From d51511a15ecbb6707580541013d7c831936f4a26 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 5 Sep 2022 00:53:05 -0400 Subject: [PATCH] refactoring: moving field --- firmware/controllers/algo/engine.h | 6 ------ firmware/controllers/algo/engine2.cpp | 2 +- firmware/controllers/algo/engine_state.h | 7 +++++++ firmware/controllers/algo/fuel_math.cpp | 2 +- firmware/controllers/engine_cycle/fuel_schedule.cpp | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index dd24dc9362..e3c2fb91c8 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -330,12 +330,6 @@ public: TriggerCentral triggerCentral; #endif // EFI_SHAFT_POSITION_INPUT - /** - * Each individual fuel injection duration for current engine cycle, without wall wetting - * including everything including injector lag, both cranking and running - * @see getInjectionDuration() - */ - floatms_t injectionDuration = 0; // Per-injection fuel mass, including TPS accel enrich float injectionMass[MAX_CYLINDER_COUNT] = {0}; diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index e0bdcd06ce..ad3bc26a35 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -158,7 +158,7 @@ void EngineState::periodicFastCallback() { auto clResult = fuelClosedLoopCorrection(); // Store the pre-wall wetting injection duration for scheduling purposes only, not the actual injection duration - engine->injectionDuration = engine->module()->getInjectionDuration(injectionMass); + engine->engineState.injectionDuration = engine->module()->getInjectionDuration(injectionMass); float fuelLoad = getFuelingLoad(); injectionOffset = getInjectionOffset(rpm, fuelLoad); diff --git a/firmware/controllers/algo/engine_state.h b/firmware/controllers/algo/engine_state.h index ca02ecf935..623f8a6def 100644 --- a/firmware/controllers/algo/engine_state.h +++ b/firmware/controllers/algo/engine_state.h @@ -61,6 +61,13 @@ public: */ floatms_t tpsAccelEnrich = 0; + /** + * Each individual fuel injection duration for current engine cycle, without wall wetting + * including everything including injector lag, both cranking and running + * @see getInjectionDuration() + */ + floatms_t injectionDuration = 0; + angle_t injectionOffset = 0; multispark_state multispark; diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 78323234af..4be566232f 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -271,7 +271,7 @@ float getInjectionModeDurationMultiplier() { * @see getCoilDutyCycle */ percent_t getInjectorDutyCycle(int rpm) { - floatms_t totalInjectiorAmountPerCycle = engine->injectionDuration * getNumberOfInjections(engineConfiguration->injectionMode); + floatms_t totalInjectiorAmountPerCycle = engine->engineState.injectionDuration * getNumberOfInjections(engineConfiguration->injectionMode); floatms_t engineCycleDuration = getEngineCycleDuration(rpm); return 100 * totalInjectiorAmountPerCycle / engineCycleDuration; } diff --git a/firmware/controllers/engine_cycle/fuel_schedule.cpp b/firmware/controllers/engine_cycle/fuel_schedule.cpp index cb676db004..470ddc74d0 100644 --- a/firmware/controllers/engine_cycle/fuel_schedule.cpp +++ b/firmware/controllers/engine_cycle/fuel_schedule.cpp @@ -64,7 +64,7 @@ expected InjectionEvent::computeInjectionAngle(int cylinderIndex) const { // injection phase may be scheduled by injection end, so we need to step the angle back // for the duration of the injection - angle_t injectionDurationAngle = getInjectionAngleCorrection(engine->injectionDuration, oneDegreeUs); + angle_t injectionDurationAngle = getInjectionAngleCorrection(engine->engineState.injectionDuration, oneDegreeUs); // User configured offset - degrees after TDC combustion floatus_t injectionOffset = engine->engineState.injectionOffset;