refactoring: extracting DEEP_IN_THE_PAST_SECONDS contant

This commit is contained in:
rusefi 2020-01-31 01:21:56 -05:00
parent b6fe6555e0
commit d48a57d599
4 changed files with 9 additions and 3 deletions

View File

@ -41,7 +41,7 @@ WarningCodeState::WarningCodeState() {
void WarningCodeState::clear() {
warningCounter = 0;
lastErrorCode = 0;
timeOfPreviousWarning = -10;
timeOfPreviousWarning = DEEP_IN_THE_PAST_SECONDS;
recentWarnings.clear();
}

View File

@ -96,7 +96,7 @@ RpmCalculator::RpmCalculator() {
// which we cannot provide inside this parameter-less constructor. need a solution for this minor mess
// we need this initial to have not_running at first invocation
lastRpmEventTimeNt = (efitick_t) -10 * NT_PER_SECOND;
lastRpmEventTimeNt = (efitick_t) DEEP_IN_THE_PAST_SECONDS * NT_PER_SECOND;
}
/**

View File

@ -54,7 +54,7 @@ public:
TriggerWaveform triggerShape;
efitick_t previousVvtCamTime = 0;
efitick_t previousVvtCamTime = DEEP_IN_THE_PAST_SECONDS * NT_PER_SECOND;
efitick_t previousVvtCamDuration = 0;
private:

View File

@ -22,6 +22,12 @@
// milliseconds to ticks
#define MS2NT(msTime) US2NT(MS2US(msTime))
/**
* We use this 'deep in past, before ECU has ever started' value as a way to unify
* handling of first ever event and an event which has happened after a large pause in engine activity
*/
#define DEEP_IN_THE_PAST_SECONDS -10
// todo: implement a function to work with times considering counter overflow
#define overflowDiff(now, time) ((now) - (time))