From d033f26910ce71bc002b17e214a50084085b3189 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Sat, 18 Jan 2025 02:22:02 -0800 Subject: [PATCH] cylinder calculates its own angle offset --- firmware/controllers/engine_cycle/spark_logic.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index 94aed6005f..47cf12cdfa 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -68,8 +68,10 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_ // let's save planned duration so that we can later compare it with reality event->sparkDwell = sparkDwell; + const auto& cylinder = engine->cylinders[realCylinderNumber]; + // Compute the final ignition timing including all "late" adjustments - angle_t finalIgnitionTiming = engine->cylinders[realCylinderNumber].getIgnitionTimingBtdc() + angle_t finalIgnitionTiming = cylinder.getIgnitionTimingBtdc() // Pull any extra timing for knock retard - engine->module()->getKnockRetard(); @@ -90,7 +92,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_ // Negate because timing *before* TDC, and we schedule *after* TDC - finalIgnitionTiming // Offset by this cylinder's position in the cycle - + getCylinderAngle(event->cylinderIndex, realCylinderNumber); + + cylinder.getAngleOffset(); efiAssertVoid(ObdCode::CUSTOM_SPARK_ANGLE_1, !std::isnan(sparkAngle), "sparkAngle#1"); wrapAngle(sparkAngle, "findAngle#2", ObdCode::CUSTOM_ERR_6550);