diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 9fd08f7fcd..4640958745 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -288,8 +288,6 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { fuelLevelVoltage); } - sensors.vBatt = Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE); - #if (BOARD_TLE8888_COUNT > 0) // nasty value injection into C driver which would not be able to access Engine class vBattForTle8888 = Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE); diff --git a/firmware/controllers/algo/engine_parts.h b/firmware/controllers/algo/engine_parts.h index 1bb92e2434..271a75b156 100644 --- a/firmware/controllers/algo/engine_parts.h +++ b/firmware/controllers/algo/engine_parts.h @@ -36,9 +36,6 @@ public: Accelerometer accelerometer; - // todo: remove this variable, replace with Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE) - // todo: https://github.com/rusefi/rusefi/issues/2260 - float vBatt = 0; /** * that's fuel in tank - just a gauge */ diff --git a/firmware/controllers/algo/fuel/injector_model.cpp b/firmware/controllers/algo/fuel/injector_model.cpp index 6b7c3c120c..d45865e65d 100644 --- a/firmware/controllers/algo/fuel/injector_model.cpp +++ b/firmware/controllers/algo/fuel/injector_model.cpp @@ -78,7 +78,7 @@ float InjectorModel::getInjectorMassFlowRate() const { float InjectorModel::getDeadtime() const { return interpolate2d( - ENGINE(sensors.vBatt), + Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE), engineConfiguration->injector.battLagCorrBins, engineConfiguration->injector.battLagCorr ); diff --git a/firmware/hw_layer/sensors/cj125_logic.cpp b/firmware/hw_layer/sensors/cj125_logic.cpp index d188354080..43bbe5c895 100644 --- a/firmware/hw_layer/sensors/cj125_logic.cpp +++ b/firmware/hw_layer/sensors/cj125_logic.cpp @@ -20,7 +20,7 @@ CJ125::CJ125() : wboHeaterControl("wbo"), void CJ125::SetHeater(float value DECLARE_ENGINE_PARAMETER_SUFFIX) { // limit duty cycle for sensor safety // todo: would be much nicer to have continuous function (vBatt) - float maxDuty = (engine->sensors.vBatt > CJ125_HEATER_LIMITING_VOLTAGE) ? CJ125_HEATER_LIMITING_RATE : 1.0f; + float maxDuty = (Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE) > CJ125_HEATER_LIMITING_VOLTAGE) ? CJ125_HEATER_LIMITING_RATE : 1.0f; heaterDuty = (value < CJ125_HEATER_MIN_DUTY) ? 0.0f : minF(maxF(value, 0.0f), maxDuty); #ifdef CJ125_DEBUG scheduleMsg(logger, "cjSetHeater: %.2f", heaterDuty); diff --git a/unit_tests/tests/ignition_injection/test_injector_model.cpp b/unit_tests/tests/ignition_injection/test_injector_model.cpp index 45030d3012..ed96a973d3 100644 --- a/unit_tests/tests/ignition_injection/test_injector_model.cpp +++ b/unit_tests/tests/ignition_injection/test_injector_model.cpp @@ -49,10 +49,10 @@ TEST(InjectorModel, Deadtime) { InjectorModel dut; INJECT_ENGINE_REFERENCE(&dut); - engine->sensors.vBatt = 3; + Sensor::setMockValue(SensorType::BatteryVoltage, 3); EXPECT_EQ(dut.getDeadtime(), 6); - engine->sensors.vBatt = 7; + Sensor::setMockValue(SensorType::BatteryVoltage, 7); EXPECT_EQ(dut.getDeadtime(), 14); }