diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 47bb5c33fc..9fd08f7fcd 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -292,7 +292,7 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if (BOARD_TLE8888_COUNT > 0) // nasty value injection into C driver which would not be able to access Engine class - vBattForTle8888 = sensors.vBatt; + vBattForTle8888 = Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE); #endif /* BOARD_TLE8888_COUNT */ #if EFI_MC33816 @@ -556,7 +556,7 @@ void Engine::checkShutdown(DECLARE_ENGINE_PARAMETER_SIGNATURE) { // if the ignition key is turned on again, // we cancel the shutdown mode, but only if all shutdown procedures are complete const float vBattThresholdOn = 8.0f; - if ((sensors.vBatt > vBattThresholdOn) && !isInShutdownMode(PASS_ENGINE_PARAMETER_SIGNATURE)) { + if ((Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE) > vBattThresholdOn) && !isInShutdownMode(PASS_ENGINE_PARAMETER_SIGNATURE)) { ignitionOnTimeNt = getTimeNowNt(); stopEngineRequestTimeNt = 0; scheduleMsg(&engineLogger, "Ignition voltage detected! Cancel the engine shutdown!"); @@ -578,7 +578,7 @@ bool Engine::isInShutdownMode(DECLARE_ENGINE_PARAMETER_SIGNATURE) const { if (stopEngineRequestTimeNt == 0 && ignitionOnTimeNt > 0) { const float vBattThresholdOff = 5.0f; // start the shutdown process if the ignition voltage dropped low - if (sensors.vBatt <= vBattThresholdOff) { + if (Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE) <= vBattThresholdOff) { scheduleStopEngine(); } } diff --git a/firmware/controllers/can/can_dash.cpp b/firmware/controllers/can/can_dash.cpp index 6fafcb2c9a..ea3b9d861c 100644 --- a/firmware/controllers/can/can_dash.cpp +++ b/firmware/controllers/can/can_dash.cpp @@ -138,7 +138,7 @@ void canMazdaRX8(void) { msg[4] = 0x01; //Oil Pressure (not really a gauge) msg[5] = 0x00; //check engine light msg[6] = 0x00; //Coolant, oil and battery - if ((GET_RPM()>0) && (engine->sensors.vBatt<13)) { + if ((GET_RPM()>0) && (Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE)<13)) { msg.setBit(6, 6); // battery light } if (!clt.Valid || clt.Value > 105) { diff --git a/firmware/hw_layer/mc33816.cpp b/firmware/hw_layer/mc33816.cpp index 002fe2de14..e892468d30 100644 --- a/firmware/hw_layer/mc33816.cpp +++ b/firmware/hw_layer/mc33816.cpp @@ -474,7 +474,7 @@ static void mcRestart() { driven.setValue(0); // ensure driven is off - if (engine->sensors.vBatt < LOW_VBATT) { + if (Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE) < LOW_VBATT) { scheduleMsg(logger, "GDI not Restarting until we see VBatt"); return; } @@ -570,7 +570,7 @@ void initMc33816IfNeeded() { if (!haveMc33816) { return; } - if (engine->sensors.vBatt < LOW_VBATT) { + if (Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE) < LOW_VBATT) { isInitializaed = false; } else { if (!isInitializaed) {