We need to reshuffle timing calculation a bit, add one more gauge #5235

This commit is contained in:
Andrey 2023-04-12 17:22:28 -04:00
parent 97d6313924
commit 0470953cb8
2 changed files with 9 additions and 4 deletions

View File

@ -164,7 +164,14 @@ void EngineState::periodicFastCallback() {
injectionOffset = getInjectionOffset(rpm, fuelLoad);
float ignitionLoad = getIgnitionLoad();
float advance = getAdvance(rpm, ignitionLoad) * engine->ignitionState.luaTimingMult + engine->ignitionState.luaTimingAdd;
float baseAdvance = getAdvance(rpm, ignitionLoad) * engine->ignitionState.luaTimingMult + engine->ignitionState.luaTimingAdd;
float correctedIgnitionAdvance = baseAdvance
// Pull any extra timing for knock retard
+ engine->module<KnockController>()->getKnockRetard();
// these fields are scaled_channel so let's only use for observability, with a local variables holding value while it matters locally
engine->ignitionState.baseIgnitionAdvance = baseAdvance;
engine->ignitionState.correctedIgnitionAdvance = correctedIgnitionAdvance;
// compute per-bank fueling
for (size_t i = 0; i < STFT_BANK_COUNT; i++) {
@ -181,7 +188,7 @@ void EngineState::periodicFastCallback() {
// Apply both per-bank and per-cylinder trims
engine->engineState.injectionMass[i] = injectionMass * bankTrim * cylinderTrim;
timingAdvance[i] = advance + getCombinedCylinderIgnitionTrim(i, rpm, ignitionLoad);
timingAdvance[i] = correctedIgnitionAdvance + getCombinedCylinderIgnitionTrim(i, rpm, ignitionLoad);
}
// TODO: calculate me from a table!

View File

@ -101,8 +101,6 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
angle_t correctedSparkAngle =
// Negate because timing *before* TDC, and we schedule *after* TDC
- getEngineState()->timingAdvance[event->cylinderNumber]
// Pull any extra timing for knock retard
+ engine->module<KnockController>()->getKnockRetard()
// Degrees of timing REMOVED from actual timing during soft RPM limit window
+ getLimpManager()->getLimitingTimingRetard();