diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index b6258e9a44..9cd9eff6ad 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -210,8 +210,6 @@ typedef enum __attribute__ ((__packed__)) { PI_PULLDOWN = 2 } pin_input_mode_e; -#define CRANK_MODE_MULTIPLIER 2.0f - /** * @see getCycleDuration * @see getEngineCycle diff --git a/firmware/controllers/trigger/decoders/trigger_gm.cpp b/firmware/controllers/trigger/decoders/trigger_gm.cpp index 5c65864087..99b9e903bf 100644 --- a/firmware/controllers/trigger/decoders/trigger_gm.cpp +++ b/firmware/controllers/trigger/decoders/trigger_gm.cpp @@ -9,9 +9,11 @@ #include "trigger_gm.h" +#define GM_60_W 6 + static float addTooth(float offset, TriggerWaveform *s) { - s->addToothRiseFall(offset / 2 + 3, 3, TriggerWheel::T_SECONDARY); - return offset + CRANK_MODE_MULTIPLIER * 6; + s->addToothRiseFall(offset + GM_60_W / 2, GM_60_W / 2, TriggerWheel::T_SECONDARY); + return offset + GM_60_W; } /** @@ -23,37 +25,35 @@ void configureGm60_2_2_2(TriggerWaveform *s) { s->isSynchronizationNeeded = false; s->isSecondWheelCam = true; - float m = CRANK_MODE_MULTIPLIER; - int offset = 1 * m; + int offset = 1; for (int i=0;i<12;i++) { offset = addTooth(offset, s); } - offset += m * 2 * 6; + offset += 2 * GM_60_W; for (int i=0;i<18;i++) { offset = addTooth(offset, s); } - offset += m * 2 * 6; + offset += 2 * GM_60_W; for (int i=0;i<18;i++) { offset = addTooth(offset, s); } - offset += m * 2 * 6; + offset += 2 * GM_60_W; for (int i=0;i<5;i++) { offset = addTooth(offset, s); } - - s->addEventAngle(m * (360 - 6), TriggerValue::RISE); + s->addEvent360(360 - GM_60_W, TriggerValue::RISE); offset = addTooth(offset, s); - s->addEventAngle(m * (360), TriggerValue::FALL); + s->addEvent360(360, TriggerValue::FALL); } diff --git a/firmware/controllers/trigger/decoders/trigger_honda.cpp b/firmware/controllers/trigger/decoders/trigger_honda.cpp index 56bc7930b4..54d1056abb 100644 --- a/firmware/controllers/trigger/decoders/trigger_honda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_honda.cpp @@ -69,12 +69,6 @@ void configureOnePlus16(TriggerWaveform *s) { s->isSynchronizationNeeded = false; } -static void kseriesTooth(TriggerWaveform* s, float end) { - // for VR we only handle rises so width does not matter much - s->addEvent360(end - 4, TriggerValue::RISE, TriggerWheel::T_PRIMARY); - s->addEvent360(end , TriggerValue::FALL, TriggerWheel::T_PRIMARY); -} - // TT_HONDA_K_CRANK_12_1 void configureHondaK_12_1(TriggerWaveform *s) { s->initialize(FOUR_STROKE_CRANK_SENSOR, SyncEdge::RiseOnly); @@ -87,11 +81,14 @@ void configureHondaK_12_1(TriggerWaveform *s) { int count = 12; float tooth = 360 / count; // hint: tooth = 30 + // for VR we only handle rises so width does not matter much + int width = 4; + // Extra "+1" tooth happens 1/3 of the way between first two teeth - kseriesTooth(s, tooth / 3); + s->addToothRiseFall(tooth / 3, width); for (int i = 1; i <= count; i++) { - kseriesTooth(s, tooth * i); + s->addToothRiseFall(tooth * i, width); } } diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index ae720f7bc4..86a9d0560f 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -225,6 +225,7 @@ void TriggerWaveform::addEvent720(angle_t angle, TriggerValue const state, Trigg void TriggerWaveform::addEvent360(angle_t angle, TriggerValue const state, TriggerWheel const channelIndex) { efiAssertVoid(ObdCode::CUSTOM_OMODE_UNDEF, operationMode == FOUR_STROKE_CAM_SENSOR || operationMode == FOUR_STROKE_CRANK_SENSOR, "Not a mode for 360"); +#define CRANK_MODE_MULTIPLIER 2.0f addEvent(CRANK_MODE_MULTIPLIER * angle / FOUR_STROKE_CYCLE_DURATION, state, channelIndex); }