mirror of https://github.com/FOME-Tech/fome-fw.git
Simplify fuel math again (#1117)
* return the scheduled time from scheduleByAngle * simplify fueling math
This commit is contained in:
parent
734963343d
commit
f5b90d3f30
|
@ -223,17 +223,6 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
|||
|
||||
floatus_t durationUs = MS2US(injectionDuration);
|
||||
|
||||
// How long until the injector should start to fire (SOI)
|
||||
floatus_t injectionStartDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * event->injectionStart.angleOffsetFromTriggerEvent;
|
||||
|
||||
#if EFI_DEFAILED_LOGGING
|
||||
scheduleMsg(logger, "handleFuel pin=%s eventIndex %d duration=%.2fms %d", event->outputs[0]->name,
|
||||
injEventIndex,
|
||||
injectionDuration,
|
||||
getRevolutionCounter());
|
||||
scheduleMsg(logger, "handleFuel pin=%s delay=%.2f %d", event->outputs[0]->name, injectionStartDelayUs,
|
||||
getRevolutionCounter());
|
||||
#endif /* EFI_DEFAILED_LOGGING */
|
||||
|
||||
// we are ignoring low RPM in order not to handle "engine was stopped to engine now running" transition
|
||||
if (rpm > 2 * engineConfiguration->cranking.rpm) {
|
||||
|
@ -261,9 +250,6 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
|||
|
||||
event->isScheduled = true;
|
||||
|
||||
efitick_t turnOnTime = nowNt + US2NT((int)injectionStartDelayUs);
|
||||
efitick_t turnOffTime = turnOnTime + US2NT((int)durationUs);
|
||||
|
||||
action_s startAction, endAction;
|
||||
// We use different callbacks based on whether we're running sequential mode or not - everything else is the same
|
||||
if (event->isSimultanious) {
|
||||
|
@ -275,11 +261,21 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
|||
endAction = { &turnInjectionPinLow, event };
|
||||
}
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", event->injectionStart.angleOffsetFromTriggerEvent, injectionStartDelayUs, injectionDuration);
|
||||
#endif
|
||||
engine->executor.scheduleByTimestampNt(&event->signalTimerUp, turnOnTime, startAction);
|
||||
efitick_t startTime = scheduleByAngle(&event->signalTimerUp, nowNt, event->injectionStart.angleOffsetFromTriggerEvent, startAction PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
efitick_t turnOffTime = startTime + US2NT((int)durationUs);
|
||||
engine->executor.scheduleByTimestampNt(&event->endOfInjectionEvent, turnOffTime, endAction);
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", event->injectionStart.angleOffsetFromTriggerEvent, NT2US(startTime - nowNt), injectionDuration);
|
||||
#endif
|
||||
#if EFI_DEFAILED_LOGGING
|
||||
scheduleMsg(logger, "handleFuel pin=%s eventIndex %d duration=%.2fms %d", event->outputs[0]->name,
|
||||
injEventIndex,
|
||||
injectionDuration,
|
||||
getRevolutionCounter());
|
||||
scheduleMsg(logger, "handleFuel pin=%s delay=%.2f %d", event->outputs[0]->name, NT2US(startTime - nowNt),
|
||||
getRevolutionCounter());
|
||||
#endif /* EFI_DEFAILED_LOGGING */
|
||||
}
|
||||
|
||||
static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
|
|
|
@ -360,7 +360,7 @@ void initRpmCalculator(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
* The callback would be executed once after the duration of time which
|
||||
* it takes the crankshaft to rotate to the specified angle.
|
||||
*/
|
||||
void scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle,
|
||||
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle,
|
||||
action_s action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
float delayUs = ENGINE(rpmCalculator.oneDegreeUs) * angle;
|
||||
|
||||
|
@ -368,6 +368,8 @@ void scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle
|
|||
efitime_t delayedTime = edgeTimestamp + delayNt;
|
||||
|
||||
ENGINE(executor.scheduleByTimestampNt(timer, delayedTime, action));
|
||||
|
||||
return delayedTime;
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -165,5 +165,5 @@ float getCrankshaftAngleNt(efitick_t timeNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
|||
#define addEngineSnifferEvent(n, msg) {}
|
||||
#endif /* EFI_ENGINE_SNIFFER */
|
||||
|
||||
void scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle, action_s action DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t edgeTimestamp, angle_t angle, action_s action DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
|
|
Loading…
Reference in New Issue