Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changesets/fix_linear_sensor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release: patch
summary: Is just one parenthesis come on
2 changes: 1 addition & 1 deletion Inc/ST-LIB_LOW/Sensors/LinearSensor/LinearSensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ template <class Type>
requires std::is_integral_v<Type> || std::is_floating_point_v<Type>
Type LinearSensor<Type>::compute_value_from_voltage(float voltage) const {
const Type sensor_voltage = static_cast<Type>(voltage);
return slope * sensor_voltage + offset;
return slope * (sensor_voltage + offset);
}

template <class Type>
Expand Down
4 changes: 2 additions & 2 deletions Tests/adc_sensor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ TEST_F(ADCSensorTest, LinearSensorUsesNormalizedADCVoltageForItsTransferFunction
LinearSensor<float> sensor(SingleADCInit::instances[0], 2.0f, -1.0f, output, 5.0f);
sensor.read();

EXPECT_NEAR(output, 2.0f * ((512.0f / 1023.0f) * 5.0f) - 1.0f, 0.001f);
EXPECT_NEAR(output, 2.0f * (((512.0f / 1023.0f) * 5.0f) - 1.0f), 0.001f);
}

TEST_F(ADCSensorTest, FilteredLinearSensorReusesTheSameADCConversionPath) {
Expand All @@ -151,7 +151,7 @@ TEST_F(ADCSensorTest, FilteredLinearSensorReusesTheSameADCConversionPath) {
sensor.read();
sensor.read();

EXPECT_NEAR(output, 2.0f * ((2048.0f / 4095.0f) * 3.3f) + 1.0f, 0.001f);
EXPECT_NEAR(output, 2.0f * (((2048.0f / 4095.0f) * 3.3f) + 1.0f), 0.001f);
}

TEST_F(ADCSensorTest, LookupSensorMapsEquivalentNormalizedReadingsAcrossResolutions) {
Expand Down
Loading