From e19fe6bbba14c90062cd7b4fe0e541ea072cb63c Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 21 Oct 2018 11:17:47 -0400 Subject: [PATCH] refctoring trigger sync layer --- firmware/controllers/trigger/trigger_central.cpp | 4 ++-- firmware/controllers/trigger/trigger_decoder.cpp | 6 +++--- firmware/controllers/trigger/trigger_structure.cpp | 4 ++-- firmware/controllers/trigger/trigger_structure.h | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index f64e4adea0..79b152dc3b 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -422,7 +422,7 @@ static void triggerShapeInfo(void) { #if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__) TriggerShape *s = &engine->triggerCentral.triggerShape; scheduleMsg(logger, "useRise=%s", boolToString(TRIGGER_SHAPE(useRiseEdge))); - scheduleMsg(logger, "gap from %.2f to %.2f", TRIGGER_SHAPE(syncRatioFrom), TRIGGER_SHAPE(syncRatioTo)); + scheduleMsg(logger, "gap from %.2f to %.2f", TRIGGER_SHAPE(syncronizationRatioFrom[0]), TRIGGER_SHAPE(syncronizationRatioTo[0])); for (int i = 0; i < s->getSize(); i++) { scheduleMsg(logger, "event %d %.2f", i, s->eventAngles[i]); @@ -562,7 +562,7 @@ void triggerInfo(void) { boolToString(engineConfiguration->directSelfStimulation)); if (TRIGGER_SHAPE(isSynchronizationNeeded)) { - scheduleMsg(logger, "gap from %.2f to %.2f", ts->syncRatioFrom, ts->syncRatioTo); + scheduleMsg(logger, "gap from %.2f to %.2f", TRIGGER_SHAPE(syncronizationRatioFrom[0]), TRIGGER_SHAPE(syncronizationRatioTo[0])); } #endif /* EFI_PROD_CODE || EFI_SIMULATOR */ diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index fc874665f0..b4e29746e6 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -260,8 +260,8 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no #endif /* EFI_UNIT_TEST */ } - bool primaryGap = currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncRatioFrom) - && currentDuration < toothed_previous_duration * TRIGGER_SHAPE(syncRatioTo); + bool primaryGap = currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncronizationRatioFrom[0]) + && currentDuration < toothed_previous_duration * TRIGGER_SHAPE(syncronizationRatioTo[0]); bool secondaryGap = cisnan(TRIGGER_SHAPE(syncronizationRatioFrom[1])) || (toothed_previous_duration > durationBeforePrevious * TRIGGER_SHAPE(syncronizationRatioFrom[1]) && toothed_previous_duration < durationBeforePrevious * TRIGGER_SHAPE(syncronizationRatioTo[1])); @@ -289,7 +289,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no getTimeNowSeconds(), gap, prevGap, gap3, currentCycle.current_index, - TRIGGER_SHAPE(syncRatioFrom), TRIGGER_SHAPE(syncRatioTo), + TRIGGER_SHAPE(syncronizationRatioFrom[0]), TRIGGER_SHAPE(syncronizationRatioTo[0]), TRIGGER_SHAPE(syncronizationRatioFrom[1]), TRIGGER_SHAPE(syncronizationRatioTo[1]), TRIGGER_SHAPE(syncronizationRatioFrom[2]), TRIGGER_SHAPE(syncronizationRatioTo[2]), someSortOfTriggerError); diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index eba97f48fe..7211168279 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -441,8 +441,8 @@ void setToothedWheelConfiguration(TriggerShape *s, int total, int skipped, void TriggerShape::setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { isSynchronizationNeeded = true; - this->syncRatioFrom = syncRatioFrom; - this->syncRatioTo = syncRatioTo; + this->syncronizationRatioFrom[0] = syncRatioFrom; + this->syncronizationRatioTo[0] = syncRatioTo; this->syncRatioAvg = (int)efiRound((syncRatioFrom + syncRatioTo) * 0.5f, 1.0f); #if EFI_UNIT_TEST || defined(__DOXYGEN__) if (printTriggerDebug) { diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index 73f9854074..a4fef5b813 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -102,8 +102,7 @@ public: float syncronizationRatioFrom[GAP_TRACKING_LENGHT]; float syncronizationRatioTo[GAP_TRACKING_LENGHT]; - float syncRatioFrom; - float syncRatioTo; + /** * used by NoiselessTriggerDecoder (See TriggerCentral::handleShaftSignal()) */