From 2c7a902d399a410b0ea5107773035fea35628277 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 26 Sep 2024 16:27:40 -0700 Subject: [PATCH] minor simplification to TableFunc template params --- .../controllers/sensors/converters/table_func.h | 4 ++-- firmware/init/sensor/init_fuel_level.cpp | 6 +----- unit_tests/tests/sensor/table_func.cpp | 15 --------------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/firmware/controllers/sensors/converters/table_func.h b/firmware/controllers/sensors/converters/table_func.h index 7893e42681..4b1be2b935 100644 --- a/firmware/controllers/sensors/converters/table_func.h +++ b/firmware/controllers/sensors/converters/table_func.h @@ -11,7 +11,7 @@ #include -template > +template class TableFunc final : public SensorConverter { public: TableFunc(TBin (&bins)[TSize], TValue (&values)[TSize]) @@ -21,7 +21,7 @@ class TableFunc final : public SensorConverter { } SensorResult convert(float inputValue) const override { - return interpolate2d(inputValue, m_bins, m_values) * TOutputScale::asFloat(); + return interpolate2d(inputValue, m_bins, m_values); } void showInfo(float /*testInputValue*/) const override { } diff --git a/firmware/init/sensor/init_fuel_level.cpp b/firmware/init/sensor/init_fuel_level.cpp index a92e91e512..57593c8376 100644 --- a/firmware/init/sensor/init_fuel_level.cpp +++ b/firmware/init/sensor/init_fuel_level.cpp @@ -12,11 +12,7 @@ static FunctionalSensor fuelSensor(SensorType::FuelLevel, /* timeout = */ MS2NT( using BinType = std::remove_extent_tfuelLevelBins)>; using ValueType = std::remove_extent_tfuelLevelValues)>; -static TableFunc - > - fuelCurve(config->fuelLevelBins, config->fuelLevelValues); +static TableFunc fuelCurve(config->fuelLevelBins, config->fuelLevelValues); void initFuelLevel() { adc_channel_e channel = engineConfiguration->fuelLevelSensor; diff --git a/unit_tests/tests/sensor/table_func.cpp b/unit_tests/tests/sensor/table_func.cpp index 1445345806..e7097057b5 100644 --- a/unit_tests/tests/sensor/table_func.cpp +++ b/unit_tests/tests/sensor/table_func.cpp @@ -14,18 +14,3 @@ TEST(TableFuncTest, basic) { EXPECT_EQ(40, dut.convert(10).value_or(0)); EXPECT_EQ(40, dut.convert(20).value_or(0)); } - -TEST(TableFuncTest, scaled) { - scaled_channel in[] = { 0, 1, 2 }; - uint8_t out[] = { 70, 60, 50 }; - - using BinType = std::remove_extent_t; - - TableFunc> - dut(in, out); - - EXPECT_EQ(0.65f, dut.convert(0.5f).value_or(0)); - EXPECT_EQ(0.55f, dut.convert(1.5f).value_or(0)); -}