From 13c42ead9294d4ecb8fc235945ec4c3af646638c Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 5 Sep 2022 04:28:47 -0400 Subject: [PATCH] tear down Engine god object #4511 just trying different things --- .../engine_cycle/main_trigger_callback.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index a169736b70..ff3805b091 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -23,6 +23,11 @@ #include "pch.h" +// dependency injection +#include "engine_state.h" +#include "rpm_calculator_api.h" +// end of injection + #include "os_access.h" #if EFI_PRINTF_FUEL_DETAILS @@ -72,7 +77,7 @@ void InjectorOutputPin::open(efitick_t nowNt) { // per-output counter for error detection overlappingCounter++; // global counter for logging - engine->engineState.fuelInjectionCounter++; + getEngineState()->fuelInjectionCounter++; #if FUEL_MATH_EXTREME_LOGGING if (printFuelDebug) { @@ -180,7 +185,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase } // Select fuel mass from the correct cylinder - auto injectionMassGrams = engine->engineState.injectionMass[this->cylinderNumber]; + auto injectionMassGrams = getEngineState()->injectionMass[this->cylinderNumber]; // Perform wall wetting adjustment on fuel mass, not duration, so that // it's correct during fuel pressure (injector flow) or battery voltage (deadtime) transients @@ -190,12 +195,12 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase #if EFI_PRINTF_FUEL_DETAILS if (printFuelDebug) { printf("fuel injectionDuration=%.2fms adjusted=%.2fms\n", - engine->engineState.injectionDuration, + getEngineState()->injectionDuration, injectionDuration); } #endif /*EFI_PRINTF_FUEL_DETAILS */ - bool isCranking = engine->rpmCalculator.isCranking(); + bool isCranking = getEngineRotationState()->isCranking(); /** * todo: pre-calculate 'numberOfInjections' * see also injectorDutyCycle @@ -205,7 +210,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase warning(CUSTOM_TOO_LONG_FUEL_INJECTION, "Too long fuel injection %.2fms", injectionDuration); } - engine->engineState.fuelConsumption.consumeFuel(injectionMassGrams * numberOfInjections, nowNt); + getEngineState()->fuelConsumption.consumeFuel(injectionMassGrams * numberOfInjections, nowNt); if (this->cylinderNumber == 0) { engine->outputChannels.actualLastInjection = injectionDuration;