From 851e8e48d3b263fb10c237a00690dc61503c4e73 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 11 Sep 2022 02:57:35 -0400 Subject: [PATCH] refactoring: type safety --- firmware/controllers/core/state_sequence.h | 14 +- .../system/timer/pwm_generator_logic.cpp | 8 +- .../trigger/decoders/trigger_chrysler.cpp | 702 +++++++++--------- .../trigger/decoders/trigger_gm.cpp | 40 +- .../trigger/decoders/trigger_honda.cpp | 50 +- .../trigger/decoders/trigger_mazda.cpp | 120 +-- .../trigger/decoders/trigger_mercedes.cpp | 12 +- .../trigger/decoders/trigger_misc.cpp | 76 +- .../trigger/decoders/trigger_mitsubishi.cpp | 60 +- .../trigger/decoders/trigger_nissan.cpp | 32 +- .../trigger/decoders/trigger_renix.cpp | 8 +- .../trigger/decoders/trigger_rover.cpp | 20 +- .../trigger/decoders/trigger_structure.cpp | 18 +- .../trigger/decoders/trigger_structure.h | 12 +- .../trigger/decoders/trigger_subaru.cpp | 48 +- .../trigger/decoders/trigger_suzuki.cpp | 20 +- .../trigger/decoders/trigger_toyota.cpp | 64 +- .../trigger/decoders/trigger_universal.cpp | 60 +- .../trigger/decoders/trigger_vw.cpp | 16 +- .../controllers/trigger/trigger_central.cpp | 16 +- .../controllers/trigger/trigger_central.h | 2 +- .../controllers/trigger/trigger_decoder.cpp | 18 +- .../controllers/trigger/trigger_decoder.h | 2 +- .../trigger/trigger_emulator_algo.cpp | 2 +- .../controllers/trigger/trigger_simulator.cpp | 2 +- .../trigger/trigger_input_comp.cpp | 4 +- .../trigger/trigger_input_exti.cpp | 4 +- .../timer/pwm_generator_logic.cpp | 4 +- unit_tests/logicdata_csv_reader.cpp | 2 +- .../ignition_injection/test_fuel_map.cpp | 42 +- unit_tests/tests/trigger/test_2jz_vvt.cpp | 4 +- .../tests/trigger/test_cam_vvt_input.cpp | 16 +- .../tests/trigger/test_nissan_vq_vvt.cpp | 7 +- unit_tests/tests/trigger/test_quad_cam.cpp | 16 +- 34 files changed, 760 insertions(+), 761 deletions(-) diff --git a/firmware/controllers/core/state_sequence.h b/firmware/controllers/core/state_sequence.h index 942fc19167..685a95f479 100644 --- a/firmware/controllers/core/state_sequence.h +++ b/firmware/controllers/core/state_sequence.h @@ -11,10 +11,10 @@ #include "rusefi_enums.h" #include "expected.h" -typedef enum { - TV_FALL = 0, - TV_RISE = 1 -} trigger_value_e; +enum class TriggerValue : uint8_t { + FALL = 0, + RISE = 1 +}; // see also 'HW_EVENT_TYPES' typedef enum { @@ -40,7 +40,7 @@ typedef enum { #endif /* PWM_PHASE_MAX_COUNT */ #define PWM_PHASE_MAX_WAVE_PER_PWM 2 -typedef trigger_value_e pin_state_t; +typedef TriggerValue pin_state_t; /** * This class represents multi-channel logical signals with shared time axis @@ -83,7 +83,7 @@ public: // todo: would be nice to get this asserting working //firmwareError(OBD_PCM_Processor_Fault, "channel index %d/%d", channelIndex, waveCount); } - return ((waveForm[phaseIndex] >> channelIndex) & 1) ? TV_RISE : TV_FALL; + return ((waveForm[phaseIndex] >> channelIndex) & 1) ? TriggerValue::RISE : TriggerValue::FALL; } void reset() { @@ -100,7 +100,7 @@ public: //firmwareError(OBD_PCM_Processor_Fault, "channel index %d/%d", channelIndex, waveCount); } uint8_t & ref = waveForm[phaseIndex]; - ref = (ref & ~(1U << channelIndex)) | ((state == TV_RISE ? 1 : 0) << channelIndex); + ref = (ref & ~(1U << channelIndex)) | ((state == TriggerValue::RISE ? 1 : 0) << channelIndex); } private: diff --git a/firmware/controllers/system/timer/pwm_generator_logic.cpp b/firmware/controllers/system/timer/pwm_generator_logic.cpp index 30f1936783..66920272af 100644 --- a/firmware/controllers/system/timer/pwm_generator_logic.cpp +++ b/firmware/controllers/system/timer/pwm_generator_logic.cpp @@ -316,8 +316,8 @@ void startSimplePwm(SimplePwm *state, const char *msg, ExecutorInterface *execut state->seq.setSwitchTime(0, dutyCycle); state->seq.setSwitchTime(1, 1); - state->seq.setChannelState(0, 0, TV_FALL); - state->seq.setChannelState(0, 1, TV_RISE); + state->seq.setChannelState(0, 0, TriggerValue::FALL); + state->seq.setChannelState(0, 1, TriggerValue::RISE); state->outputPins[0] = output; @@ -376,7 +376,7 @@ void applyPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { efiAssertVoid(CUSTOM_ERR_6664, state->multiChannelStateSequence->waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount"); for (int channelIndex = 0; channelIndex < state->multiChannelStateSequence->waveCount; channelIndex++) { OutputPin *output = state->outputPins[channelIndex]; - int value = state->multiChannelStateSequence->getChannelState(channelIndex, stateIndex); - output->setValue(value); + TriggerValue value = state->multiChannelStateSequence->getChannelState(channelIndex, stateIndex); + output->setValue(value == TriggerValue::RISE); } } diff --git a/firmware/controllers/trigger/decoders/trigger_chrysler.cpp b/firmware/controllers/trigger/decoders/trigger_chrysler.cpp index 862515ae9e..7afc974a61 100644 --- a/firmware/controllers/trigger/decoders/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/decoders/trigger_chrysler.cpp @@ -19,11 +19,11 @@ void initDodgeRam(TriggerWaveform *s) { addSkippedToothTriggerEvents(T_SECONDARY, s, 8, 0, 0.06, -25, 360, 0, 720); - s->addEvent720(360, T_PRIMARY, TV_RISE); + s->addEvent720(360, T_PRIMARY, TriggerValue::RISE); addSkippedToothTriggerEvents(T_SECONDARY, s, 8, 0, 0.06, 360 - 25, 360, 0, 720); - s->addEvent720(720, T_PRIMARY, TV_FALL); + s->addEvent720(720, T_PRIMARY, TriggerValue::FALL); } void configureNeon2003TriggerWaveformCrank(TriggerWaveform *s) { @@ -32,71 +32,71 @@ void configureNeon2003TriggerWaveformCrank(TriggerWaveform *s) { s->setTriggerSynchronizationGap(3); - s->addEvent360(25, T_PRIMARY, TV_FALL); - s->addEvent360(30, T_PRIMARY, TV_RISE); - s->addEvent360(35, T_PRIMARY, TV_FALL); - s->addEvent360(40, T_PRIMARY, TV_RISE); - s->addEvent360(45, T_PRIMARY, TV_FALL); - s->addEvent360(50, T_PRIMARY, TV_RISE); - s->addEvent360(55, T_PRIMARY, TV_FALL); - s->addEvent360(60, T_PRIMARY, TV_RISE); - s->addEvent360(65, T_PRIMARY, TV_FALL); - s->addEvent360(70, T_PRIMARY, TV_RISE); - s->addEvent360(75, T_PRIMARY, TV_FALL); - s->addEvent360(80, T_PRIMARY, TV_RISE); - s->addEvent360(85, T_PRIMARY, TV_FALL); - s->addEvent360(90, T_PRIMARY, TV_RISE); - s->addEvent360(95, T_PRIMARY, TV_FALL); - s->addEvent360(100, T_PRIMARY, TV_RISE); - s->addEvent360(105, T_PRIMARY, TV_FALL); - s->addEvent360(110, T_PRIMARY, TV_RISE); - s->addEvent360(115, T_PRIMARY, TV_FALL); - s->addEvent360(120, T_PRIMARY, TV_RISE); - s->addEvent360(125, T_PRIMARY, TV_FALL); - s->addEvent360(130, T_PRIMARY, TV_RISE); - s->addEvent360(135, T_PRIMARY, TV_FALL); - s->addEvent360(140, T_PRIMARY, TV_RISE); - s->addEvent360(145,T_PRIMARY, TV_FALL); - s->addEvent360(150, T_PRIMARY, TV_RISE); - s->addEvent360(155, T_PRIMARY, TV_FALL); - s->addEvent360(160, T_PRIMARY, TV_RISE); - s->addEvent360(165, T_PRIMARY, TV_FALL); - s->addEvent360(170, T_PRIMARY, TV_RISE); - s->addEvent360(175, T_PRIMARY, TV_FALL); - s->addEvent360(180, T_PRIMARY, TV_RISE); - s->addEvent360(185, T_PRIMARY, TV_FALL); + s->addEvent360(25, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(30, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(35, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(40, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(45, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(50, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(55, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(60, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(65, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(70, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(75, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(80, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(85, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(90, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(95, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(100, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(105, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(110, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(115, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(120, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(125, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(130, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(135, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(140, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(145,T_PRIMARY, TriggerValue::FALL); + s->addEvent360(150, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(155, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(160, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(165, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(170, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(175, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(180, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(185, T_PRIMARY, TriggerValue::FALL); // gap 25 - s->addEvent360(210, T_PRIMARY, TV_RISE); - s->addEvent360(215, T_PRIMARY, TV_FALL); - s->addEvent360(220, T_PRIMARY, TV_RISE); - s->addEvent360(225, T_PRIMARY, TV_FALL); - s->addEvent360(230, T_PRIMARY, TV_RISE); - s->addEvent360(235, T_PRIMARY, TV_FALL); - s->addEvent360(240, T_PRIMARY, TV_RISE); - s->addEvent360(245, T_PRIMARY, TV_FALL); - s->addEvent360(250, T_PRIMARY, TV_RISE); - s->addEvent360(255, T_PRIMARY, TV_FALL); - s->addEvent360(260, T_PRIMARY, TV_RISE); - s->addEvent360(265, T_PRIMARY, TV_FALL); - s->addEvent360(270, T_PRIMARY, TV_RISE); - s->addEvent360(275, T_PRIMARY, TV_FALL); - s->addEvent360(280, T_PRIMARY, TV_RISE); - s->addEvent360(285, T_PRIMARY, TV_FALL); - s->addEvent360(290, T_PRIMARY, TV_RISE); - s->addEvent360(295, T_PRIMARY, TV_FALL); - s->addEvent360(300, T_PRIMARY, TV_RISE); - s->addEvent360(305, T_PRIMARY, TV_FALL); - s->addEvent360(310, T_PRIMARY, TV_RISE); - s->addEvent360(315, T_PRIMARY, TV_FALL); - s->addEvent360(320, T_PRIMARY, TV_RISE); - s->addEvent360(325, T_PRIMARY, TV_FALL); - s->addEvent360(330, T_PRIMARY, TV_RISE); - s->addEvent360(335, T_PRIMARY, TV_FALL); - s->addEvent360(340, T_PRIMARY, TV_RISE); - s->addEvent360(345, T_PRIMARY, TV_FALL); - s->addEvent360(350, T_PRIMARY, TV_RISE); - s->addEvent360(355, T_PRIMARY, TV_FALL); - s->addEvent360(360, T_PRIMARY, TV_RISE); + s->addEvent360(210, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(215, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(220, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(225, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(230, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(235, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(240, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(245, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(250, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(255, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(260, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(265, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(270, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(275, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(280, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(285, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(290, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(295, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(300, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(305, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(310, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(315, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(320, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(325, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(330, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(335, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(340, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(345, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(350, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(355, T_PRIMARY, TriggerValue::FALL); + s->addEvent360(360, T_PRIMARY, TriggerValue::RISE); } void configureNeon2003TriggerWaveformCam(TriggerWaveform *s) { @@ -129,23 +129,23 @@ gap=1.43/0.71 s->useOnlyPrimaryForSync = true; if (useOnlyPrimary) { - s->addEvent720(144, T_PRIMARY, TV_RISE); - s->addEvent720(180, T_PRIMARY, TV_FALL); + s->addEvent720(144, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(180, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(216, T_PRIMARY, TV_RISE); - s->addEvent720(252, T_PRIMARY, TV_FALL); + s->addEvent720(216, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(252, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(288, T_PRIMARY, TV_RISE); - s->addEvent720(324, T_PRIMARY, TV_FALL); + s->addEvent720(288, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(324, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(360, T_PRIMARY, TV_RISE); // width = 144 - s->addEvent720(504, T_PRIMARY, TV_FALL); // width = 36 - s->addEvent720(540, T_PRIMARY, TV_RISE); - s->addEvent720(576, T_PRIMARY, TV_FALL); - s->addEvent720(612, T_PRIMARY, TV_RISE); - s->addEvent720(648, T_PRIMARY, TV_FALL); - s->addEvent720(684, T_PRIMARY, TV_RISE); - s->addEvent720(720, T_PRIMARY, TV_FALL); + s->addEvent720(360, T_PRIMARY, TriggerValue::RISE); // width = 144 + s->addEvent720(504, T_PRIMARY, TriggerValue::FALL); // width = 36 + s->addEvent720(540, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(576, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(612, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(648, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(684, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(720, T_PRIMARY, TriggerValue::FALL); } else { /** @@ -154,171 +154,171 @@ gap=1.43/0.71 * */ - s->addEvent720(25, T_SECONDARY, TV_FALL); - s->addEvent720(30, T_SECONDARY, TV_RISE); - s->addEvent720(35, T_SECONDARY, TV_FALL); - s->addEvent720(40, T_SECONDARY, TV_RISE); - s->addEvent720(45, T_SECONDARY, TV_FALL); - s->addEvent720(50, T_SECONDARY, TV_RISE); - s->addEvent720(55, T_SECONDARY, TV_FALL); - s->addEvent720(60, T_SECONDARY, TV_RISE); - s->addEvent720(65, T_SECONDARY, TV_FALL); - s->addEvent720(70, T_SECONDARY, TV_RISE); - s->addEvent720(75, T_SECONDARY, TV_FALL); - s->addEvent720(80, T_SECONDARY, TV_RISE); - s->addEvent720(85, T_SECONDARY, TV_FALL); - s->addEvent720(90, T_SECONDARY, TV_RISE); - s->addEvent720(95, T_SECONDARY, TV_FALL); - s->addEvent720(100, T_SECONDARY, TV_RISE); - s->addEvent720(105, T_SECONDARY, TV_FALL); - s->addEvent720(110, T_SECONDARY, TV_RISE); - s->addEvent720(115, T_SECONDARY, TV_FALL); - s->addEvent720(120, T_SECONDARY, TV_RISE); - s->addEvent720(125, T_SECONDARY, TV_FALL); - s->addEvent720(130, T_SECONDARY, TV_RISE); - s->addEvent720(135, T_SECONDARY, TV_FALL); - s->addEvent720(140, T_SECONDARY, TV_RISE); + s->addEvent720(25, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(30, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(35, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(40, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(45, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(50, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(55, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(60, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(65, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(70, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(75, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(80, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(85, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(90, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(95, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(100, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(105, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(110, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(115, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(120, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(125, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(130, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(135, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(140, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(144, T_PRIMARY, TV_RISE); + s->addEvent720(144, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(145,T_SECONDARY, TV_FALL); - s->addEvent720(150, T_SECONDARY, TV_RISE); - s->addEvent720(155, T_SECONDARY, TV_FALL); - s->addEvent720(160, T_SECONDARY, TV_RISE); - s->addEvent720(165, T_SECONDARY, TV_FALL); - s->addEvent720(170, T_SECONDARY, TV_RISE); - s->addEvent720(175, T_SECONDARY, TV_FALL); - s->addEvent720(180 - EPS_ANGLE, T_SECONDARY, TV_RISE); + s->addEvent720(145,T_SECONDARY, TriggerValue::FALL); + s->addEvent720(150, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(155, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(160, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(165, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(170, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(175, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(180 - EPS_ANGLE, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(180, T_PRIMARY, TV_FALL); + s->addEvent720(180, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(185, T_SECONDARY, TV_FALL); - s->addEvent720(210, T_SECONDARY, TV_RISE); - s->addEvent720(215, T_SECONDARY, TV_FALL); + s->addEvent720(185, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(210, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(215, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(216, T_PRIMARY, TV_RISE); + s->addEvent720(216, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(220, T_SECONDARY, TV_RISE); - s->addEvent720(225, T_SECONDARY, TV_FALL); - s->addEvent720(230, T_SECONDARY, TV_RISE); - s->addEvent720(235, T_SECONDARY, TV_FALL); - s->addEvent720(240, T_SECONDARY, TV_RISE); - s->addEvent720(245, T_SECONDARY, TV_FALL); - s->addEvent720(250, T_SECONDARY, TV_RISE); + s->addEvent720(220, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(225, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(230, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(235, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(240, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(245, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(250, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(252, T_PRIMARY, TV_FALL); + s->addEvent720(252, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(255, T_SECONDARY, TV_FALL); + s->addEvent720(255, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(260, T_SECONDARY, TV_RISE); - s->addEvent720(265, T_SECONDARY, TV_FALL); - s->addEvent720(270, T_SECONDARY, TV_RISE); - s->addEvent720(275, T_SECONDARY, TV_FALL); - s->addEvent720(280, T_SECONDARY, TV_RISE); - s->addEvent720(285, T_SECONDARY, TV_FALL); + s->addEvent720(260, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(265, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(270, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(275, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(280, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(285, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(288, T_PRIMARY, TV_RISE); + s->addEvent720(288, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(290, T_SECONDARY, TV_RISE); - s->addEvent720(295, T_SECONDARY, TV_FALL); - s->addEvent720(300, T_SECONDARY, TV_RISE); - s->addEvent720(305, T_SECONDARY, TV_FALL); - s->addEvent720(310, T_SECONDARY, TV_RISE); - s->addEvent720(315, T_SECONDARY, TV_FALL); - s->addEvent720(320, T_SECONDARY, TV_RISE); + s->addEvent720(290, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(295, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(300, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(305, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(310, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(315, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(320, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(324, T_PRIMARY, TV_FALL); + s->addEvent720(324, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(325, T_SECONDARY, TV_FALL); - s->addEvent720(330, T_SECONDARY, TV_RISE); - s->addEvent720(335, T_SECONDARY, TV_FALL); - s->addEvent720(340, T_SECONDARY, TV_RISE); - s->addEvent720(345, T_SECONDARY, TV_FALL); - s->addEvent720(350, T_SECONDARY, TV_RISE); - s->addEvent720(355, T_SECONDARY, TV_FALL); - s->addEvent720(360 - EPS_ANGLE, T_SECONDARY, TV_RISE); + s->addEvent720(325, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(330, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(335, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(340, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(345, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(350, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(355, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(360 - EPS_ANGLE, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(360, T_PRIMARY, TV_RISE); + s->addEvent720(360, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(385, T_SECONDARY, TV_FALL); - s->addEvent720(390, T_SECONDARY, TV_RISE); - s->addEvent720(395, T_SECONDARY, TV_FALL); - s->addEvent720(400, T_SECONDARY, TV_RISE); - s->addEvent720(405, T_SECONDARY, TV_FALL); - s->addEvent720(410, T_SECONDARY, TV_RISE); - s->addEvent720(415, T_SECONDARY, TV_FALL); - s->addEvent720(420, T_SECONDARY, TV_RISE); - s->addEvent720(425, T_SECONDARY, TV_FALL); - s->addEvent720(430, T_SECONDARY, TV_RISE); - s->addEvent720(435, T_SECONDARY, TV_FALL); - s->addEvent720(440, T_SECONDARY, TV_RISE); - s->addEvent720(445, T_SECONDARY, TV_FALL); - s->addEvent720(450, T_SECONDARY, TV_RISE); - s->addEvent720(455, T_SECONDARY, TV_FALL); - s->addEvent720(460, T_SECONDARY, TV_RISE); - s->addEvent720(465, T_SECONDARY, TV_FALL); - s->addEvent720(470, T_SECONDARY, TV_RISE); - s->addEvent720(475, T_SECONDARY, TV_FALL); - s->addEvent720(480, T_SECONDARY, TV_RISE); - s->addEvent720(485, T_SECONDARY, TV_FALL); - s->addEvent720(490, T_SECONDARY, TV_RISE); - s->addEvent720(495, T_SECONDARY, TV_FALL); - s->addEvent720(500, T_SECONDARY, TV_RISE); + s->addEvent720(385, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(390, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(395, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(400, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(405, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(410, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(415, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(420, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(425, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(430, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(435, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(440, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(445, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(450, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(455, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(460, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(465, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(470, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(475, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(480, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(485, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(490, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(495, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(500, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(504, T_PRIMARY, TV_FALL); + s->addEvent720(504, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(505, T_SECONDARY, TV_FALL); - s->addEvent720(510, T_SECONDARY, TV_RISE); - s->addEvent720(515, T_SECONDARY, TV_FALL); - s->addEvent720(520, T_SECONDARY, TV_RISE); - s->addEvent720(525, T_SECONDARY, TV_FALL); - s->addEvent720(530, T_SECONDARY, TV_RISE); - s->addEvent720(535, T_SECONDARY, TV_FALL); - s->addEvent720(540 - EPS_ANGLE, T_SECONDARY, TV_RISE); + s->addEvent720(505, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(510, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(515, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(520, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(525, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(530, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(535, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(540 - EPS_ANGLE, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(540, T_PRIMARY, TV_RISE); + s->addEvent720(540, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(545, T_SECONDARY, TV_FALL); - s->addEvent720(570, T_SECONDARY, TV_RISE); - s->addEvent720(575, T_SECONDARY, TV_FALL); + s->addEvent720(545, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(570, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(575, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(576, T_PRIMARY, TV_FALL); - s->addEvent720(580, T_SECONDARY, TV_RISE); - s->addEvent720(585, T_SECONDARY, TV_FALL); - s->addEvent720(590, T_SECONDARY, TV_RISE); - s->addEvent720(595, T_SECONDARY, TV_FALL); - s->addEvent720(600, T_SECONDARY, TV_RISE); - s->addEvent720(605, T_SECONDARY, TV_FALL); - s->addEvent720(610, T_SECONDARY, TV_RISE); + s->addEvent720(576, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(580, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(585, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(590, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(595, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(600, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(605, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(610, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(612, T_PRIMARY, TV_RISE); - s->addEvent720(615, T_SECONDARY, TV_FALL); - s->addEvent720(620, T_SECONDARY, TV_RISE); - s->addEvent720(625, T_SECONDARY, TV_FALL); - s->addEvent720(630, T_SECONDARY, TV_RISE); - s->addEvent720(635, T_SECONDARY, TV_FALL); - s->addEvent720(640, T_SECONDARY, TV_RISE); - s->addEvent720(645, T_SECONDARY, TV_FALL); + s->addEvent720(612, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(615, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(620, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(625, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(630, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(635, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(640, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(645, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(648, T_PRIMARY, TV_FALL); - s->addEvent720(650, T_SECONDARY, TV_RISE); - s->addEvent720(655, T_SECONDARY, TV_FALL); - s->addEvent720(660, T_SECONDARY, TV_RISE); - s->addEvent720(665, T_SECONDARY, TV_FALL); - s->addEvent720(670, T_SECONDARY, TV_RISE); - s->addEvent720(675, T_SECONDARY, TV_FALL); - s->addEvent720(680, T_SECONDARY, TV_RISE); + s->addEvent720(648, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(650, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(655, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(660, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(665, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(670, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(675, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(680, T_SECONDARY, TriggerValue::RISE); - s->addEvent720(684, T_PRIMARY, TV_RISE); - s->addEvent720(685, T_SECONDARY, TV_FALL); - s->addEvent720(690, T_SECONDARY, TV_RISE); - s->addEvent720(695, T_SECONDARY, TV_FALL); - s->addEvent720(700, T_SECONDARY, TV_RISE); - s->addEvent720(705, T_SECONDARY, TV_FALL); - s->addEvent720(710, T_SECONDARY, TV_RISE); - s->addEvent720(715, T_SECONDARY, TV_FALL); - s->addEvent720(720 - EPS_ANGLE, T_SECONDARY, TV_RISE); - s->addEvent720(720, T_PRIMARY, TV_FALL); + s->addEvent720(684, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(685, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(690, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(695, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(700, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(705, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(710, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(715, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(720 - EPS_ANGLE, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(720, T_PRIMARY, TriggerValue::FALL); } } @@ -334,56 +334,56 @@ void configureDodgeStratusTriggerWaveform(TriggerWaveform *s) { float base = 0; // 2 teeth float angle = base + 120.0 - w; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); angle += g; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); base += 120; // 3 teeth angle = base + 120.0 - w; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); angle += g; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); angle += g; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); base += 120; // 2 teeth angle = base + 120.0 - w; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); angle += g; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); base += 120; // just one angle = base + 120.0 - w; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); base += 120; // 3 teeth angle = base + 120.0 - w; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); angle += g; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); angle += g; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); base += 120; // just one again angle = base + 120.0 - w; - s->addEvent720(angle, T_PRIMARY, TV_RISE); - s->addEvent720(angle + w, T_PRIMARY, TV_FALL); + s->addEvent720(angle, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(angle + w, T_PRIMARY, TriggerValue::FALL); } static void configureNeon1995TriggerWaveformCommon(bool withCam, TriggerWaveform *s) { @@ -394,54 +394,54 @@ static void configureNeon1995TriggerWaveformCommon(bool withCam, TriggerWaveform float m = withCam ? 1 : 2; - s->addEvent720(m * (base - 120), crank, TV_RISE); - s->addEvent720(m * (base - 116), crank, TV_FALL); - s->addEvent720(m * (base - 720 + 616), crank, TV_RISE); - s->addEvent720(m * (base - 100), crank, TV_FALL); - s->addEvent720(m * (base - 720 + 643), crank, TV_RISE); - s->addEvent720(m * (base - 720 + 648), crank, TV_FALL); - s->addEvent720(m * (base - 720 + 671), crank, TV_RISE); - s->addEvent720(m * (base - 44), crank, TV_FALL); + s->addEvent720(m * (base - 120), crank, TriggerValue::RISE); + s->addEvent720(m * (base - 116), crank, TriggerValue::FALL); + s->addEvent720(m * (base - 720 + 616), crank, TriggerValue::RISE); + s->addEvent720(m * (base - 100), crank, TriggerValue::FALL); + s->addEvent720(m * (base - 720 + 643), crank, TriggerValue::RISE); + s->addEvent720(m * (base - 720 + 648), crank, TriggerValue::FALL); + s->addEvent720(m * (base - 720 + 671), crank, TriggerValue::RISE); + s->addEvent720(m * (base - 44), crank, TriggerValue::FALL); if (withCam) { - s->addEvent720(base + 0, T_PRIMARY, TV_FALL); + s->addEvent720(base + 0, T_PRIMARY, TriggerValue::FALL); } - s->addEvent720(m * (base + 20), crank, TV_RISE); - s->addEvent720(m * (base + 60), crank, TV_FALL); - s->addEvent720(m * (base + 75), crank, TV_RISE); - s->addEvent720(m * (base + 79), crank, TV_FALL); - s->addEvent720(m * (base + 101), crank, TV_RISE); - s->addEvent720(m * (base + 106), crank, TV_FALL); - s->addEvent720(m * (base + 130), crank, TV_RISE); - s->addEvent720(m * (base + 135), crank, TV_FALL); + s->addEvent720(m * (base + 20), crank, TriggerValue::RISE); + s->addEvent720(m * (base + 60), crank, TriggerValue::FALL); + s->addEvent720(m * (base + 75), crank, TriggerValue::RISE); + s->addEvent720(m * (base + 79), crank, TriggerValue::FALL); + s->addEvent720(m * (base + 101), crank, TriggerValue::RISE); + s->addEvent720(m * (base + 106), crank, TriggerValue::FALL); + s->addEvent720(m * (base + 130), crank, TriggerValue::RISE); + s->addEvent720(m * (base + 135), crank, TriggerValue::FALL); if (withCam) { - s->addEvent720(base + 200, T_PRIMARY, TV_RISE); // width = 150 + s->addEvent720(base + 200, T_PRIMARY, TriggerValue::RISE); // width = 150 - s->addEvent720(base + 236, crank, TV_RISE); - s->addEvent720(base + 239, crank, TV_FALL); - s->addEvent720(base + 250, crank, TV_RISE); - s->addEvent720(base + 255, crank, TV_FALL); - s->addEvent720(base + 277, crank, TV_RISE); - s->addEvent720(base + 282, crank, TV_FALL); - s->addEvent720(base + 305, crank, TV_RISE); - s->addEvent720(base + 310, crank, TV_FALL); + s->addEvent720(base + 236, crank, TriggerValue::RISE); + s->addEvent720(base + 239, crank, TriggerValue::FALL); + s->addEvent720(base + 250, crank, TriggerValue::RISE); + s->addEvent720(base + 255, crank, TriggerValue::FALL); + s->addEvent720(base + 277, crank, TriggerValue::RISE); + s->addEvent720(base + 282, crank, TriggerValue::FALL); + s->addEvent720(base + 305, crank, TriggerValue::RISE); + s->addEvent720(base + 310, crank, TriggerValue::FALL); - s->addEvent720(base + 374, crank, TV_RISE); + s->addEvent720(base + 374, crank, TriggerValue::RISE); // if (withCam) - s->addEvent720(base + 395, T_PRIMARY, TV_FALL); // width = + s->addEvent720(base + 395, T_PRIMARY, TriggerValue::FALL); // width = - s->addEvent720(base + 418, crank, TV_FALL); - s->addEvent720(base + 436, crank, TV_RISE); - s->addEvent720(base + 441, crank, TV_FALL); - s->addEvent720(base + 463, crank, TV_RISE); - s->addEvent720(base + 468, crank, TV_FALL); - s->addEvent720(base + 492, crank, TV_RISE); - s->addEvent720(base + 497, crank, TV_FALL); + s->addEvent720(base + 418, crank, TriggerValue::FALL); + s->addEvent720(base + 436, crank, TriggerValue::RISE); + s->addEvent720(base + 441, crank, TriggerValue::FALL); + s->addEvent720(base + 463, crank, TriggerValue::RISE); + s->addEvent720(base + 468, crank, TriggerValue::FALL); + s->addEvent720(base + 492, crank, TriggerValue::RISE); + s->addEvent720(base + 497, crank, TriggerValue::FALL); // if (withCam) - s->addEvent720(base + 560, T_PRIMARY, TV_RISE); // width = + s->addEvent720(base + 560, T_PRIMARY, TriggerValue::RISE); // width = } } @@ -464,7 +464,7 @@ void configureNeon1995TriggerWaveform(TriggerWaveform *s) { s->useRiseEdge = false; - s->initialState[T_PRIMARY] = TV_RISE; + s->initialState[T_PRIMARY] = TriggerValue::RISE; configureNeon1995TriggerWaveformCommon(true, s); @@ -478,79 +478,79 @@ void initJeep18_2_2_2(TriggerWaveform *s) { float off = 212; - s->addEvent720(534 - 720 + off, T_SECONDARY, TV_RISE); - s->addEvent720(536 - 720 + off, T_SECONDARY, TV_FALL); - s->addEvent720(554 - 720 + off, T_SECONDARY, TV_RISE); - s->addEvent720(556 - 720 + off, T_SECONDARY, TV_FALL); - s->addEvent720(574 - 720 + off, T_SECONDARY, TV_RISE); - s->addEvent720(576 - 720 + off, T_SECONDARY, TV_FALL); - s->addEvent720(594 - 720 + off, T_SECONDARY, TV_RISE); - s->addEvent720(596 - 720 + off, T_SECONDARY, TV_FALL); + s->addEvent720(534 - 720 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(536 - 720 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(554 - 720 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(556 - 720 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(574 - 720 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(576 - 720 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(594 - 720 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(596 - 720 + off, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(654 - 720 + off, T_SECONDARY, TV_RISE); - s->addEvent720(656 - 720 + off, T_SECONDARY, TV_FALL); - s->addEvent720(674 - 720 + off, T_SECONDARY, TV_RISE); - s->addEvent720(676 - 720 + off, T_SECONDARY, TV_FALL); - s->addEvent720(694 - 720 + off, T_SECONDARY, TV_RISE); - s->addEvent720(696 - 720 + off, T_SECONDARY, TV_FALL); - s->addEvent720(714 - 720 + off, T_SECONDARY, TV_RISE); - s->addEvent720(716 - 720 + off, T_SECONDARY, TV_FALL); + s->addEvent720(654 - 720 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(656 - 720 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(674 - 720 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(676 - 720 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(694 - 720 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(696 - 720 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(714 - 720 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(716 - 720 + off, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(54 + off, T_SECONDARY, TV_RISE); - s->addEvent720(56 + off, T_SECONDARY, TV_FALL); - s->addEvent720(74 + off, T_SECONDARY, TV_RISE); - s->addEvent720(76 + off, T_SECONDARY, TV_FALL); - s->addEvent720(94 + off, T_SECONDARY, TV_RISE); - s->addEvent720(96 + off, T_SECONDARY, TV_FALL); - s->addEvent720(114 + off, T_SECONDARY, TV_RISE); - s->addEvent720(116 + off, T_SECONDARY, TV_FALL); + s->addEvent720(54 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(56 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(74 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(76 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(94 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(96 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(114 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(116 + off, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(148 + off, T_PRIMARY, TV_RISE); // 360 + s->addEvent720(148 + off, T_PRIMARY, TriggerValue::RISE); // 360 - s->addEvent720(174 + off, T_SECONDARY, TV_RISE); - s->addEvent720(176 + off, T_SECONDARY, TV_FALL); - s->addEvent720(194 + off, T_SECONDARY, TV_RISE); - s->addEvent720(196 + off, T_SECONDARY, TV_FALL); - s->addEvent720(214 + off, T_SECONDARY, TV_RISE); - s->addEvent720(216 + off, T_SECONDARY, TV_FALL); - s->addEvent720(234 + off, T_SECONDARY, TV_RISE); - s->addEvent720(236 + off, T_SECONDARY, TV_FALL); + s->addEvent720(174 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(176 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(194 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(196 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(214 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(216 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(234 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(236 + off, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(294 + off, T_SECONDARY, TV_RISE); - s->addEvent720(296 + off, T_SECONDARY, TV_FALL); - s->addEvent720(314 + off, T_SECONDARY, TV_RISE); - s->addEvent720(316 + off, T_SECONDARY, TV_FALL); - s->addEvent720(334 + off, T_SECONDARY, TV_RISE); - s->addEvent720(336 + off, T_SECONDARY, TV_FALL); - s->addEvent720(354 + off, T_SECONDARY, TV_RISE); - s->addEvent720(356 + off, T_SECONDARY, TV_FALL); + s->addEvent720(294 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(296 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(314 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(316 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(334 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(336 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(354 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(356 + off, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(414 + off, T_SECONDARY, TV_RISE); - s->addEvent720(416 + off, T_SECONDARY, TV_FALL); - s->addEvent720(434 + off, T_SECONDARY, TV_RISE); - s->addEvent720(436 + off, T_SECONDARY, TV_FALL); - s->addEvent720(454 + off, T_SECONDARY, TV_RISE); - s->addEvent720(456 + off, T_SECONDARY, TV_FALL); - s->addEvent720(474 + off, T_SECONDARY, TV_RISE); - s->addEvent720(476 + off, T_SECONDARY, TV_FALL); + s->addEvent720(414 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(416 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(434 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(436 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(454 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(456 + off, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(474 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(476 + off, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(508 + off, T_PRIMARY, TV_FALL); // 720 + s->addEvent720(508 + off, T_PRIMARY, TriggerValue::FALL); // 720 } static void add4cylblock(int off, TriggerWaveform *s) { - s->addEvent720(114 + off, T_SECONDARY, TV_RISE); - s->addEvent720(114 + off + 2, T_SECONDARY, TV_FALL); + s->addEvent720(114 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(114 + off + 2, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(134 + off, T_SECONDARY, TV_RISE); - s->addEvent720(134 + off + 2, T_SECONDARY, TV_FALL); + s->addEvent720(134 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(134 + off + 2, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(154 + off, T_SECONDARY, TV_RISE); - s->addEvent720(154 + off + 2, T_SECONDARY, TV_FALL); + s->addEvent720(154 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(154 + off + 2, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(174 + off, T_SECONDARY, TV_RISE); - s->addEvent720(174 + off + 2, T_SECONDARY, TV_FALL); + s->addEvent720(174 + off, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(174 + off + 2, T_SECONDARY, TriggerValue::FALL); } // TT_JEEP_4_CYL @@ -564,12 +564,12 @@ void initJeep_XJ_4cyl_2500(TriggerWaveform *s) { add4cylblock(offset - 180, s); add4cylblock(offset, s); - s->addEvent720(236 + offset, T_PRIMARY, TV_RISE); // 360 + s->addEvent720(236 + offset, T_PRIMARY, TriggerValue::RISE); // 360 add4cylblock(offset + 180, s); add4cylblock(offset + 360, s); - s->addEvent720(596 + offset, T_PRIMARY, TV_FALL); // 720 + s->addEvent720(596 + offset, T_PRIMARY, TriggerValue::FALL); // 720 } @@ -588,24 +588,24 @@ void configureChryslerNGC_36_2_2(TriggerWaveform *s) { float base = 0; for (int i = 0; i < 14; i++) { - s->addEventAngle(base + narrow / 2, T_PRIMARY, TV_RISE); - s->addEventAngle(base + narrow, T_PRIMARY, TV_FALL); + s->addEventAngle(base + narrow / 2, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(base + narrow, T_PRIMARY, TriggerValue::FALL); base += narrow; } - s->addEventAngle(base + narrow / 2, T_PRIMARY, TV_RISE); + s->addEventAngle(base + narrow / 2, T_PRIMARY, TriggerValue::RISE); base += narrow / 2; - s->addEventAngle(base + wide, T_PRIMARY, TV_FALL); + s->addEventAngle(base + wide, T_PRIMARY, TriggerValue::FALL); base += wide; for (int i = 0; i < 16; i++) { - s->addEventAngle(base + narrow / 2, T_PRIMARY, TV_RISE); - s->addEventAngle(base + narrow, T_PRIMARY, TV_FALL); + s->addEventAngle(base + narrow / 2, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(base + narrow, T_PRIMARY, TriggerValue::FALL); base += narrow; } // one small tooth at the end of the engine cycle - s->addEventAngle(s->getCycleDuration() - narrow / 2, T_PRIMARY, TV_RISE); - s->addEventAngle(s->getCycleDuration(), T_PRIMARY, TV_FALL); + s->addEventAngle(s->getCycleDuration() - narrow / 2, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(s->getCycleDuration(), T_PRIMARY, TriggerValue::FALL); s->useOnlyPrimaryForSync = true; } diff --git a/firmware/controllers/trigger/decoders/trigger_gm.cpp b/firmware/controllers/trigger/decoders/trigger_gm.cpp index 6eedb9c21b..73a7563667 100644 --- a/firmware/controllers/trigger/decoders/trigger_gm.cpp +++ b/firmware/controllers/trigger/decoders/trigger_gm.cpp @@ -10,9 +10,9 @@ #include "trigger_gm.h" static float addTooth(float offset, TriggerWaveform *s) { - s->addEventAngle(offset, T_SECONDARY, TV_RISE); + s->addEventAngle(offset, T_SECONDARY, TriggerValue::RISE); offset += CRANK_MODE_MULTIPLIER * 3; - s->addEventAngle(offset, T_SECONDARY, TV_FALL); + s->addEventAngle(offset, T_SECONDARY, TriggerValue::FALL); offset += CRANK_MODE_MULTIPLIER * 3; return offset; } @@ -52,11 +52,11 @@ void configureGm60_2_2_2(TriggerWaveform *s) { } - s->addEventAngle(m * (360 - 6), T_PRIMARY, TV_RISE); + s->addEventAngle(m * (360 - 6), T_PRIMARY, TriggerValue::RISE); offset = addTooth(offset, s); - s->addEventAngle(m * (360), T_PRIMARY, TV_FALL); + s->addEventAngle(m * (360), T_PRIMARY, TriggerValue::FALL); } @@ -65,26 +65,26 @@ void configureGmTriggerWaveform(TriggerWaveform *s) { float w = 5; - s->addEvent360(60 - w, T_PRIMARY, TV_RISE); - s->addEvent360(60, T_PRIMARY, TV_FALL); + s->addEvent360(60 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(60, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(120 - w, T_PRIMARY, TV_RISE); - s->addEvent360(120.0, T_PRIMARY, TV_FALL); + s->addEvent360(120 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(120.0, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(180 - w, T_PRIMARY, TV_RISE); - s->addEvent360(180, T_PRIMARY, TV_FALL); + s->addEvent360(180 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(180, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(240 - w, T_PRIMARY, TV_RISE); - s->addEvent360(240.0, T_PRIMARY, TV_FALL); + s->addEvent360(240 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(240.0, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(300 - w, T_PRIMARY, TV_RISE); - s->addEvent360(300.0, T_PRIMARY, TV_FALL); + s->addEvent360(300 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(300.0, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(350 - w, T_PRIMARY, TV_RISE); - s->addEvent360(350.0, T_PRIMARY, TV_FALL); + s->addEvent360(350 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(350.0, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(360 - w, T_PRIMARY, TV_RISE); - s->addEvent360(360.0, T_PRIMARY, TV_FALL); + s->addEvent360(360 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(360.0, T_PRIMARY, TriggerValue::FALL); s->setTriggerSynchronizationGap(6); } @@ -94,8 +94,8 @@ static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, int window = (isShortLong ? shortToothWidth : (15 - shortToothWidth)) * mult; int end = startAngle + mult * 15; - s->addEvent720(startAngle + window, T_PRIMARY, TV_RISE); - s->addEvent720(end, T_PRIMARY, TV_FALL); + s->addEvent720(startAngle + window, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(end, T_PRIMARY, TriggerValue::FALL); return end; } diff --git a/firmware/controllers/trigger/decoders/trigger_honda.cpp b/firmware/controllers/trigger/decoders/trigger_honda.cpp index 8c247227ed..01bbf4d748 100644 --- a/firmware/controllers/trigger/decoders/trigger_honda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_honda.cpp @@ -22,20 +22,20 @@ void configureHondaCbr600(TriggerWaveform *s) { addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 0, 720, 0, 349); - s->addEvent720(350.0f, T_PRIMARY, TV_FALL); - s->addEvent720(360.0f, T_PRIMARY, TV_RISE); + s->addEvent720(350.0f, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(360.0f, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(360 + 0.2, T_SECONDARY, TV_FALL); + s->addEvent720(360 + 0.2, T_SECONDARY, TriggerValue::FALL); addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 0, 720, 361, 649); - s->addEvent720(650.0f, T_PRIMARY, TV_FALL); - s->addEvent720(660.0f, T_PRIMARY, TV_RISE); + s->addEvent720(650.0f, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(660.0f, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(660 + 0.2, T_SECONDARY, TV_FALL); + s->addEvent720(660 + 0.2, T_SECONDARY, TriggerValue::FALL); addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0.5, 0, 720, @@ -44,11 +44,11 @@ void configureHondaCbr600(TriggerWaveform *s) { // exit(-1); - s->addEvent720(710.0f, T_PRIMARY, TV_FALL); + s->addEvent720(710.0f, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(720.0f - 1, T_SECONDARY, TV_FALL); + s->addEvent720(720.0f - 1, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(720.0f, T_PRIMARY, TV_RISE); + s->addEvent720(720.0f, T_PRIMARY, TriggerValue::RISE); } void configureOnePlus16(TriggerWaveform *s) { @@ -58,12 +58,12 @@ void configureOnePlus16(TriggerWaveform *s) { float tooth = s->getCycleDuration() / count; float width = tooth / 2; // for VR we only handle rises so width does not matter much - s->addEventAngle(1, T_PRIMARY, TV_RISE); - s->addEventAngle(5, T_PRIMARY, TV_FALL); + s->addEventAngle(1, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(5, T_PRIMARY, TriggerValue::FALL); for (int i = 1; i <= count; i++) { - s->addEventAngle(tooth * i - width, T_SECONDARY, TV_RISE); - s->addEventAngle(tooth * i, T_SECONDARY, TV_FALL); + s->addEventAngle(tooth * i - width, T_SECONDARY, TriggerValue::RISE); + s->addEventAngle(tooth * i, T_SECONDARY, TriggerValue::FALL); } s->isSynchronizationNeeded = false; @@ -71,8 +71,8 @@ void configureOnePlus16(TriggerWaveform *s) { static void kseriesTooth(TriggerWaveform* s, float end) { // for VR we only handle rises so width does not matter much - s->addEvent360(end - 4, T_PRIMARY, TV_RISE); - s->addEvent360(end , T_PRIMARY, TV_FALL); + s->addEvent360(end - 4, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(end , T_PRIMARY, TriggerValue::FALL); } // TT_HONDA_K_12_1 @@ -107,18 +107,18 @@ void configureHondaK_4_1(TriggerWaveform *s) { angle_t start = 55.5; angle_t end = 70.5; - s->addEvent360(start + 90 * 0, T_PRIMARY, TV_RISE); - s->addEvent360(end + 90 * 0, T_PRIMARY, TV_FALL); + s->addEvent360(start + 90 * 0, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(end + 90 * 0, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(start + 90 * 1, T_PRIMARY, TV_RISE); - s->addEvent360(end + 90 * 1, T_PRIMARY, TV_FALL); + s->addEvent360(start + 90 * 1, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(end + 90 * 1, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(start + 90 * 2, T_PRIMARY, TV_RISE); - s->addEvent360(end + 90 * 2, T_PRIMARY, TV_FALL); + s->addEvent360(start + 90 * 2, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(end + 90 * 2, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(start + 90 * 3, T_PRIMARY, TV_RISE); - s->addEvent360(end + 90 * 3, T_PRIMARY, TV_FALL); + s->addEvent360(start + 90 * 3, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(end + 90 * 3, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(353, T_PRIMARY, TV_RISE); - s->addEvent360(360, T_PRIMARY, TV_FALL); + s->addEvent360(353, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(360, T_PRIMARY, TriggerValue::FALL); } diff --git a/firmware/controllers/trigger/decoders/trigger_mazda.cpp b/firmware/controllers/trigger/decoders/trigger_mazda.cpp index 5ad1aae692..09c03eb348 100644 --- a/firmware/controllers/trigger/decoders/trigger_mazda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mazda.cpp @@ -43,21 +43,21 @@ void initializeMazdaMiataNaShape(TriggerWaveform *s) { /** * http://rusefi.com/forum/viewtopic.php?f=3&t=729&p=12983#p12983 */ - s->addEvent720(52.960405, T_SECONDARY, TV_RISE); - s->addEvent720(122.635956, T_SECONDARY, TV_FALL); + s->addEvent720(52.960405, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(122.635956, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(216.897031, T_PRIMARY, TV_RISE); - s->addEvent720(232.640068, T_SECONDARY, TV_RISE); - s->addEvent720(288.819688, T_PRIMARY, TV_FALL); // <-- This edge is the sync point - s->addEvent720(302.646323, T_SECONDARY, TV_FALL); + s->addEvent720(216.897031, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(232.640068, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(288.819688, T_PRIMARY, TriggerValue::FALL); // <-- This edge is the sync point + s->addEvent720(302.646323, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(412.448056, T_SECONDARY, TV_RISE); - s->addEvent720(482.816719, T_SECONDARY, TV_FALL); + s->addEvent720(412.448056, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(482.816719, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(577.035495, T_PRIMARY, TV_RISE); - s->addEvent720(592.878113, T_SECONDARY, TV_RISE); - s->addEvent720(662.899708, T_SECONDARY, TV_FALL); - s->addEvent720(720.0f, T_PRIMARY, TV_FALL); + s->addEvent720(577.035495, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(592.878113, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(662.899708, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(720.0f, T_PRIMARY, TriggerValue::FALL); s->useOnlyPrimaryForSync = true; } @@ -77,15 +77,15 @@ void initializeMazdaMiataNb2Crank(TriggerWaveform *s) { s->setSecondTriggerSynchronizationGap2(0.8f, 1.8f); // todo: NB2 fronts are inverted comparing to NB1, life is not perfect :( - s->addEventAngle(180.0f - NB_CRANK_MAGIC - 4, T_PRIMARY, TV_FALL); - s->addEventAngle(180.0f - NB_CRANK_MAGIC, T_PRIMARY, TV_RISE); - s->addEventAngle(180.0f - 4, T_PRIMARY, TV_FALL); - s->addEventAngle(180.0f, T_PRIMARY, TV_RISE); + s->addEventAngle(180.0f - NB_CRANK_MAGIC - 4, T_PRIMARY, TriggerValue::FALL); + s->addEventAngle(180.0f - NB_CRANK_MAGIC, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(180.0f - 4, T_PRIMARY, TriggerValue::FALL); + s->addEventAngle(180.0f, T_PRIMARY, TriggerValue::RISE); } static void addNBCrankTooth(TriggerWaveform *s, angle_t angle, trigger_wheel_e const channelIndex) { - s->addEvent720(angle, channelIndex, TV_RISE); - s->addEvent720(angle + 4, channelIndex, TV_FALL); + s->addEvent720(angle, channelIndex, TriggerValue::RISE); + s->addEvent720(angle + 4, channelIndex, TriggerValue::FALL); } static void initializeMazdaMiataNb1ShapeWithOffset(TriggerWaveform *s, float offset) { @@ -100,25 +100,25 @@ static void initializeMazdaMiataNb1ShapeWithOffset(TriggerWaveform *s, float off /** * cam sensor is primary, crank sensor is secondary */ - s->addEvent720(20.0f, T_PRIMARY, TV_FALL); + s->addEvent720(20.0f, T_PRIMARY, TriggerValue::FALL); addNBCrankTooth(s, offset + 66.0f, T_SECONDARY); addNBCrankTooth(s, offset + 66.0f + NB_CRANK_MAGIC, T_SECONDARY); addNBCrankTooth(s, offset + 66.0f + 180, T_SECONDARY); addNBCrankTooth(s, offset + 66.0f + 180 + NB_CRANK_MAGIC, T_SECONDARY); - s->addEvent720(340.0f, T_PRIMARY, TV_RISE); - s->addEvent720(360.0f, T_PRIMARY, TV_FALL); + s->addEvent720(340.0f, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(360.0f, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(380.0f, T_PRIMARY, TV_RISE); - s->addEvent720(400.0f, T_PRIMARY, TV_FALL); + s->addEvent720(380.0f, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(400.0f, T_PRIMARY, TriggerValue::FALL); addNBCrankTooth(s, offset + 66.0f + 360, T_SECONDARY); addNBCrankTooth(s, offset + 66.0f + 360 + NB_CRANK_MAGIC, T_SECONDARY); addNBCrankTooth(s, offset + 66.0f + 540, T_SECONDARY); addNBCrankTooth(s, offset + 66.0f + 540 + NB_CRANK_MAGIC, T_SECONDARY); - s->addEvent720(720.0f, T_PRIMARY, TV_RISE); + s->addEvent720(720.0f, T_PRIMARY, TriggerValue::RISE); } void initializeMazdaMiataVVtTestShape(TriggerWaveform *s) { @@ -136,18 +136,18 @@ void configureMazdaProtegeSOHC(TriggerWaveform *s) { float z = 0.093; a = 180; - s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE); - s->addEvent720(a, T_PRIMARY, TV_FALL); + s->addEvent720(a - z * 720, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(a, T_PRIMARY, TriggerValue::FALL); a += 180; - s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE); - s->addEvent720(a, T_PRIMARY, TV_FALL); + s->addEvent720(a - z * 720, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(a, T_PRIMARY, TriggerValue::FALL); a += 180; - s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE); - s->addEvent720(a, T_PRIMARY, TV_FALL); + s->addEvent720(a - z * 720, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(a, T_PRIMARY, TriggerValue::FALL); a += 180; - s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE); - s->addEvent720(a, T_PRIMARY, TV_FALL); + s->addEvent720(a - z * 720, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(a, T_PRIMARY, TriggerValue::FALL); s->isSynchronizationNeeded = false; s->shapeWithoutTdc = true; @@ -159,21 +159,21 @@ void configureMazdaProtegeLx(TriggerWaveform *s) { /** * based on https://svn.code.sf.net/p/rusefi/code/trunk/misc/logs/1993_escort_gt/MAIN_rfi_report_2015-02-01%2017_39.csv */ - s->addEvent720(95.329254, T_PRIMARY, TV_RISE); + s->addEvent720(95.329254, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(95.329254 + 14.876692, T_SECONDARY, TV_RISE); - s->addEvent720(95.329254 + 82.693557, T_SECONDARY, TV_FALL); + s->addEvent720(95.329254 + 14.876692, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(95.329254 + 82.693557, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(95.329254 + 137.119154, T_PRIMARY, TV_FALL); + s->addEvent720(95.329254 + 137.119154, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(95.329254 + 192.378308, T_SECONDARY, TV_RISE); - s->addEvent720(95.329254 + 261.556418, T_SECONDARY, TV_FALL); + s->addEvent720(95.329254 + 192.378308, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(95.329254 + 261.556418, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(95.329254 + 373.060597, T_SECONDARY, TV_RISE); - s->addEvent720(95.329254 + 443.503184, T_SECONDARY, TV_FALL); + s->addEvent720(95.329254 + 373.060597, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(95.329254 + 443.503184, T_SECONDARY, TriggerValue::FALL); - s->addEvent720(95.329254 + 555.349776, T_SECONDARY, TV_RISE); - s->addEvent720(720, T_SECONDARY, TV_FALL); + s->addEvent720(95.329254 + 555.349776, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(720, T_SECONDARY, TriggerValue::FALL); s->tdcPosition = 137.119154; s->isSynchronizationNeeded = false; @@ -187,14 +187,14 @@ void initializeMazdaMiataVVtCamShape(TriggerWaveform *s) { // Nominal gap is 0.128 s->setSecondTriggerSynchronizationGap2(0.04f, 0.2f); - s->addEvent720(325, T_PRIMARY, TV_FALL); - s->addEvent720(360, T_PRIMARY, TV_RISE); + s->addEvent720(325, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(360, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(641, T_PRIMARY, TV_FALL); - s->addEvent720(679, T_PRIMARY, TV_RISE); + s->addEvent720(641, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(679, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(700, T_PRIMARY, TV_FALL); - s->addEvent720(720, T_PRIMARY, TV_RISE); + s->addEvent720(700, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(720, T_PRIMARY, TriggerValue::RISE); } // https://rusefi.com/forum/viewtopic.php?f=17&t=2417 @@ -203,26 +203,26 @@ void initializeMazdaSkyactivCam(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR); // wide - s->addEvent360(50, T_PRIMARY, TV_RISE); - s->addEvent360(70, T_PRIMARY, TV_FALL); + s->addEvent360(50, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(70, T_PRIMARY, TriggerValue::FALL); // narrow - s->addEvent360(80, T_PRIMARY, TV_RISE); - s->addEvent360(90, T_PRIMARY, TV_FALL); + s->addEvent360(80, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(90, T_PRIMARY, TriggerValue::FALL); // wide - s->addEvent360(140, T_PRIMARY, TV_RISE); - s->addEvent360(160, T_PRIMARY, TV_FALL); + s->addEvent360(140, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(160, T_PRIMARY, TriggerValue::FALL); // narrow - s->addEvent360(170, T_PRIMARY, TV_RISE); - s->addEvent360(180, T_PRIMARY, TV_FALL); + s->addEvent360(170, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(180, T_PRIMARY, TriggerValue::FALL); // wide - s->addEvent360(250, T_PRIMARY, TV_RISE); - s->addEvent360(270, T_PRIMARY, TV_FALL); + s->addEvent360(250, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(270, T_PRIMARY, TriggerValue::FALL); // wide - s->addEvent360(340, T_PRIMARY, TV_RISE); - s->addEvent360(360, T_PRIMARY, TV_FALL); + s->addEvent360(340, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(360, T_PRIMARY, TriggerValue::FALL); s->setTriggerSynchronizationGap(0.43); s->setSecondTriggerSynchronizationGap(0.78); diff --git a/firmware/controllers/trigger/decoders/trigger_mercedes.cpp b/firmware/controllers/trigger/decoders/trigger_mercedes.cpp index 33fc10e8a7..d8a2f5229f 100644 --- a/firmware/controllers/trigger/decoders/trigger_mercedes.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mercedes.cpp @@ -6,14 +6,14 @@ void setMercedesTwoSegment(TriggerWaveform* s) { s->initialize(FOUR_STROKE_CRANK_SENSOR); - s->addEvent360(180 - 10, T_PRIMARY, TV_RISE); - s->addEvent360(180, T_PRIMARY, TV_FALL); + s->addEvent360(180 - 10, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(180, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(227 - 10, T_PRIMARY, TV_RISE); - s->addEvent360(227, T_PRIMARY, TV_FALL); + s->addEvent360(227 - 10, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(227, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(360 - 10, T_PRIMARY, TV_RISE); - s->addEvent360(360, T_PRIMARY, TV_FALL); + s->addEvent360(360 - 10, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(360, T_PRIMARY, TriggerValue::FALL); s->setTriggerSynchronizationGap(1.35); s->setSecondTriggerSynchronizationGap(2.84); diff --git a/firmware/controllers/trigger/decoders/trigger_misc.cpp b/firmware/controllers/trigger/decoders/trigger_misc.cpp index 248bfd7c41..b1e6c0486e 100644 --- a/firmware/controllers/trigger/decoders/trigger_misc.cpp +++ b/firmware/controllers/trigger/decoders/trigger_misc.cpp @@ -17,11 +17,11 @@ void configureFiatIAQ_P8(TriggerWaveform * s) { int width = 60; s->tdcPosition = width; - s->addEvent720(width, T_PRIMARY, TV_RISE); - s->addEvent720(180, T_PRIMARY, TV_FALL); + s->addEvent720(width, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(180, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(180 + width, T_PRIMARY, TV_RISE); - s->addEvent720(720, T_PRIMARY, TV_FALL); + s->addEvent720(180 + width, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(720, T_PRIMARY, TriggerValue::FALL); s->setTriggerSynchronizationGap(3); } @@ -40,10 +40,10 @@ void configureTriTach(TriggerWaveform * s) { float angleDown = engineCycle / totalTeethCount * (0 + (1 - toothWidth)); float angleUp = engineCycle / totalTeethCount * (0 + 1); - s->addEventClamped(offset + angleDown, T_PRIMARY, TV_RISE, NO_LEFT_FILTER, NO_RIGHT_FILTER); - s->addEventClamped(offset + angleDown + 0.1, T_SECONDARY, TV_RISE, NO_LEFT_FILTER, NO_RIGHT_FILTER); - s->addEventClamped(offset + angleUp, T_PRIMARY, TV_FALL, NO_LEFT_FILTER, NO_RIGHT_FILTER); - s->addEventClamped(offset + angleUp + 0.1, T_SECONDARY, TV_FALL, NO_LEFT_FILTER, NO_RIGHT_FILTER); + s->addEventClamped(offset + angleDown, T_PRIMARY, TriggerValue::RISE, NO_LEFT_FILTER, NO_RIGHT_FILTER); + s->addEventClamped(offset + angleDown + 0.1, T_SECONDARY, TriggerValue::RISE, NO_LEFT_FILTER, NO_RIGHT_FILTER); + s->addEventClamped(offset + angleUp, T_PRIMARY, TriggerValue::FALL, NO_LEFT_FILTER, NO_RIGHT_FILTER); + s->addEventClamped(offset + angleUp + 0.1, T_SECONDARY, TriggerValue::FALL, NO_LEFT_FILTER, NO_RIGHT_FILTER); addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, /* skipped */ 0, toothWidth, offset, engineCycle, @@ -67,13 +67,13 @@ void configureFordPip(TriggerWaveform * s) { */ int oneCylinder = s->getCycleDuration() / 8; - s->addEventAngle(oneCylinder * 0.75, T_PRIMARY, TV_RISE); - s->addEventAngle(oneCylinder, T_PRIMARY, TV_FALL); + s->addEventAngle(oneCylinder * 0.75, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(oneCylinder, T_PRIMARY, TriggerValue::FALL); for (int i = 2;i<=8;i++) { - s->addEventAngle(oneCylinder * (i - 0.5), T_PRIMARY, TV_RISE); - s->addEventAngle(oneCylinder * i, T_PRIMARY, TV_FALL); + s->addEventAngle(oneCylinder * (i - 0.5), T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(oneCylinder * i, T_PRIMARY, TriggerValue::FALL); } } @@ -84,20 +84,20 @@ void configureFordST170(TriggerWaveform * s) { int total = s->getCycleDuration() / 8; - s->addEventAngle(1 * total - width, T_PRIMARY, TV_RISE); - s->addEventAngle(1 * total, T_PRIMARY, TV_FALL); + s->addEventAngle(1 * total - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(1 * total, T_PRIMARY, TriggerValue::FALL); - s->addEventAngle(2 * total - width, T_PRIMARY, TV_RISE); - s->addEventAngle(2 * total, T_PRIMARY, TV_FALL); + s->addEventAngle(2 * total - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(2 * total, T_PRIMARY, TriggerValue::FALL); - s->addEventAngle(4 * total - width, T_PRIMARY, TV_RISE); - s->addEventAngle(4 * total, T_PRIMARY, TV_FALL); + s->addEventAngle(4 * total - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(4 * total, T_PRIMARY, TriggerValue::FALL); - s->addEventAngle(6 * total - width, T_PRIMARY, TV_RISE); - s->addEventAngle(6 * total, T_PRIMARY, TV_FALL); + s->addEventAngle(6 * total - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(6 * total, T_PRIMARY, TriggerValue::FALL); - s->addEventAngle(8 * total - width, T_PRIMARY, TV_RISE); - s->addEventAngle(8 * total, T_PRIMARY, TV_FALL); + s->addEventAngle(8 * total - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(8 * total, T_PRIMARY, TriggerValue::FALL); } void configureDaihatsu4(TriggerWaveform * s) { @@ -107,18 +107,18 @@ void configureDaihatsu4(TriggerWaveform * s) { s->setTriggerSynchronizationGap(0.125); - s->addEventAngle(30 - width, T_PRIMARY, TV_RISE); - s->addEventAngle(30, T_PRIMARY, TV_FALL); + s->addEventAngle(30 - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(30, T_PRIMARY, TriggerValue::FALL); - s->addEventAngle(s->getCycleDuration() / 3 - width, T_PRIMARY, TV_RISE); - s->addEventAngle(s->getCycleDuration() / 3, T_PRIMARY, TV_FALL); + s->addEventAngle(s->getCycleDuration() / 3 - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(s->getCycleDuration() / 3, T_PRIMARY, TriggerValue::FALL); - s->addEventAngle(s->getCycleDuration() / 3 * 2 - width, T_PRIMARY, TV_RISE); - s->addEventAngle(s->getCycleDuration() / 3 * 2, T_PRIMARY, TV_FALL); + s->addEventAngle(s->getCycleDuration() / 3 * 2 - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(s->getCycleDuration() / 3 * 2, T_PRIMARY, TriggerValue::FALL); - s->addEventAngle(s->getCycleDuration() - width, T_PRIMARY, TV_RISE); - s->addEventAngle(s->getCycleDuration(), T_PRIMARY, TV_FALL); + s->addEventAngle(s->getCycleDuration() - width, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(s->getCycleDuration(), T_PRIMARY, TriggerValue::FALL); } @@ -136,23 +136,23 @@ void configureBarra3plus1cam(TriggerWaveform *s) { { int offset = 120; - s->addEventAngle(offset + 2 * 0 - 10, T_PRIMARY, TV_RISE); - s->addEventAngle(offset + 2 * 0 + 0, T_PRIMARY, TV_FALL); + s->addEventAngle(offset + 2 * 0 - 10, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(offset + 2 * 0 + 0, T_PRIMARY, TriggerValue::FALL); // short gap 60 deg - s->addEventAngle(offset + 2 * 60 - 10, T_PRIMARY, TV_RISE); - s->addEventAngle(offset + 2 * 60 + 0, T_PRIMARY, TV_FALL); + s->addEventAngle(offset + 2 * 60 - 10, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(offset + 2 * 60 + 0, T_PRIMARY, TriggerValue::FALL); // long gap 120 deg - s->addEventAngle(offset + 2 * 180 - 10, T_PRIMARY, TV_RISE); - s->addEventAngle(offset + 2 * 180 + 0, T_PRIMARY, TV_FALL); + s->addEventAngle(offset + 2 * 180 - 10, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(offset + 2 * 180 + 0, T_PRIMARY, TriggerValue::FALL); // long gap 120 deg - s->addEventAngle(offset + 2 * 300 - 10, T_PRIMARY, TV_RISE); - s->addEventAngle(offset + 2 * 300 + 0, T_PRIMARY, TV_FALL); + s->addEventAngle(offset + 2 * 300 - 10, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(offset + 2 * 300 + 0, T_PRIMARY, TriggerValue::FALL); // short gap, 60 deg back to zero/720 } diff --git a/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp b/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp index 4f75cf8497..bc5821e2f0 100644 --- a/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp @@ -18,17 +18,17 @@ void configureFordAspireTriggerWaveform(TriggerWaveform * s) { float x = 121.90; float y = 110.86; - s->addEvent720(x + y - 180, T_SECONDARY, TV_RISE); - s->addEvent720(x, T_SECONDARY, TV_FALL); - s->addEvent720(x + y, T_SECONDARY, TV_RISE); - s->addEvent720(x + 180, T_SECONDARY, TV_FALL); - s->addEvent720(360, T_PRIMARY, TV_RISE); + s->addEvent720(x + y - 180, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(x, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(x + y, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(x + 180, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(360, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(x + 180 + y, T_SECONDARY, TV_RISE); - s->addEvent720(x + 360, T_SECONDARY, TV_FALL); - s->addEvent720(x + 360 + y, T_SECONDARY, TV_RISE); - s->addEvent720(x + 540, T_SECONDARY, TV_FALL); - s->addEvent720(720, T_PRIMARY, TV_FALL); + s->addEvent720(x + 180 + y, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(x + 360, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(x + 360 + y, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(x + 540, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(720, T_PRIMARY, TriggerValue::FALL); } /** @@ -40,18 +40,18 @@ void initializeMitsubishi4g18(TriggerWaveform *s) { s->setTriggerSynchronizationGap(1.6666); - s->addEvent720(106.77999999999997, T_PRIMARY, TV_FALL); - s->addEvent720(120.09999999999998, T_SECONDARY, TV_RISE); - s->addEvent720(188.0775, T_SECONDARY, TV_FALL); - s->addEvent720(286.33, T_PRIMARY, TV_RISE); - s->addEvent720(298.875, T_SECONDARY, TV_RISE); - s->addEvent720(354.91999999999996, T_PRIMARY, TV_FALL); - s->addEvent720(366.6825, T_SECONDARY, TV_FALL); - s->addEvent720(476.45, T_SECONDARY, TV_RISE); - s->addEvent720(543.9749999999999, T_SECONDARY, TV_FALL); - s->addEvent720(639.52, T_PRIMARY, TV_RISE); - s->addEvent720(653.15, T_SECONDARY, TV_RISE); - s->addEvent720(720.0, T_SECONDARY, TV_FALL); + s->addEvent720(106.77999999999997, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(120.09999999999998, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(188.0775, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(286.33, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(298.875, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(354.91999999999996, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(366.6825, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(476.45, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(543.9749999999999, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(639.52, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(653.15, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(720.0, T_SECONDARY, TriggerValue::FALL); s->useOnlyPrimaryForSync = true; } @@ -114,17 +114,17 @@ void initializeVvt3A92(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CRANK_SENSOR); int w = 5; - s->addEvent360(120 - w, T_PRIMARY, TV_RISE); - s->addEvent360(120, T_PRIMARY, TV_FALL); + s->addEvent360(120 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(120, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(12 + 120 - w, T_PRIMARY, TV_RISE); - s->addEvent360(12 + 120, T_PRIMARY, TV_FALL); + s->addEvent360(12 + 120 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(12 + 120, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(240 - w, T_PRIMARY, TV_RISE); - s->addEvent360(240, T_PRIMARY, TV_FALL); + s->addEvent360(240 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(240, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(360 - w, T_PRIMARY, TV_RISE); - s->addEvent360(360, T_PRIMARY, TV_FALL); + s->addEvent360(360 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(360, T_PRIMARY, TriggerValue::FALL); s->setTriggerSynchronizationGap(9); s->setSecondTriggerSynchronizationGap(0.11); // redundancy diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.cpp b/firmware/controllers/trigger/decoders/trigger_nissan.cpp index d953315c75..e23f86a1ae 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.cpp +++ b/firmware/controllers/trigger/decoders/trigger_nissan.cpp @@ -26,24 +26,24 @@ void initializeNissanSR20VE_4(TriggerWaveform *s) { float width = 4; - s->addEvent720(1 * 180 - 4 * width, T_PRIMARY, TV_RISE); - s->addEvent720(1 * 180, T_PRIMARY, TV_FALL); + s->addEvent720(1 * 180 - 4 * width, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(1 * 180, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(2 * 180 - width, T_PRIMARY, TV_RISE); - s->addEvent720(2 * 180, T_PRIMARY, TV_FALL); + s->addEvent720(2 * 180 - width, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(2 * 180, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(3 * 180 - width, T_PRIMARY, TV_RISE); - s->addEvent720(3 * 180, T_PRIMARY, TV_FALL); + s->addEvent720(3 * 180 - width, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(3 * 180, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(4 * 180 - width, T_PRIMARY, TV_RISE); - s->addEvent720(4 * 180, T_PRIMARY, TV_FALL); + s->addEvent720(4 * 180 - width, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(4 * 180, T_PRIMARY, TriggerValue::FALL); } static void addPrimaryToothEndingAt(TriggerWaveform *s, float fallAngle) { int vvtWidth = 20; - s->addEventAngle(fallAngle - vvtWidth, T_PRIMARY, TV_RISE); - s->addEventAngle(fallAngle, T_PRIMARY, TV_FALL); + s->addEventAngle(fallAngle - vvtWidth, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(fallAngle, T_PRIMARY, TriggerValue::FALL); } @@ -73,8 +73,8 @@ void makeNissanPattern(TriggerWaveform* s, size_t halfCylinderCount, size_t tota float currentAngle = missing * toothAngle; for (size_t i = 0; i < toothCount; i++) { currentAngle += toothAngle; - s->addEventAngle(currentAngle - 5, T_PRIMARY, TV_RISE); - s->addEventAngle(currentAngle, T_PRIMARY, TV_FALL); + s->addEventAngle(currentAngle - 5, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(currentAngle, T_PRIMARY, TriggerValue::FALL); } } @@ -111,14 +111,14 @@ void initializeNissanQR25crank(TriggerWaveform *s) { float currentAngle = 20; for (int i = 0;i < 16;i++) { currentAngle += 10; - s->addEventAngle(currentAngle - 5, T_PRIMARY, TV_RISE); - s->addEventAngle(currentAngle, T_PRIMARY, TV_FALL); + s->addEventAngle(currentAngle - 5, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(currentAngle, T_PRIMARY, TriggerValue::FALL); } } static void addvq30tooth(TriggerWaveform *s, float angle) { - s->addEvent360(angle - 4, T_PRIMARY, TV_RISE); - s->addEvent360(angle, T_PRIMARY, TV_FALL); + s->addEvent360(angle - 4, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(angle, T_PRIMARY, TriggerValue::FALL); } // yes, this is CAM shaft shape NOT crank shaft shape! diff --git a/firmware/controllers/trigger/decoders/trigger_renix.cpp b/firmware/controllers/trigger/decoders/trigger_renix.cpp index 198ee6c475..1f4849585d 100644 --- a/firmware/controllers/trigger/decoders/trigger_renix.cpp +++ b/firmware/controllers/trigger/decoders/trigger_renix.cpp @@ -19,15 +19,15 @@ static void commonRenix(TriggerWaveform *s) { float currentAngle = 0; for (int i = 0;i < 20;i++) { - s->addEventAngle(currentAngle + tooth / 2, T_PRIMARY, TV_RISE); - s->addEventAngle(currentAngle + tooth, T_PRIMARY, TV_FALL); + s->addEventAngle(currentAngle + tooth / 2, T_PRIMARY, TriggerValue::RISE); + s->addEventAngle(currentAngle + tooth, T_PRIMARY, TriggerValue::FALL); currentAngle += tooth; } - s->addEventAngle(currentAngle + tooth, T_PRIMARY, TV_RISE); + s->addEventAngle(currentAngle + tooth, T_PRIMARY, TriggerValue::RISE); // float math error accumulates at this point so we have to spell out 180 - s->addEventAngle(s->getCycleDuration(), T_PRIMARY, TV_FALL); + s->addEventAngle(s->getCycleDuration(), T_PRIMARY, TriggerValue::FALL); } // TT_RENIX_44_2_2 diff --git a/firmware/controllers/trigger/decoders/trigger_rover.cpp b/firmware/controllers/trigger/decoders/trigger_rover.cpp index b746a2463d..dea26753b1 100644 --- a/firmware/controllers/trigger/decoders/trigger_rover.cpp +++ b/firmware/controllers/trigger/decoders/trigger_rover.cpp @@ -26,32 +26,32 @@ void initializeRoverK(TriggerWaveform *s) { float base = 0; for (int i = 0; i < 2; i++) { - s->addEvent720(base + tooth / 2, T_PRIMARY, TV_RISE); - s->addEvent720(base + tooth, T_PRIMARY, TV_FALL); + s->addEvent720(base + tooth / 2, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(base + tooth, T_PRIMARY, TriggerValue::FALL); base += tooth; } base += tooth; for (int i = 0; i < 2; i++) { - s->addEvent720(base + tooth / 2, T_PRIMARY, TV_RISE); - s->addEvent720(base + tooth, T_PRIMARY, TV_FALL); + s->addEvent720(base + tooth / 2, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(base + tooth, T_PRIMARY, TriggerValue::FALL); base += tooth; } base += tooth; for (int i = 0; i < 14; i++) { - s->addEvent720(base + tooth / 2, T_PRIMARY, TV_RISE); - s->addEvent720(base + tooth, T_PRIMARY, TV_FALL); + s->addEvent720(base + tooth / 2, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(base + tooth, T_PRIMARY, TriggerValue::FALL); base += tooth; } base += tooth; for (int i = 0; i < 3; i++) { - s->addEvent720(base + tooth / 2, T_PRIMARY, TV_RISE); - s->addEvent720(base + tooth, T_PRIMARY, TV_FALL); + s->addEvent720(base + tooth / 2, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(base + tooth, T_PRIMARY, TriggerValue::FALL); base += tooth; } base += tooth; for (int i = 0; i < 11; i++) { - s->addEvent720(base + tooth / 2, T_PRIMARY, TV_RISE); - s->addEvent720(base + tooth, T_PRIMARY, TV_FALL); + s->addEvent720(base + tooth / 2, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(base + tooth, T_PRIMARY, TriggerValue::FALL); base += tooth; } diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index fe4f5dfce8..3c90bc987e 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -168,7 +168,7 @@ angle_t TriggerWaveform::getAngle(int index) const { return cycleStartAngle + positionWithinCycle; } -void TriggerWaveform::addEventClamped(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam, float filterLeft, float filterRight) { +void TriggerWaveform::addEventClamped(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const stateParam, float filterLeft, float filterRight) { if (angle > filterLeft && angle < filterRight) { #if EFI_UNIT_TEST // printf("addEventClamped %f %s\r\n", angle, getTrigger_value_e(stateParam)); @@ -212,7 +212,7 @@ void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrig } // todo: move the following logic from below here - // if (!useOnlyRisingEdgeForTrigger || stateParam == TV_RISE) { + // if (!useOnlyRisingEdgeForTrigger || stateParam == TriggerValue::RISE) { // expectedEventCount[channelIndex]++; // } @@ -221,20 +221,20 @@ void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrig /** * Deprecated! many usages should be replaced by addEvent360 */ -void TriggerWaveform::addEvent720(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state) { +void TriggerWaveform::addEvent720(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const state) { addEvent(angle / FOUR_STROKE_CYCLE_DURATION, channelIndex, state); } -void TriggerWaveform::addEvent360(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state) { +void TriggerWaveform::addEvent360(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const state) { efiAssertVoid(CUSTOM_OMODE_UNDEF, operationMode == FOUR_STROKE_CAM_SENSOR || operationMode == FOUR_STROKE_CRANK_SENSOR, "Not a mode for 360"); addEvent(CRANK_MODE_MULTIPLIER * angle / FOUR_STROKE_CYCLE_DURATION, channelIndex, state); } -void TriggerWaveform::addEventAngle(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state) { +void TriggerWaveform::addEventAngle(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const state) { addEvent(angle / getCycleDuration(), channelIndex, state); } -void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state) { +void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const state) { efiAssertVoid(CUSTOM_OMODE_UNDEF, operationMode != OM_NONE, "operationMode not set"); if (channelIndex == T_SECONDARY) { @@ -257,7 +257,7 @@ void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex // 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 || state == TV_RISE) { + if (!useOnlyRisingEdgeForTriggerTemp || state == TriggerValue::RISE) { expectedEventCount[channelIndex]++; } @@ -284,7 +284,7 @@ void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex wave.setChannelState(i, /* switchIndex */ 0, /* value */ initialState[i]); } - isRiseEvent[0] = TV_RISE == state; + isRiseEvent[0] = TriggerValue::RISE == state; wave.setSwitchTime(0, angle); wave.setChannelState(channelIndex, /* channelIndex */ 0, /* value */ state); return; @@ -311,7 +311,7 @@ void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex wave.setSwitchTime(i + 1, wave.getSwitchTime(i)); } */ - isRiseEvent[index] = TV_RISE == state; + isRiseEvent[index] = TriggerValue::RISE == state; if ((unsigned)index != wave.phaseCount) { firmwareError(ERROR_TRIGGER_DRAMA, "are we ever here?"); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index 9fff385462..4970e0c01e 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -176,7 +176,7 @@ public: * These signals are used for trigger export only */ int triggerSignalIndeces[PWM_PHASE_MAX_COUNT]; - int triggerSignalStates[PWM_PHASE_MAX_COUNT]; + TriggerValue triggerSignalStates[PWM_PHASE_MAX_COUNT]; // see also 'doesTriggerImplyOperationMode' bool knownOperationMode = true; #endif @@ -199,16 +199,16 @@ public: bool useOnlyRisingEdgeForTriggerTemp; /* (0..1] angle range */ - void addEvent(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state); + void addEvent(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const state); /* (0..720] angle range * Deprecated! many usages should be replaced by addEvent360 */ - void addEvent720(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state); + void addEvent720(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const state); /** * this method helps us use real world 360 degrees shape for FOUR_STROKE_CAM_SENSOR and FOUR_STROKE_CRANK_SENSOR */ - void addEvent360(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state); + void addEvent360(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const state); /** * This version of 'addEvent...' family considers the angle duration of operationMode in this trigger @@ -217,12 +217,12 @@ public: * TODO: one day kill all usages with FOUR_STROKE_CAM_SENSOR 720 cycle and add runtime prohibition * TODO: for FOUR_STROKE_CAM_SENSOR addEvent360 is the way to go */ - void addEventAngle(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const state); + void addEventAngle(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const state); /* (0..720] angle range * Deprecated? */ - void addEventClamped(angle_t angle, trigger_wheel_e const channelIndex, trigger_value_e const stateParam, float filterLeft, float filterRight); + void addEventClamped(angle_t angle, trigger_wheel_e const channelIndex, TriggerValue const stateParam, float filterLeft, float filterRight); operation_mode_e getWheelOperationMode() const; void initialize(operation_mode_e operationMode); diff --git a/firmware/controllers/trigger/decoders/trigger_subaru.cpp b/firmware/controllers/trigger/decoders/trigger_subaru.cpp index 68abaa25d9..8935a829b6 100644 --- a/firmware/controllers/trigger/decoders/trigger_subaru.cpp +++ b/firmware/controllers/trigger/decoders/trigger_subaru.cpp @@ -23,26 +23,26 @@ static void initialize_one_of_36_2_2_2(TriggerWaveform *s, int firstCount, int s float base = 0; for (int i = 0; i < firstCount; i++) { - s->addEvent720(base + narrow / 2, T_PRIMARY, TV_FALL); - s->addEvent720(base + narrow, T_PRIMARY, TV_RISE); + s->addEvent720(base + narrow / 2, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(base + narrow, T_PRIMARY, TriggerValue::RISE); base += narrow; } - s->addEvent720(base + wide / 2, T_PRIMARY, TV_FALL); - s->addEvent720(base + wide, T_PRIMARY, TV_RISE); + s->addEvent720(base + wide / 2, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(base + wide, T_PRIMARY, TriggerValue::RISE); base += wide; for (int i = 0; i < secondCount; i++) { - s->addEvent720(base + narrow / 2, T_PRIMARY, TV_FALL); - s->addEvent720(base + narrow, T_PRIMARY, TV_RISE); + s->addEvent720(base + narrow / 2, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(base + narrow, T_PRIMARY, TriggerValue::RISE); base += narrow; } - s->addEvent720(720 - wide - wide / 2, T_PRIMARY, TV_FALL); - s->addEvent720(720 - wide, T_PRIMARY, TV_RISE); + s->addEvent720(720 - wide - wide / 2, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(720 - wide, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(720 - wide / 2, T_PRIMARY, TV_FALL); - s->addEvent720(720, T_PRIMARY, TV_RISE); + s->addEvent720(720 - wide / 2, T_PRIMARY, TriggerValue::FALL); + s->addEvent720(720, T_PRIMARY, TriggerValue::RISE); s->useOnlyPrimaryForSync = true; } @@ -86,22 +86,22 @@ static void initializeSubaru7_6(TriggerWaveform *s, bool withCrankWheel) { /* 97 degrees BTDC, but we have 20 degrees shift: * 180 - 97 - 20 = 63 */ #define SUBARU76_CRANK_PULSE0(cycle) \ - s->addEvent720((180 * (cycle)) + 63 - width, T_SECONDARY, TV_RISE); \ - s->addEvent720((180 * (cycle)) + 63, T_SECONDARY, TV_FALL) + s->addEvent720((180 * (cycle)) + 63 - width, T_SECONDARY, TriggerValue::RISE); \ + s->addEvent720((180 * (cycle)) + 63, T_SECONDARY, TriggerValue::FALL) /* 65 degrees BTDC, but we have 20 degrees shift: * 180 - 65 - 20 = 95 */ #define SUBARU76_CRANK_PULSE1(cycle) \ - s->addEvent720((180 * (cycle)) + 95 - width, T_SECONDARY, TV_RISE); \ - s->addEvent720((180 * (cycle)) + 95, T_SECONDARY, TV_FALL) + s->addEvent720((180 * (cycle)) + 95 - width, T_SECONDARY, TriggerValue::RISE); \ + s->addEvent720((180 * (cycle)) + 95, T_SECONDARY, TriggerValue::FALL) /* 10 degrees BTDC, but we have 20 degrees shift: * 180 - 10 - 20 = 150 */ #define SUBARU76_CRANK_PULSE2(cycle) \ - s->addEvent720((180 * (cycle)) + 150 - width, T_SECONDARY, TV_RISE); \ - s->addEvent720((180 * (cycle)) + 150, T_SECONDARY, TV_FALL) + s->addEvent720((180 * (cycle)) + 150 - width, T_SECONDARY, TriggerValue::RISE); \ + s->addEvent720((180 * (cycle)) + 150, T_SECONDARY, TriggerValue::FALL) #define SUBARU76_CAM_PULSE(cycle, offset) \ - s->addEvent720((180 * (cycle)) + (offset) - width, T_PRIMARY, TV_RISE); \ - s->addEvent720((180 * (cycle)) + (offset), T_PRIMARY, TV_FALL) + s->addEvent720((180 * (cycle)) + (offset) - width, T_PRIMARY, TriggerValue::RISE); \ + s->addEvent720((180 * (cycle)) + (offset), T_PRIMARY, TriggerValue::FALL) /* (TDC#2 + 20) + 15 */ SUBARU76_CAM_PULSE(0, +15); @@ -202,14 +202,14 @@ void initializeSubaru_SVX(TriggerWaveform *s) { #define CRANK_1_RISE(n) (CRANK_1_FALL(n) - width) #define SUBARU_SVX_CRANK1_PULSE(n) \ - s->addEventAngle(20 + (30 * (n)) + offset - width, SVX_CRANK_1, TV_RISE); \ - s->addEventAngle(20 + (30 * (n)) + offset, SVX_CRANK_1, TV_FALL) + s->addEventAngle(20 + (30 * (n)) + offset - width, SVX_CRANK_1, TriggerValue::RISE); \ + s->addEventAngle(20 + (30 * (n)) + offset, SVX_CRANK_1, TriggerValue::FALL) /* cam falling edge offset from preceding Cr #1 falling edge */ float cam_offset = (10.0 + 30.0 + 30.0 + 30.0) - 90.0; #define SUBARU_SVX_CAM_PULSE(n) \ - s->addEvent720(CRANK_1_RISE(n) + cam_offset, SVX_CAM, TV_RISE); \ - s->addEvent720(CRANK_1_FALL(n) + cam_offset, SVX_CAM, TV_FALL) + s->addEvent720(CRANK_1_RISE(n) + cam_offset, SVX_CAM, TriggerValue::RISE); \ + s->addEvent720(CRANK_1_FALL(n) + cam_offset, SVX_CAM, TriggerValue::FALL) #ifdef SVX_CRANK_2 /* Cr #2 signle tooth falling edge is (55 + 1) BTDC @@ -217,8 +217,8 @@ void initializeSubaru_SVX(TriggerWaveform *s) { float crank_2_offset = (10.0 + 30.0 + 30.0) - (55.0 + 1.0); #define SUBARU_SVX_CRANK2_PULSE(n) \ - s->addEvent720(CRANK_1_RISE(n) + crank_2_offset, SVX_CRANK_2, TV_RISE); \ - s->addEvent720(CRANK_1_FALL(n) + crank_2_offset, SVX_CRANK_2, TV_FALL) + s->addEvent720(CRANK_1_RISE(n) + crank_2_offset, SVX_CRANK_2, TriggerValue::RISE); \ + s->addEvent720(CRANK_1_FALL(n) + crank_2_offset, SVX_CRANK_2, TriggerValue::FALL) #else #define SUBARU_SVX_CRANK2_PULSE(n) (void)(n) #endif diff --git a/firmware/controllers/trigger/decoders/trigger_suzuki.cpp b/firmware/controllers/trigger/decoders/trigger_suzuki.cpp index 5d63c9ba48..30cc136223 100644 --- a/firmware/controllers/trigger/decoders/trigger_suzuki.cpp +++ b/firmware/controllers/trigger/decoders/trigger_suzuki.cpp @@ -15,20 +15,20 @@ void initializeSuzukiG13B(TriggerWaveform *s) { float w = 5; float specialTooth = 20; - s->addEvent720(180 - w, T_PRIMARY, TV_RISE); - s->addEvent720(180, T_PRIMARY, TV_FALL); + s->addEvent720(180 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(180, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(2 * specialTooth + 180 - w, T_PRIMARY, TV_RISE); - s->addEvent720(2 * specialTooth + 180, T_PRIMARY, TV_FALL); + s->addEvent720(2 * specialTooth + 180 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(2 * specialTooth + 180, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(360 - w, T_PRIMARY, TV_RISE); - s->addEvent720(360, T_PRIMARY, TV_FALL); + s->addEvent720(360 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(360, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(540 - w, T_PRIMARY, TV_RISE); - s->addEvent720(540, T_PRIMARY, TV_FALL); + s->addEvent720(540 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(540, T_PRIMARY, TriggerValue::FALL); - s->addEvent720(720 - w, T_PRIMARY, TV_RISE); - s->addEvent720(720, T_PRIMARY, TV_FALL); + s->addEvent720(720 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(720, T_PRIMARY, TriggerValue::FALL); s->setTriggerSynchronizationGap(0.22); s->setSecondTriggerSynchronizationGap(1); diff --git a/firmware/controllers/trigger/decoders/trigger_toyota.cpp b/firmware/controllers/trigger/decoders/trigger_toyota.cpp index 7d46a1784c..d23fcc10ed 100644 --- a/firmware/controllers/trigger/decoders/trigger_toyota.cpp +++ b/firmware/controllers/trigger/decoders/trigger_toyota.cpp @@ -23,30 +23,30 @@ void initialize2jzGE1_12(TriggerWaveform *s) { float crankD = 360 / 12 / 2; // 15 float crankAngle = 10; - s->addEventClamped(crankAngle, T_SECONDARY, TV_FALL, -1, 721); // 120 + s->addEventClamped(crankAngle, T_SECONDARY, TriggerValue::FALL, -1, 721); // 120 for (int i = 0; i < 2; i++) { - s->addEventClamped(crankAngle + crankD, T_SECONDARY, TV_RISE, -1, 721); + s->addEventClamped(crankAngle + crankD, T_SECONDARY, TriggerValue::RISE, -1, 721); crankAngle += crankD; - s->addEventClamped(crankAngle + crankD, T_SECONDARY, TV_FALL, -1, 721); // 120 + s->addEventClamped(crankAngle + crankD, T_SECONDARY, TriggerValue::FALL, -1, 721); // 120 crankAngle += crankD; } - s->addEventClamped(75, T_PRIMARY, TV_FALL, -1, 721); + s->addEventClamped(75, T_PRIMARY, TriggerValue::FALL, -1, 721); for (int i = 0; i < 21; i++) { - s->addEventClamped(crankAngle + crankD, T_SECONDARY, TV_RISE, -1, 721); + s->addEventClamped(crankAngle + crankD, T_SECONDARY, TriggerValue::RISE, -1, 721); crankAngle += crankD; - s->addEventClamped(crankAngle + crankD, T_SECONDARY, TV_FALL, -1, 721); // 120 + s->addEventClamped(crankAngle + crankD, T_SECONDARY, TriggerValue::FALL, -1, 721); // 120 crankAngle += crankD; } - s->addEventClamped(crankAngle + crankD, T_SECONDARY, TV_RISE, -1, 721); + s->addEventClamped(crankAngle + crankD, T_SECONDARY, TriggerValue::RISE, -1, 721); crankAngle += crankD; - s->addEventClamped(720, T_PRIMARY, TV_RISE, -1, 721); + s->addEventClamped(720, T_PRIMARY, TriggerValue::RISE, -1, 721); s->isSynchronizationNeeded = false; } @@ -65,18 +65,18 @@ void initialize2jzGE3_34_simulation_shape(TriggerWaveform *s) { float crankAngle = 2 * crankDelta; // skipping two teeth for (int i = 0; i < 10; i++) { - s->addEvent720(crankAngle + 5, T_SECONDARY, TV_RISE); - s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TV_FALL); // 120 + s->addEvent720(crankAngle + 5, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TriggerValue::FALL); // 120 crankAngle += 10; } // 2 + 10 camAngle += camD; - s->addEvent720(camAngle, T_PRIMARY, TV_RISE); // 120 - s->addEvent720(camAngle + 3, T_PRIMARY, TV_FALL); + s->addEvent720(camAngle, T_PRIMARY, TriggerValue::RISE); // 120 + s->addEvent720(camAngle + 3, T_PRIMARY, TriggerValue::FALL); for (int i = 0; i < 12; i++) { - s->addEvent720(crankAngle + 5, T_SECONDARY, TV_RISE); - s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TV_FALL); // 120 + s->addEvent720(crankAngle + 5, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TriggerValue::FALL); // 120 crankAngle += 10; } // 2 + 22 @@ -84,38 +84,38 @@ void initialize2jzGE3_34_simulation_shape(TriggerWaveform *s) { camAngle += camD; for (int i = 0; i < 12; i++) { - s->addEvent720(crankAngle + 5, T_SECONDARY, TV_RISE); - s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TV_FALL); // 120 + s->addEvent720(crankAngle + 5, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TriggerValue::FALL); // 120 crankAngle += crankDelta; } // 2 + 34 camAngle += camD; - s->addEvent720(camAngle, T_PRIMARY, TV_RISE); // 360 - s->addEvent720(camAngle + 3, T_PRIMARY, TV_FALL); + s->addEvent720(camAngle, T_PRIMARY, TriggerValue::RISE); // 360 + s->addEvent720(camAngle + 3, T_PRIMARY, TriggerValue::FALL); crankAngle += 20; // skipping two teeth one more time for (int i = 0; i < 10; i++) { - s->addEvent720(crankAngle + 5, T_SECONDARY, TV_RISE); - s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TV_FALL); // 120 + s->addEvent720(crankAngle + 5, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TriggerValue::FALL); // 120 crankAngle += crankDelta; } // 2 + 10 camAngle += camD; for (int i = 0; i < 12; i++) { - s->addEvent720(crankAngle + 5, T_SECONDARY, TV_RISE); - s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TV_FALL); // 120 + s->addEvent720(crankAngle + 5, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TriggerValue::FALL); // 120 crankAngle += crankDelta; } // 2 + 22 camAngle += camD; - s->addEvent720(camAngle, T_PRIMARY, TV_RISE); // 600 - s->addEvent720(camAngle + 3, T_PRIMARY, TV_FALL); + s->addEvent720(camAngle, T_PRIMARY, TriggerValue::RISE); // 600 + s->addEvent720(camAngle + 3, T_PRIMARY, TriggerValue::FALL); for (int i = 0; i < 12; i++) { - s->addEvent720(crankAngle + 5, T_SECONDARY, TV_RISE); - s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TV_FALL); // 120 + s->addEvent720(crankAngle + 5, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(crankAngle + crankDelta, T_SECONDARY, TriggerValue::FALL); // 120 crankAngle += 10; } // 2 + 32 camAngle += camD; @@ -130,12 +130,12 @@ void initializeToyota4_1(TriggerWaveform *s) { int w = 10; - s->addEvent360(180 - w, T_PRIMARY, TV_RISE); - s->addEvent360(180, T_PRIMARY, TV_FALL); + s->addEvent360(180 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(180, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(270 - w, T_PRIMARY, TV_RISE); - s->addEvent360(270, T_PRIMARY, TV_FALL); + s->addEvent360(270 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(270, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(360 - w, T_PRIMARY, TV_RISE); - s->addEvent360(360, T_PRIMARY, TV_FALL); + s->addEvent360(360 - w, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(360, T_PRIMARY, TriggerValue::FALL); } diff --git a/firmware/controllers/trigger/decoders/trigger_universal.cpp b/firmware/controllers/trigger/decoders/trigger_universal.cpp index 5aac78acaa..07d7ce7e77 100644 --- a/firmware/controllers/trigger/decoders/trigger_universal.cpp +++ b/firmware/controllers/trigger/decoders/trigger_universal.cpp @@ -24,14 +24,14 @@ void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerWaveform *s, int for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) { float angleDown = engineCycle / totalTeethCount * (i + (1 - toothWidth)); float angleUp = engineCycle / totalTeethCount * (i + 1); - s->addEventClamped(offset + angleDown, wheel, TV_RISE, filterLeft, filterRight); - s->addEventClamped(offset + angleUp, wheel, TV_FALL, filterLeft, filterRight); + s->addEventClamped(offset + angleDown, wheel, TriggerValue::RISE, filterLeft, filterRight); + s->addEventClamped(offset + angleUp, wheel, TriggerValue::FALL, filterLeft, filterRight); } float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + (1 - toothWidth)); - s->addEventClamped(offset + angleDown, wheel, TV_RISE, filterLeft, filterRight); + s->addEventClamped(offset + angleDown, wheel, TriggerValue::RISE, filterLeft, filterRight); // custom handling of last event in order to avoid rounding error - s->addEventClamped(offset + engineCycle, wheel, TV_FALL, filterLeft, filterRight); + s->addEventClamped(offset + engineCycle, wheel, TriggerValue::FALL, filterLeft, filterRight); } void initializeSkippedToothTriggerWaveformExt(TriggerWaveform *s, int totalTeethCount, int skippedCount, @@ -63,11 +63,11 @@ void initializeSkippedToothTriggerWaveformExt(TriggerWaveform *s, int totalTeeth void configureOnePlusOne(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CAM_SENSOR); - s->addEvent360( 90, T_PRIMARY, TV_RISE); - s->addEvent360(180, T_PRIMARY, TV_FALL); + s->addEvent360( 90, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(180, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(270, T_SECONDARY, TV_RISE); - s->addEvent360(360, T_SECONDARY, TV_FALL); + s->addEvent360(270, T_SECONDARY, TriggerValue::RISE); + s->addEvent360(360, T_SECONDARY, TriggerValue::FALL); s->isSynchronizationNeeded = false; s->useOnlyPrimaryForSync = true; @@ -82,29 +82,29 @@ void configure3_1_cam(TriggerWaveform *s) { trigger_wheel_e crank = T_SECONDARY; - s->addEvent720(10, T_PRIMARY, TV_RISE); - s->addEvent720(50, T_PRIMARY, TV_FALL); + s->addEvent720(10, T_PRIMARY, TriggerValue::RISE); + s->addEvent720(50, T_PRIMARY, TriggerValue::FALL); float a = 2 * crankW; // #1/3 - s->addEvent720(a += crankW, crank, TV_RISE); - s->addEvent720(a += crankW, crank, TV_FALL); + s->addEvent720(a += crankW, crank, TriggerValue::RISE); + s->addEvent720(a += crankW, crank, TriggerValue::FALL); // #2/3 - s->addEvent720(a += crankW, crank, TV_RISE); - s->addEvent720(a += crankW, crank, TV_FALL); + s->addEvent720(a += crankW, crank, TriggerValue::RISE); + s->addEvent720(a += crankW, crank, TriggerValue::FALL); // #3/3 a += crankW; a += crankW; // 2nd #1/3 - s->addEvent720(a += crankW, crank, TV_RISE); - s->addEvent720(a += crankW, crank, TV_FALL); + s->addEvent720(a += crankW, crank, TriggerValue::RISE); + s->addEvent720(a += crankW, crank, TriggerValue::FALL); // 2nd #2/3 - s->addEvent720(a += crankW, crank, TV_RISE); - s->addEvent720(a += crankW, crank, TV_FALL); + s->addEvent720(a += crankW, crank, TriggerValue::RISE); + s->addEvent720(a += crankW, crank, TriggerValue::FALL); s->isSynchronizationNeeded = false; } @@ -123,8 +123,8 @@ void configureKawaKX450F(TriggerWaveform *s) { addSkippedToothTriggerEvents(T_PRIMARY, s, 18, 0, toothWidth, 0, engineCycle, NO_LEFT_FILTER, 720 - 39); - s->addEvent(0.97, T_PRIMARY, TV_RISE); - s->addEvent(1, T_PRIMARY, TV_FALL); + s->addEvent(0.97, T_PRIMARY, TriggerValue::RISE); + s->addEvent(1, T_PRIMARY, TriggerValue::FALL); } void configureQuickStartSenderWheel(TriggerWaveform *s) { @@ -138,17 +138,17 @@ void configureQuickStartSenderWheel(TriggerWaveform *s) { s->setTriggerSynchronizationGap(0.645); s->setSecondTriggerSynchronizationGap(1.556); - s->addEvent360(offset + 0, T_PRIMARY, TV_RISE); - s->addEvent360(offset + 70, T_PRIMARY, TV_FALL); + s->addEvent360(offset + 0, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(offset + 70, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(offset + 90, T_PRIMARY, TV_RISE); - s->addEvent360(offset + 110, T_PRIMARY, TV_FALL); + s->addEvent360(offset + 90, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(offset + 110, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(offset + 180, T_PRIMARY, TV_RISE); - s->addEvent360(offset + 200, T_PRIMARY, TV_FALL); + s->addEvent360(offset + 180, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(offset + 200, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(offset + 270, T_PRIMARY, TV_RISE); - s->addEvent360(offset + 340, T_PRIMARY, TV_FALL); + s->addEvent360(offset + 270, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(offset + 340, T_PRIMARY, TriggerValue::FALL); } // Useful for: @@ -166,6 +166,6 @@ void configure12ToothCrank(TriggerWaveform* s) { } // Just a single tooth with 50% duty cycle - s->addEventAngle(15, T_PRIMARY, TV_FALL); - s->addEventAngle(30, T_PRIMARY, TV_RISE); + s->addEventAngle(15, T_PRIMARY, TriggerValue::FALL); + s->addEventAngle(30, T_PRIMARY, TriggerValue::RISE); } diff --git a/firmware/controllers/trigger/decoders/trigger_vw.cpp b/firmware/controllers/trigger/decoders/trigger_vw.cpp index 58cd6cf4a3..93e4b55950 100644 --- a/firmware/controllers/trigger/decoders/trigger_vw.cpp +++ b/firmware/controllers/trigger/decoders/trigger_vw.cpp @@ -12,14 +12,14 @@ void setSkodaFavorit(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CRANK_SENSOR); - s->addEvent360(46, T_PRIMARY, TV_RISE); - s->addEvent360(177, T_PRIMARY, TV_FALL); + s->addEvent360(46, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(177, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(180, T_PRIMARY, TV_RISE); - s->addEvent360(183, T_PRIMARY, TV_FALL); + s->addEvent360(180, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(183, T_PRIMARY, TriggerValue::FALL); - s->addEvent360(226, T_PRIMARY, TV_RISE); - s->addEvent360(360, T_PRIMARY, TV_FALL); + s->addEvent360(226, T_PRIMARY, TriggerValue::RISE); + s->addEvent360(360, T_PRIMARY, TriggerValue::FALL); s->tdcPosition = 180 - 46; s->setTriggerSynchronizationGap(3.91); @@ -38,8 +38,8 @@ void setVwConfiguration(TriggerWaveform *s) { NO_LEFT_FILTER, 690); float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + (1 - toothWidth) ); - s->addEventClamped(0 + angleDown + 12, T_PRIMARY, TV_RISE, NO_LEFT_FILTER, NO_RIGHT_FILTER); - s->addEventClamped(0 + engineCycle, T_PRIMARY, TV_FALL, NO_LEFT_FILTER, NO_RIGHT_FILTER); + s->addEventClamped(0 + angleDown + 12, T_PRIMARY, TriggerValue::RISE, NO_LEFT_FILTER, NO_RIGHT_FILTER); + s->addEventClamped(0 + engineCycle, T_PRIMARY, TriggerValue::FALL, NO_LEFT_FILTER, NO_RIGHT_FILTER); s->setTriggerSynchronizationGap2(1.6, 4); s->setSecondTriggerSynchronizationGap(1); // this gap is not required to synch on perfect signal but is needed to handle to reject cranking transition noise diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 03d898891f..3487e69c7c 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -234,7 +234,7 @@ static void logFront(bool isImportantFront, efitick_t nowNt, int index) { } } -void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { +void hwHandleVvtCamSignal(TriggerValue front, efitick_t nowNt, int index) { if (engine->directSelfStimulation || !engine->hwTriggerInputEnabled) { // sensor noise + self-stim = loss of trigger sync return; @@ -243,7 +243,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { int bankIndex = index / CAMS_PER_BANK; int camIndex = index % CAMS_PER_BANK; TriggerCentral *tc = &engine->triggerCentral; - if (front == TV_RISE) { + if (front == TriggerValue::RISE) { tc->vvtEventRiseCounter[index]++; } else { tc->vvtEventFallCounter[index]++; @@ -269,18 +269,18 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { if (!engineConfiguration->displayLogicLevelsInEngineSniffer) { // todo: migrate injector_pressure_type_e to class enum, maybe merge with FrontDirection? - addEngineSnifferVvtEvent(index, front == TV_RISE ? FrontDirection::UP : FrontDirection::DOWN); + addEngineSnifferVvtEvent(index, front == TriggerValue::RISE ? FrontDirection::UP : FrontDirection::DOWN); #if EFI_TOOTH_LOGGER // todo: we need to start logging different VVT channels differently!!! - trigger_event_e tooth = front == TV_RISE ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING; + trigger_event_e tooth = front == TriggerValue::RISE ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING; LogTriggerTooth(tooth, nowNt); #endif /* EFI_TOOTH_LOGGER */ } - bool isImportantFront = (engineConfiguration->vvtCamSensorUseRise ^ (front == TV_FALL)); + bool isImportantFront = (engineConfiguration->vvtCamSensorUseRise ^ (front == TriggerValue::FALL)); bool isVvtWithRealDecoder = vvtWithRealDecoder(engineConfiguration->vvtMode[camIndex]); if (!isVvtWithRealDecoder && !isImportantFront) { // todo: there should be a way to always use real trigger code for this logic? @@ -302,7 +302,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { tc->vvtShape[camIndex], nullptr, engine->vvtTriggerConfiguration[camIndex], - front == TV_RISE ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING, nowNt); + front == TriggerValue::RISE ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING, nowNt); // yes we log data from all VVT channels into same fields for now tc->triggerState.vvtSyncGapRatio = vvtDecoder.triggerSyncGapRatio; tc->triggerState.vvtStateIndex = vvtDecoder.currentCycle.current_index; @@ -623,8 +623,8 @@ void TriggerCentral::decodeMapCam(efitick_t timestamp, float currentPhase) { mapVvt_MAP_AT_CYCLE_COUNT = revolutionCounter - prevChangeAtCycle; prevChangeAtCycle = revolutionCounter; - hwHandleVvtCamSignal(TV_RISE, timestamp, /*index*/0); - hwHandleVvtCamSignal(TV_FALL, timestamp, /*index*/0); + hwHandleVvtCamSignal(TriggerValue::RISE, timestamp, /*index*/0); + hwHandleVvtCamSignal(TriggerValue::FALL, timestamp, /*index*/0); #if EFI_UNIT_TEST // hack? feature? existing unit test relies on VVT phase available right away // but current implementation which is based on periodicFastCallback would only make result available on NEXT tooth diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 2e4daf547c..675367b56d 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -149,7 +149,7 @@ private: void triggerInfo(void); void hwHandleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp); void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp); -void hwHandleVvtCamSignal(trigger_value_e front, efitick_t timestamp, int index); +void hwHandleVvtCamSignal(TriggerValue front, efitick_t timestamp, int index); void validateTriggerInputs(); diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index b4ce8a8d44..05442b80fc 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -339,7 +339,7 @@ bool TriggerDecoderBase::isValidIndex(const TriggerWaveform& triggerShape) const } static trigger_wheel_e eventIndex[4] = { T_PRIMARY, T_PRIMARY, T_SECONDARY, T_SECONDARY }; -static trigger_value_e eventType[4] = { TV_FALL, TV_RISE, TV_FALL, TV_RISE }; +static TriggerValue eventType[4] = { TriggerValue::FALL, TriggerValue::RISE, TriggerValue::FALL, TriggerValue::RISE }; #if EFI_UNIT_TEST #define PRINT_INC_INDEX if (printTriggerTrace) {\ @@ -358,8 +358,8 @@ static trigger_value_e eventType[4] = { TV_FALL, TV_RISE, TV_FALL, TV_RISE }; #define considerEventForGap() (!triggerShape.useOnlyPrimaryForSync || isPrimary) -#define needToSkipFall(type) ((!triggerShape.gapBothDirections) && (( triggerShape.useRiseEdge) && (type != TV_RISE))) -#define needToSkipRise(type) ((!triggerShape.gapBothDirections) && ((!triggerShape.useRiseEdge) && (type != TV_FALL))) +#define needToSkipFall(type) ((!triggerShape.gapBothDirections) && (( triggerShape.useRiseEdge) && (type != TriggerValue::RISE))) +#define needToSkipRise(type) ((!triggerShape.gapBothDirections) && ((!triggerShape.useRiseEdge) && (type != TriggerValue::FALL))) int TriggerDecoderBase::getCurrentIndex() const { return currentCycle.current_index; @@ -441,12 +441,12 @@ case SHAFT_SECONDARY_RISING: } return NULL; } -const char *getTrigger_value_e(trigger_value_e value){ +const char *getTrigger_value_e(TriggerValue value){ switch(value) { -case TV_FALL: - return "TV_FALL"; -case TV_RISE: - return "TV_RISE"; +case TriggerValue::FALL: + return "TriggerValue::FALL"; +case TriggerValue::RISE: + return "TriggerValue::RISE"; } return NULL; } @@ -536,7 +536,7 @@ expected TriggerDecoderBase::decodeTriggerEvent( efiAssert(CUSTOM_TRIGGER_UNEXPECTED, signal <= SHAFT_SECONDARY_RISING, "unexpected signal", unexpected); trigger_wheel_e triggerWheel = eventIndex[signal]; - trigger_value_e type = eventType[signal]; + TriggerValue type = eventType[signal]; // Check that we didn't get the same edge twice in a row - that should be impossible if (!useOnlyRisingEdgeForTrigger && prevSignal == signal) { diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index c495f051e9..55d6605cc5 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -15,7 +15,7 @@ #include "timer.h" const char *getTrigger_event_e(trigger_event_e value); -const char *getTrigger_value_e(trigger_value_e value); +const char *getTrigger_value_e(TriggerValue value); struct TriggerStateListener { #if EFI_SHAFT_POSITION_INPUT diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index ad76f39ec4..9f086fad09 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -48,7 +48,7 @@ void TriggerEmulatorHelper::handleEmulatorCallback(const MultiChannelStateSequen if (needEvent(stateIndex, multiChannelStateSequence, i)) { pin_state_t currentValue = multiChannelStateSequence.getChannelState(/*phaseIndex*/i, stateIndex); - handleShaftSignal(i, currentValue, stamp); + handleShaftSignal(i, currentValue == TriggerValue::RISE, stamp); } } #endif // EFI_SHAFT_POSITION_INPUT diff --git a/firmware/controllers/trigger/trigger_simulator.cpp b/firmware/controllers/trigger/trigger_simulator.cpp index 5b8248e226..866980c697 100644 --- a/firmware/controllers/trigger/trigger_simulator.cpp +++ b/firmware/controllers/trigger/trigger_simulator.cpp @@ -76,7 +76,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent( for (size_t i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) { if (needEvent(stateIndex, multiChannelStateSequence, i)) { pin_state_t currentValue = multiChannelStateSequence.getChannelState(/*phaseIndex*/i, stateIndex); - trigger_event_e event = (currentValue ? riseEvents : fallEvents)[i]; + trigger_event_e event = (currentValue == TriggerValue::RISE ? riseEvents : fallEvents)[i]; if (isUsefulSignal(event, triggerConfiguration)) { state.decodeTriggerEvent( "sim", diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input_comp.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input_comp.cpp index a1baa8d4b8..a991d68dc6 100644 --- a/firmware/hw_layer/digital_input/trigger/trigger_input_comp.cpp +++ b/firmware/hw_layer/digital_input/trigger/trigger_input_comp.cpp @@ -72,9 +72,9 @@ static void comp_cam_callback(COMPDriver *comp) { efitick_t stamp = getTimeNowNt(); if (isRising) { - hwHandleVvtCamSignal(TV_RISE, stamp, index); + hwHandleVvtCamSignal(TriggerValue::RISE, stamp, index); } else { - hwHandleVvtCamSignal(TV_FALL, stamp, index); + hwHandleVvtCamSignal(TriggerValue::FALL, stamp, index); } } #endif diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input_exti.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input_exti.cpp index c07c0795e3..a53a4e7cdb 100644 --- a/firmware/hw_layer/digital_input/trigger/trigger_input_exti.cpp +++ b/firmware/hw_layer/digital_input/trigger/trigger_input_exti.cpp @@ -43,9 +43,9 @@ static void cam_callback(void *arg, efitick_t stamp) { bool rise = (palReadLine(pal_line) == PAL_HIGH); if (rise ^ engineConfiguration->invertCamVVTSignal) { - hwHandleVvtCamSignal(TV_RISE, stamp, index); + hwHandleVvtCamSignal(TriggerValue::RISE, stamp, index); } else { - hwHandleVvtCamSignal(TV_FALL, stamp, index); + hwHandleVvtCamSignal(TriggerValue::FALL, stamp, index); } } diff --git a/misc/stm32f1_test_project/timer/pwm_generator_logic.cpp b/misc/stm32f1_test_project/timer/pwm_generator_logic.cpp index bb891b6703..8098f0ba52 100644 --- a/misc/stm32f1_test_project/timer/pwm_generator_logic.cpp +++ b/misc/stm32f1_test_project/timer/pwm_generator_logic.cpp @@ -316,8 +316,8 @@ void startSimplePwm(SimplePwm *state, const char *msg, ExecutorInterface *execut state->seq.setSwitchTime(0, dutyCycle); state->seq.setSwitchTime(1, 1); - state->seq.setChannelState(0, 0, TV_FALL); - state->seq.setChannelState(0, 1, TV_RISE); + state->seq.setChannelState(0, 0, TriggerValue::FALL); + state->seq.setChannelState(0, 1, TriggerValue::RISE); state->outputPins[0] = output; diff --git a/unit_tests/logicdata_csv_reader.cpp b/unit_tests/logicdata_csv_reader.cpp index 579c702dc1..9d4d65c815 100644 --- a/unit_tests/logicdata_csv_reader.cpp +++ b/unit_tests/logicdata_csv_reader.cpp @@ -101,7 +101,7 @@ void CsvReader::processLine(EngineTestHelper *eth) { } efitick_t nowNt = getTimeNowNt(); - trigger_value_e event = newVvtState[vvtIndex] ^ engineConfiguration->invertCamVVTSignal ? TV_RISE : TV_FALL; + TriggerValue event = newVvtState[vvtIndex] ^ engineConfiguration->invertCamVVTSignal ? TriggerValue::RISE : TriggerValue::FALL; // todo: configurable selection of vvt mode - dual bank or dual cam single bank int bankIndex = vvtIndex; int camIndex = 0; diff --git a/unit_tests/tests/ignition_injection/test_fuel_map.cpp b/unit_tests/tests/ignition_injection/test_fuel_map.cpp index fee44430d5..b26f875ace 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_map.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_map.cpp @@ -88,34 +88,34 @@ static void configureFordAspireTriggerWaveform(TriggerWaveform * s) { s->initialize(FOUR_STROKE_CAM_SENSOR); s->useOnlyRisingEdgeForTriggerTemp = false; - s->addEvent720(53.747, T_SECONDARY, TV_RISE); - s->addEvent720(121.90, T_SECONDARY, TV_FALL); - s->addEvent720(232.76, T_SECONDARY, TV_RISE); - s->addEvent720(300.54, T_SECONDARY, TV_FALL); - s->addEvent720(360, T_PRIMARY, TV_RISE); + s->addEvent720(53.747, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(121.90, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(232.76, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(300.54, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(360, T_PRIMARY, TriggerValue::RISE); - s->addEvent720(409.8412, T_SECONDARY, TV_RISE); - s->addEvent720(478.6505, T_SECONDARY, TV_FALL); - s->addEvent720(588.045, T_SECONDARY, TV_RISE); - s->addEvent720(657.03, T_SECONDARY, TV_FALL); - s->addEvent720(720, T_PRIMARY, TV_FALL); + s->addEvent720(409.8412, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(478.6505, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(588.045, T_SECONDARY, TriggerValue::RISE); + s->addEvent720(657.03, T_SECONDARY, TriggerValue::FALL); + s->addEvent720(720, T_PRIMARY, TriggerValue::FALL); ASSERT_FLOAT_EQ(53.747 / 720, s->wave.getSwitchTime(0)); - ASSERT_EQ( 1, s->wave.getChannelState(1, 0)) << "@0"; - ASSERT_EQ( 1, s->wave.getChannelState(1, 0)) << "@0"; + ASSERT_EQ( TriggerValue::RISE, s->wave.getChannelState(1, 0)) << "@0"; + ASSERT_EQ( TriggerValue::RISE, s->wave.getChannelState(1, 0)) << "@0"; - ASSERT_EQ( 0, s->wave.getChannelState(0, 1)) << "@1"; - ASSERT_EQ( 0, s->wave.getChannelState(1, 1)) << "@1"; + ASSERT_EQ( TriggerValue::FALL, s->wave.getChannelState(0, 1)) << "@1"; + ASSERT_EQ( TriggerValue::FALL, s->wave.getChannelState(1, 1)) << "@1"; - ASSERT_EQ( 0, s->wave.getChannelState(0, 2)) << "@2"; - ASSERT_EQ( 1, s->wave.getChannelState(1, 2)) << "@2"; + ASSERT_EQ( TriggerValue::FALL, s->wave.getChannelState(0, 2)) << "@2"; + ASSERT_EQ( TriggerValue::RISE, s->wave.getChannelState(1, 2)) << "@2"; - ASSERT_EQ( 0, s->wave.getChannelState(0, 3)) << "@3"; - ASSERT_EQ( 0, s->wave.getChannelState(1, 3)) << "@3"; + ASSERT_EQ( TriggerValue::FALL, s->wave.getChannelState(0, 3)) << "@3"; + ASSERT_EQ( TriggerValue::FALL, s->wave.getChannelState(1, 3)) << "@3"; - ASSERT_EQ( 1, s->wave.getChannelState(0, 4)) << "@4"; - ASSERT_EQ( 1, s->wave.getChannelState(1, 5)) << "@5"; - ASSERT_EQ( 0, s->wave.getChannelState(1, 8)) << "@8"; + ASSERT_EQ( TriggerValue::RISE, s->wave.getChannelState(0, 4)) << "@4"; + ASSERT_EQ( TriggerValue::RISE, s->wave.getChannelState(1, 5)) << "@5"; + ASSERT_EQ( TriggerValue::FALL, s->wave.getChannelState(1, 8)) << "@8"; ASSERT_FLOAT_EQ(121.90 / 720, s->wave.getSwitchTime(1)); ASSERT_FLOAT_EQ(657.03 / 720, s->wave.getSwitchTime(8)); diff --git a/unit_tests/tests/trigger/test_2jz_vvt.cpp b/unit_tests/tests/trigger/test_2jz_vvt.cpp index eae57279d4..0606976740 100644 --- a/unit_tests/tests/trigger/test_2jz_vvt.cpp +++ b/unit_tests/tests/trigger/test_2jz_vvt.cpp @@ -29,8 +29,8 @@ TEST(sensors, test2jz) { eth.moveTimeForwardUs(MS2US(3)); // shifting VVT phase a few angles - hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::FALL, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), 0); // currentPosition ASSERT_NEAR(608.2 - 720, engine->triggerCentral.currentVVTEventPosition[0][0], EPS3D); diff --git a/unit_tests/tests/trigger/test_cam_vvt_input.cpp b/unit_tests/tests/trigger/test_cam_vvt_input.cpp index 9de183b315..1a479cb2a3 100644 --- a/unit_tests/tests/trigger/test_cam_vvt_input.cpp +++ b/unit_tests/tests/trigger/test_cam_vvt_input.cpp @@ -110,7 +110,7 @@ TEST(trigger, testCamInput) { for (int i = 0; i < 600;i++) { eth.moveTimeForwardUs(MS2US(10)); - hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::FALL, getTimeNowNt(), 0); eth.moveTimeForwardUs(MS2US(40)); eth.firePrimaryTriggerRise(); } @@ -147,21 +147,21 @@ TEST(trigger, testNB2CamInput) { eth.moveTimeForwardUs(MS2US(3)); // shifting VVT phase a few angles - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), 0); // first gap - long eth.moveTimeForwardUs(MS2US(130)); - hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::FALL, getTimeNowNt(), 0); eth.moveTimeForwardUs(MS2US( 30)); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), 0); // second gap - short eth.moveTimeForwardUs(MS2US(10)); - hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::FALL, getTimeNowNt(), 0); eth.moveTimeForwardUs(MS2US(10)); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), 0); ASSERT_FLOAT_EQ(0, engine->triggerCentral.getVVTPosition(0, 0)); ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getCrankSynchronizationCounter()); @@ -169,9 +169,9 @@ TEST(trigger, testNB2CamInput) { // Third gap - long eth.moveTimeForwardUs(MS2US(130)); - hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::FALL, getTimeNowNt(), 0); eth.moveTimeForwardUs(MS2US( 30)); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), 0); EXPECT_NEAR(290.5f, engine->triggerCentral.getVVTPosition(0, 0), EPS2D); // actually position based on VVT! diff --git a/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp b/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp index e16739b14e..36ed69084f 100644 --- a/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp +++ b/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp @@ -24,13 +24,12 @@ static void func(TriggerCallback *callback) { Engine *engine = callback->engine; - int value = callback->form->wave.getChannelState(0, formIndex); + TriggerValue value = callback->form->wave.getChannelState(0, formIndex); efitick_t nowNt = getTimeNowNt(); if (callback->isVvt) { - trigger_value_e v = value ? TV_RISE : TV_FALL; - hwHandleVvtCamSignal(v, nowNt, callback->vvtBankIndex * CAMS_PER_BANK); + hwHandleVvtCamSignal(value, nowNt, callback->vvtBankIndex * CAMS_PER_BANK); } else { - handleShaftSignal(0, value, nowNt); + handleShaftSignal(0, value == TriggerValue::RISE, nowNt); } } diff --git a/unit_tests/tests/trigger/test_quad_cam.cpp b/unit_tests/tests/trigger/test_quad_cam.cpp index 6b3a7f634c..2d00585d82 100644 --- a/unit_tests/tests/trigger/test_quad_cam.cpp +++ b/unit_tests/tests/trigger/test_quad_cam.cpp @@ -59,10 +59,10 @@ TEST(trigger, testQuadCam) { ASSERT_EQ(0, engine->triggerCentral.getVVTPosition(secondBank, firstCam)); ASSERT_EQ(0, engine->triggerCentral.getVVTPosition(secondBank, secondCam)); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), firstCam); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), secondCam); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), firstCamSecondBank); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), secondCamSecondBank); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), firstCam); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), secondCam); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), firstCamSecondBank); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), secondCamSecondBank); float basePos = -80.2f; @@ -74,13 +74,13 @@ TEST(trigger, testQuadCam) { // Now fire cam events again, but with time gaps between each eth.moveTimeForwardMs(1); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), firstCam); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), firstCam); eth.moveTimeForwardMs(1); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), secondCam); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), secondCam); eth.moveTimeForwardMs(1); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), firstCamSecondBank); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), firstCamSecondBank); eth.moveTimeForwardMs(1); - hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), secondCamSecondBank); + hwHandleVvtCamSignal(TriggerValue::RISE, getTimeNowNt(), secondCamSecondBank); // All four cams should have different positions, each retarded by 1ms from the last float oneMsDegrees = 1000 / engine->rpmCalculator.oneDegreeUs;