deep rabbit holes are the best ones!

refactoring: encapsulation
This commit is contained in:
Andrey 2022-09-14 02:24:41 -04:00
parent 1d0f13fc41
commit d9accf1772
4 changed files with 16 additions and 19 deletions

View File

@ -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");

View File

@ -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();

View File

@ -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
}

View File

@ -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;