From be2a34a9562cbc0824815d3b588e718a7936d0e7 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Fri, 4 Dec 2020 16:24:19 -0500 Subject: [PATCH] refactoring: magic constants --- firmware/controllers/trigger/decoders/trigger_structure.cpp | 6 +++--- firmware/controllers/trigger/decoders/trigger_structure.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 80c67cadc0..f4cbd86a4a 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -428,7 +428,7 @@ void TriggerWaveform::prepareShape(TriggerFormDetails *details DECLARE_ENGINE_PA } void TriggerWaveform::setTriggerSynchronizationGap(float syncRatio) { - setTriggerSynchronizationGap3(/*gapIndex*/0, syncRatio * 0.75f, syncRatio * 1.25f); + setTriggerSynchronizationGap3(/*gapIndex*/0, syncRatio * TRIGGER_GAP_DEVIATION_LOW, syncRatio * TRIGGER_GAP_DEVIATION_HIGH); } void TriggerWaveform::setSecondTriggerSynchronizationGap2(float syncRatioFrom, float syncRatioTo) { @@ -436,11 +436,11 @@ void TriggerWaveform::setSecondTriggerSynchronizationGap2(float syncRatioFrom, f } void TriggerWaveform::setThirdTriggerSynchronizationGap(float syncRatio) { - setTriggerSynchronizationGap3(/*gapIndex*/2, syncRatio * 0.75f, syncRatio * 1.25f); + setTriggerSynchronizationGap3(/*gapIndex*/2, syncRatio * TRIGGER_GAP_DEVIATION_LOW, syncRatio * TRIGGER_GAP_DEVIATION_HIGH); } void TriggerWaveform::setSecondTriggerSynchronizationGap(float syncRatio) { - setTriggerSynchronizationGap3(/*gapIndex*/1, syncRatio * 0.75f, syncRatio * 1.25f); + setTriggerSynchronizationGap3(/*gapIndex*/1, syncRatio * TRIGGER_GAP_DEVIATION_LOW, syncRatio * TRIGGER_GAP_DEVIATION_HIGH); } diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index c600a98631..2a6a797f66 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -13,6 +13,10 @@ #define FOUR_STROKE_ENGINE_CYCLE 720 +#define TRIGGER_GAP_DEVIATION 0.25f +#define TRIGGER_GAP_DEVIATION_LOW (1.0f - TRIGGER_GAP_DEVIATION) +#define TRIGGER_GAP_DEVIATION_HIGH (1.0f + TRIGGER_GAP_DEVIATION) + #if EFI_ENABLE_ASSERTS #define assertAngleRange(angle, msg, code) if (angle > 10000000 || angle < -10000000) { firmwareError(code, "angle range %s %.2f", msg, angle);angle = 0;} #else