refactoring: extracting DEEP_IN_THE_PAST_SECONDS contant

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

View File

@ -41,7 +41,7 @@ WarningCodeState::WarningCodeState() {
void WarningCodeState::clear() { void WarningCodeState::clear() {
warningCounter = 0; warningCounter = 0;
lastErrorCode = 0; lastErrorCode = 0;
timeOfPreviousWarning = -10; timeOfPreviousWarning = DEEP_IN_THE_PAST_SECONDS;
recentWarnings.clear(); 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 // 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 // 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; TriggerWaveform triggerShape;
efitick_t previousVvtCamTime = 0; efitick_t previousVvtCamTime = DEEP_IN_THE_PAST_SECONDS * NT_PER_SECOND;
efitick_t previousVvtCamDuration = 0; efitick_t previousVvtCamDuration = 0;
private: private:

View File

@ -22,6 +22,12 @@
// milliseconds to ticks // milliseconds to ticks
#define MS2NT(msTime) US2NT(MS2US(msTime)) #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 // todo: implement a function to work with times considering counter overflow
#define overflowDiff(now, time) ((now) - (time)) #define overflowDiff(now, time) ((now) - (time))