diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 15394cf410..494d30a805 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -184,7 +184,7 @@ TransmissionState::TransmissionState() { } EngineState::EngineState() { - dwellAngle = 0; + dwellAngle = NAN; engineNoiseHipLevel = 0; injectorLag = 0; warningCounter = 0; @@ -231,7 +231,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) { int rpm = ENGINE(rpmCalculator).getRpm(PASS_ENGINE_PARAMETER_SIGNATURE); sparkDwell = getSparkDwell(rpm PASS_ENGINE_PARAMETER_SUFFIX); - dwellAngle = sparkDwell / getOneDegreeTimeMs(rpm); + dwellAngle = cisnan(rpm) ? NAN : sparkDwell / getOneDegreeTimeMs(rpm); if (hasAfrSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { engine->sensors.currentAfr = getAfr(PASS_ENGINE_PARAMETER_SIGNATURE); } diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 28567bb09f..129f6b71b1 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -166,6 +166,7 @@ public: /** * ignition dwell duration as crankshaft angle + * NAN if engine is stopped */ angle_t dwellAngle;