From 8d3d716d7f505a7013de540f043f608df524816d Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 3 Feb 2019 01:34:20 -0500 Subject: [PATCH] Refactor Trigger System #635 --- .../trigger/decoders/trigger_structure.cpp | 15 +++++++-------- .../trigger/decoders/trigger_structure.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 1700131495..a7f9db2d38 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -151,7 +151,7 @@ angle_t TriggerShape::getAngle(int index) const { void TriggerShape::addEvent3(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam, float filterLeft, float filterRight) { if (angle > filterLeft && angle < filterRight) - addEvent(useOnlyRisingEdgeForTriggerTemp, angle / getEngineCycle(operationMode), channelIndex, stateParam); + addEvent(angle / getEngineCycle(operationMode), channelIndex, stateParam); } operation_mode_e TriggerShape::getOperationMode() { @@ -171,14 +171,10 @@ void TriggerShape::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrigger } void TriggerShape::addEvent720(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam) { - addEvent(useOnlyRisingEdgeForTriggerTemp, angle / 720, channelIndex, stateParam); + addEvent(angle / 720, channelIndex, stateParam); } -// todo: the whole 'useOnlyRisingEdgeForTrigger' parameter and logic should not be here -// todo: see calculateExpectedEventCounts -// related calculation should be done once trigger is initialized outside of trigger shape scope -void TriggerShape::addEvent(bool useOnlyRisingEdgeForTrigger, angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam) { - +void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam) { efiAssertVoid(CUSTOM_OMODE_UNDEF, operationMode != OM_NONE, "operationMode not set"); efiAssertVoid(CUSTOM_ERR_6598, channelIndex!= T_SECONDARY || needSecondTriggerInput, "secondary needed or not?"); @@ -202,7 +198,10 @@ void TriggerShape::addEvent(bool useOnlyRisingEdgeForTrigger, angle_t angle, tri #endif - if (!useOnlyRisingEdgeForTrigger || stateParam == TV_RISE) { + // todo: the whole 'useOnlyRisingEdgeForTrigger' parameter and logic should not be here + // todo: see calculateExpectedEventCounts + // related calculation should be done once trigger is initialized outside of trigger shape scope + if (!useOnlyRisingEdgeForTriggerTemp || stateParam == TV_RISE) { expectedEventCount[channelIndex]++; } diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index 88abbf9170..879883b379 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -211,7 +211,7 @@ public: bool useOnlyRisingEdgeForTriggerTemp; /* 0..1 angle range */ - void addEvent(bool useOnlyRisingEdgeForTrigger, angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state); + void addEvent(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state); /* 0..720 angle range * Deprecated? */