diff --git a/firmware/controllers/trigger/decoders/trigger_chrysler.cpp b/firmware/controllers/trigger/decoders/trigger_chrysler.cpp index d8b851421c..3566260ed7 100644 --- a/firmware/controllers/trigger/decoders/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/decoders/trigger_chrysler.cpp @@ -124,7 +124,7 @@ gap=1.43/0.71 // these values only work well for 'useFronOnly' mode!!! s->setTriggerSynchronizationGap2(0.75, 1.5); - s->setSecondTriggerSynchronizationGap2(0.65, 1.25); + s->setTriggerSynchronizationGap3(1, 0.65, 1.25); float EPS_ANGLE = 0.3; diff --git a/firmware/controllers/trigger/decoders/trigger_subaru.cpp b/firmware/controllers/trigger/decoders/trigger_subaru.cpp index ed6a44fc85..4cc15d54be 100644 --- a/firmware/controllers/trigger/decoders/trigger_subaru.cpp +++ b/firmware/controllers/trigger/decoders/trigger_subaru.cpp @@ -108,7 +108,7 @@ void initializeSubaru7_6(TriggerShape *s DECLARE_ENGINE_PARAMETER_SUFFIX) { s->addEvent2(720, T_PRIMARY, TV_FALL PASS_ENGINE_PARAMETER_SUFFIX); s->setTriggerSynchronizationGap2(4.9, 9); - s->setSecondTriggerSynchronizationGap2(0.6, 1.25); + s->setTriggerSynchronizationGap3(1, 0.6, 1.25); s->isSynchronizationNeeded = true; diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 7211168279..6cea83385b 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -440,37 +440,38 @@ void setToothedWheelConfiguration(TriggerShape *s, int total, int skipped, } void TriggerShape::setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { + setTriggerSynchronizationGap3(0, syncRatioFrom, syncRatioTo); +} + +void TriggerShape::setTriggerSynchronizationGap3(int index, float syncRatioFrom, float syncRatioTo) { isSynchronizationNeeded = true; - this->syncronizationRatioFrom[0] = syncRatioFrom; - this->syncronizationRatioTo[0] = syncRatioTo; - this->syncRatioAvg = (int)efiRound((syncRatioFrom + syncRatioTo) * 0.5f, 1.0f); + this->syncronizationRatioFrom[index] = syncRatioFrom; + this->syncronizationRatioTo[index] = syncRatioTo; + if (index == 0) { + // we have a special case here - only sync with one gap has this feature + this->syncRatioAvg = (int)efiRound((syncRatioFrom + syncRatioTo) * 0.5f, 1.0f); + } + #if EFI_UNIT_TEST || defined(__DOXYGEN__) if (printTriggerDebug) { - printf("setTriggerSynchronizationGap2 %.2f %.2f\r\n", syncRatioFrom, syncRatioTo); + printf("setTriggerSynchronizationGap3 %d %.2f %.2f\r\n", index, syncRatioFrom, syncRatioTo); } #endif /* EFI_UNIT_TEST */ + } void TriggerShape::setTriggerSynchronizationGap(float syncRatio) { - setTriggerSynchronizationGap2(syncRatio * 0.75f, syncRatio * 1.25f); + setTriggerSynchronizationGap3(0, syncRatio * 0.75f, syncRatio * 1.25f); } void TriggerShape::setSecondTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { - isSynchronizationNeeded = true; - this->syncronizationRatioFrom[1] = syncRatioFrom; - this->syncronizationRatioTo[1] = syncRatioTo; + setTriggerSynchronizationGap3(1, syncRatioFrom, syncRatioTo); } void TriggerShape::setThirdTriggerSynchronizationGap(float syncRatio) { - setThirdTriggerSynchronizationGap2(syncRatio * 0.75f, syncRatio * 1.25f); -} - -void TriggerShape::setThirdTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { - isSynchronizationNeeded = true; - this->syncronizationRatioFrom[2] = syncRatioFrom; - this->syncronizationRatioTo[2] = syncRatioTo; + setTriggerSynchronizationGap3(2, syncRatio * 0.75f, syncRatio * 1.25f); } void TriggerShape::setSecondTriggerSynchronizationGap(float syncRatio) { - setSecondTriggerSynchronizationGap2(syncRatio * 0.75f, syncRatio * 1.25f); + setTriggerSynchronizationGap3(1, syncRatio * 0.75f, syncRatio * 1.25f); } diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index 24068f3573..167407710e 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -178,11 +178,11 @@ public: void initialize(operation_mode_e operationMode, bool needSecondTriggerInput); void setTriggerSynchronizationGap(float syncRatio); + void setTriggerSynchronizationGap3(int index, float syncRatioFrom, float syncRatioTo); void setTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo); void setSecondTriggerSynchronizationGap(float syncRatio); void setSecondTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo); void setThirdTriggerSynchronizationGap(float syncRatio); - void setThirdTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo); /** * this one is per CRANKshaft revolution */