From 9c663a75b9f4aade44cc30badd875bd46eb24e16 Mon Sep 17 00:00:00 2001 From: Teemo Vaas <36799067+TBAMax@users.noreply.github.com> Date: Sat, 3 Feb 2024 08:25:20 +0200 Subject: [PATCH] Add check for running schedules (#1134) Add check for running schedules. So that switching from half to full sync only happens when there is no schedules currently running. This prevents possibility of some outputs sticking open for whole engine cycle immediately after switching. --- speeduino/init.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/speeduino/init.cpp b/speeduino/init.cpp index 3c57ff51..97e82f06 100644 --- a/speeduino/init.cpp +++ b/speeduino/init.cpp @@ -3722,6 +3722,32 @@ static inline bool isAnyFuelScheduleRunning(void) { ; } +static inline bool isAnyIgnScheduleRunning(void) { + return ignitionSchedule1.Status==RUNNING +#if IGN_CHANNELS >= 2 + || ignitionSchedule2.Status==RUNNING +#endif +#if IGN_CHANNELS >= 3 + || ignitionSchedule3.Status==RUNNING +#endif +#if IGN_CHANNELS >= 4 + || ignitionSchedule4.Status==RUNNING +#endif +#if IGN_CHANNELS >= 5 + || ignitionSchedule5.Status==RUNNING +#endif +#if IGN_CHANNELS >= 6 + || ignitionSchedule6.Status==RUNNING +#endif +#if IGN_CHANNELS >= 7 + || ignitionSchedule7.Status==RUNNING +#endif +#if IGN_CHANNELS >= 8 + || ignitionSchedule8.Status==RUNNING +#endif + ; +} + /** Change injectors or/and ignition angles to 720deg. * Roll back req_fuel size and set number of outputs equal to cylinder count. * */ @@ -3781,7 +3807,7 @@ void changeHalfToFullSync(void) interrupts(); //Need to do another check for sparkMode as this function can be called from injection - if( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) && (CRANK_ANGLE_MAX_IGN != 720) ) + if( (configPage4.sparkMode == IGN_MODE_SEQUENTIAL) && (CRANK_ANGLE_MAX_IGN != 720) && (!isAnyIgnScheduleRunning()) ) { CRANK_ANGLE_MAX_IGN = 720; maxIgnOutputs = configPage2.nCylinders;