From ee066cb26f3090aeb5a8b58c32505d68481ef280 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Wed, 15 Jul 2015 23:07:51 -0400 Subject: [PATCH] auto-sync --- firmware/controllers/trigger/trigger_decoder.cpp | 2 ++ firmware/controllers/trigger/trigger_decoder.h | 4 +++- firmware/controllers/trigger/trigger_structure.cpp | 1 + firmware/controllers/trigger/trigger_structure.h | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index dce752ab2f..c8c4f9578e 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -129,6 +129,8 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no currentDuration = currentDurationLong > 10 * US2NT(US_PER_SECOND_LL) ? 10 * US2NT(US_PER_SECOND_LL) : currentDurationLong; + bool_t isPrimary = triggerWheel == T_PRIMARY; + if (isLessImportant(signal)) { #if EFI_UNIT_TEST if (printTriggerDebug) { diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 89ea39a368..5130afe986 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -105,7 +105,9 @@ void initTriggerDecoderLogger(Logging *sharedLogger); bool_t isTriggerDecoderError(void); #define isLessImportant(signal) ((TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_UP) \ - || (!TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_DOWN)) + || (!TRIGGER_SHAPE(useRiseEdge) && signal != SHAFT_PRIMARY_DOWN) \ + || (!isPrimary && TRIGGER_SHAPE(useOnlyPrimaryForSync)) \ + ) #endif /* TRIGGER_DECODER_H_ */ diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 00be4d6b28..995a5ba74a 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -39,6 +39,7 @@ TriggerShape::TriggerShape() : wave.waves = h.waves; // todo: false here, true in clear() what a mess! useRiseEdge = false; + useOnlyPrimaryForSync = false; gapBothDirections = false; isSynchronizationNeeded = false; // todo: reuse 'clear' method? diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index 70a54187fd..3d4c344130 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -59,6 +59,8 @@ public: * Should we use falls or rises for gap ratio detection? */ bool_t useRiseEdge; + + bool_t useOnlyPrimaryForSync; /** * Should we measure gaps with events of both kinds? */