From 32b7b014c9e0fea7243d049ee4f12231f0dcccaa Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 12 Apr 2023 15:18:29 -0400 Subject: [PATCH] per-cylinder should not contain firingOrderOffset fix #5236 --- firmware/controllers/engine_cycle/spark_logic.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index 6837fae2b8..5fe8fd61da 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -98,19 +98,21 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_ // let's save planned duration so that we can later compare it with reality event->sparkDwell = sparkDwell; - angle_t sparkAngle = + angle_t correctedSparkAngle = // Negate because timing *before* TDC, and we schedule *after* TDC - getEngineState()->timingAdvance[event->cylinderNumber] - // Offset by this cylinder's position in the cycle - + getPerCylinderFiringOrderOffset(event->cylinderIndex, event->cylinderNumber) // Pull any extra timing for knock retard + engine->module()->getKnockRetard() // Degrees of timing REMOVED from actual timing during soft RPM limit window + getLimpManager()->getLimitingTimingRetard(); - efiAssertVoid(CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1"); + engine->ignitionState.perCylinderTiming[event->cylinderIndex] = correctedSparkAngle; - engine->ignitionState.perCylinderTiming[event->cylinderIndex] = sparkAngle; + angle_t sparkAngle = correctedSparkAngle + // Offset by this cylinder's position in the cycle + + getPerCylinderFiringOrderOffset(event->cylinderIndex, event->cylinderNumber); + + efiAssertVoid(CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1"); auto ignitionMode = getCurrentIgnitionMode();