comments & improve logic

This commit is contained in:
Matthew Kennedy 2020-07-16 23:55:41 -07:00
parent c21b60eeb8
commit f06b2c2edd
2 changed files with 13 additions and 2 deletions

View File

@ -165,8 +165,14 @@ void RpmCalculator::setRpmValue(float value DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_ENGINE_CONTROL
// This presumably fixes injection mode change for cranking-to-running transition.
// 'isSimultanious' flag should be updated for events if injection modes differ for cranking and running.
if (state != oldState) {
if (state != oldState && CONFIG(crankingInjectionMode) != CONFIG(injectionMode)) {
// Reset the state of all injectors: when we change fueling modes, we could
// immediately reschedule an injection that's currently underway. That will cause
// the injector's overlappingCounter to get out of sync with reality. As the fix,
// every injector's state is forcibly reset just before we could cause that to happen.
engine->injectionEvents.resetOverlapping();
// reschedule all injection events now that we've reset them
engine->injectionEvents.addFuelEvents(PASS_ENGINE_PARAMETER_SIGNATURE);
}
#endif

View File

@ -277,7 +277,12 @@ bool NamedOutputPin::stop() {
}
void InjectorOutputPin::reset() {
overlappingCounter = 0;
// If this injector was open, close it and reset state
if (overlappingCounter != 0) {
overlappingCounter = 0;
setValue(0);
}
// todo: this could be refactored by calling some super-reset method
currentLogicValue = INITIAL_PIN_STATE;
}