diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 5a0d5652de..b0e7cc72fe 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -314,10 +314,6 @@ void Engine::updateSwitchInputs() { #endif // EFI_GPIO_HARDWARE } -void Engine::onTriggerSignalEvent() { - isSpinning = true; -} - Engine::Engine() { reset(); } @@ -446,7 +442,7 @@ void Engine::efiWatchdog() { } mostRecentMs = msNow; - if (!isSpinning) { + if (!getTriggerCentral()->isSpinningJustForWatchdog) { if (!isRunningBenchTest() && enginePins.stopPins()) { // todo: make this a firmwareError assuming functional tests would run warning(CUSTOM_ERR_2ND_WATCHDOG, "Some pins were turned off by 2nd pass watchdog"); @@ -462,7 +458,7 @@ void Engine::efiWatchdog() { // Engine moved recently, no need to safe pins. return; } - isSpinning = false; + getTriggerCentral()->isSpinningJustForWatchdog = false; ignitionEvents.isReady = false; #if EFI_PROD_CODE || EFI_SIMULATOR efiPrintf("engine has STOPPED"); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index a4b5d9cc3a..f776aae7e4 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -284,10 +284,6 @@ public: */ int ignitionPin[MAX_CYLINDER_COUNT]; - /** - * this is invoked each time we register a trigger tooth signal - */ - void onTriggerSignalEvent(); EngineState engineState; /** * idle blip is a development tool: alternator PID research for instance have benefited from a repetitive change of RPM @@ -340,13 +336,6 @@ public: LimpManager limpManager; private: - /** - * By the way: - * 'cranking' means engine is not stopped and the rpm are below crankingRpm - * 'running' means RPM are above crankingRpm - * 'spinning' means the engine is not stopped - */ - bool isSpinning = false; void reset(); void injectEngineReferences(); diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 7162bd17a6..e436cf4f6c 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -666,7 +666,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta } } - engine->onTriggerSignalEvent(); + isSpinningJustForWatchdog = true; m_lastEventTimer.reset(timestamp); @@ -886,7 +886,7 @@ void triggerInfo(void) { static void resetRunningTriggerCounters() { #if !EFI_UNIT_TEST - engine->triggerCentral.resetCounters(); + getTriggerCentral()->resetCounters(); triggerInfo(); #endif } diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 865ab7c274..55339e119b 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -70,6 +70,18 @@ public: LocalVersionHolder triggerVersion; + /** + * By the way: + * 'cranking' means engine is not stopped and the rpm are below crankingRpm + * 'running' means RPM are above crankingRpm + * 'spinning' means the engine is not stopped + */ + // todo: combine with other RpmCalculator fields? + /** + * this is set to true each time we register a trigger tooth signal + */ + bool isSpinningJustForWatchdog = false; + angle_t mapCamPrevToothAngle = -1; float mapCamPrevCycleValue = 0; int prevChangeAtCycle = 0;