tear down Engine god object #4511

oh I hope this ends well
This commit is contained in:
rusefillc 2022-09-15 23:41:06 -04:00
parent 3104538022
commit 61134b452a
4 changed files with 19 additions and 6 deletions

View File

@ -552,3 +552,11 @@ TriggerCentral * getTriggerCentral() {
LimpManager * getLimpManager() { LimpManager * getLimpManager() {
return &engine->limpManager; return &engine->limpManager;
} }
FuelSchedule *getFuelSchedule() {
return &engine->injectionEvents;
}
IgnitionEventList *getIgnitionEvents() {
return &engine->ignitionEvents;
}

View File

@ -82,3 +82,6 @@ public:
AngleBasedEvent open; AngleBasedEvent open;
AngleBasedEvent close; AngleBasedEvent close;
}; };
IgnitionEventList *getIgnitionEvents();

View File

@ -83,3 +83,5 @@ public:
InjectionEvent elements[MAX_CYLINDER_COUNT]; InjectionEvent elements[MAX_CYLINDER_COUNT];
bool isReady = false; bool isReady = false;
}; };
FuelSchedule * getFuelSchedule();

View File

@ -56,7 +56,7 @@
void endSimultaneousInjection(InjectionEvent *event) { void endSimultaneousInjection(InjectionEvent *event) {
event->isScheduled = false; event->isScheduled = false;
endSimultaneousInjectionOnlyTogglePins(); endSimultaneousInjectionOnlyTogglePins();
engine->injectionEvents.addFuelEventsForCylinder(event->ownIndex); getFuelSchedule()->addFuelEventsForCylinder(event->ownIndex);
} }
void turnInjectionPinLow(InjectionEvent *event) { void turnInjectionPinLow(InjectionEvent *event) {
@ -69,7 +69,7 @@ void turnInjectionPinLow(InjectionEvent *event) {
output->close(nowNt); output->close(nowNt);
} }
} }
engine->injectionEvents.addFuelEventsForCylinder(event->ownIndex); getFuelSchedule()->addFuelEventsForCylinder(event->ownIndex);
} }
static bool isPhaseInRange(float test, float current, float next) { static bool isPhaseInRange(float test, float current, float next) {
@ -229,7 +229,7 @@ static void handleFuel(uint32_t trgEventIndex, int rpm, efitick_t nowNt, float c
engine->tpsAccelEnrichment.onEngineCycleTps(); engine->tpsAccelEnrichment.onEngineCycleTps();
} }
LimpState limitedFuelState = engine->limpManager.allowInjection(); LimpState limitedFuelState = getLimpManager()->allowInjection();
engine->outputChannels.fuelCutReason = (int8_t)limitedFuelState.reason; engine->outputChannels.fuelCutReason = (int8_t)limitedFuelState.reason;
bool limitedFuel = !limitedFuelState.value; bool limitedFuel = !limitedFuelState.value;
if (limitedFuel) { if (limitedFuel) {
@ -240,7 +240,7 @@ static void handleFuel(uint32_t trgEventIndex, int rpm, efitick_t nowNt, float c
* Injection events are defined by addFuelEvents() according to selected * Injection events are defined by addFuelEvents() according to selected
* fueling strategy * fueling strategy
*/ */
FuelSchedule *fs = &engine->injectionEvents; FuelSchedule *fs = getFuelSchedule();
if (!fs->isReady) { if (!fs->isReady) {
fs->addFuelEvents(); fs->addFuelEvents();
} }
@ -289,8 +289,8 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_
if (trgEventIndex == 0) { if (trgEventIndex == 0) {
if (getTriggerCentral()->checkIfTriggerConfigChanged()) { if (getTriggerCentral()->checkIfTriggerConfigChanged()) {
engine->ignitionEvents.isReady = false; // we need to rebuild complete ignition schedule getIgnitionEvents()->isReady = false; // we need to rebuild complete ignition schedule
engine->injectionEvents.isReady = false; getFuelSchedule()->isReady = false;
// moved 'triggerIndexByAngle' into trigger initialization (why was it invoked from here if it's only about trigger shape & optimization?) // moved 'triggerIndexByAngle' into trigger initialization (why was it invoked from here if it's only about trigger shape & optimization?)
// see updateTriggerWaveform() -> prepareOutputSignals() // see updateTriggerWaveform() -> prepareOutputSignals()