The Big Refactoring of 2019: configuration version should not be a global variable #656

This commit is contained in:
rusefi 2019-01-15 21:18:44 -05:00
parent 0a89fcca33
commit 662831cde9
3 changed files with 11 additions and 7 deletions

View File

@ -594,10 +594,8 @@ static void setBlinkingPeriod(int value) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
extern efitick_t lastDecodingErrorTime;
static bool isTriggerErrorNow() {
bool justHadError = (getTimeNowNt() - lastDecodingErrorTime) < US2NT(2 * 1000 * 3 * blinkingPeriod);
bool justHadError = (getTimeNowNt() - engine->triggerCentral.triggerState.lastDecodingErrorTime) < US2NT(2 * 1000 * 3 * blinkingPeriod);
return justHadError || isTriggerDecoderError();
}

View File

@ -40,6 +40,10 @@
EXTERN_ENGINE
;
// todo: this should become a field on some class
// no reason to make this a field on TriggerState since we have two instances of that one
// and only one needs this data structure. we probably need a virtual method of .addError() and
// only TriggerStateWithRunningStatistics would have the field?
static cyclic_buffer<int> errorDetection;
#if ! EFI_PROD_CODE || defined(__DOXYGEN__)
@ -53,10 +57,6 @@ extern TunerStudioOutputChannels tsOutputChannels;
static Logging * logger;
efitick_t lastDecodingErrorTime = US2NT(-10000000LL);
// the boolean flag is a performance optimization so that complex comparison is avoided if no error
static bool someSortOfTriggerError = false;
/**
* @return TRUE is something is wrong with trigger decoding
*/
@ -249,6 +249,8 @@ void TriggerState::reset() {
totalRevolutionCounter = 0;
totalTriggerErrorCounter = 0;
orderingErrorCounter = 0;
lastDecodingErrorTime = US2NT(-10000000LL);
someSortOfTriggerError = false;
memset(toothDurations, 0, sizeof(toothDurations));
curSignal = SHAFT_PRIMARY_FALLING;

View File

@ -74,6 +74,10 @@ public:
*/
bool shaft_is_synchronized;
efitick_t lastDecodingErrorTime;
// the boolean flag is a performance optimization so that complex comparison is avoided if no error
bool someSortOfTriggerError;
/**
* current duration at index zero and previous durations are following
*/