Skip to content

Commit

Permalink
cylinder calculates its own angle offset
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jan 18, 2025
1 parent e516fde commit d033f26
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions firmware/controllers/engine_cycle/spark_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<KnockController>()->getKnockRetard();

Expand All @@ -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);
Expand Down

0 comments on commit d033f26

Please sign in to comment.