From 55c98cab220c111dd717dcd4a9efa4fadf563cd0 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Fri, 6 Oct 2023 20:43:15 +1100 Subject: [PATCH] Allow mega2560 builds with non-standard _CHANNELS values --- speeduino/init.cpp | 9 ++++++--- speeduino/speeduino.ino | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/speeduino/init.cpp b/speeduino/init.cpp index 9dc88683e6..b0672443a1 100644 --- a/speeduino/init.cpp +++ b/speeduino/init.cpp @@ -746,7 +746,9 @@ void initialiseAll(void) channel2IgnDegrees = 72; channel3IgnDegrees = 144; channel4IgnDegrees = 216; +#if (IGN_CHANNELS >= 5) channel5IgnDegrees = 288; +#endif maxIgnOutputs = 5; //Only 4 actual outputs, so that's all that can be cut maxInjOutputs = 4; //Is updated below to 5 if there are enough channels @@ -755,7 +757,9 @@ void initialiseAll(void) channel2IgnDegrees = 144; channel3IgnDegrees = 288; channel4IgnDegrees = 432; +#if (IGN_CHANNELS >= 5) channel5IgnDegrees = 576; +#endif CRANK_ANGLE_MAX_IGN = 720; } @@ -879,9 +883,8 @@ void initialiseAll(void) channel8InjDegrees = channel4InjDegrees; #else //This is an invalid config as there are not enough outputs to support sequential + staging - //Put the staging output to the non-existant channel 7 - maxInjOutputs = 7; - channel7InjDegrees = channel1InjDegrees; + //No staging output will be active + maxInjOutputs = 6; #endif } } diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index 5032024a5d..70ff07a10f 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -1405,7 +1405,9 @@ void calculateIgnitionAngles(int dwellAngle) calculateIgnitionAngle(dwellAngle, channel2IgnDegrees, currentStatus.advance, &ignition2EndAngle, &ignition2StartAngle); calculateIgnitionAngle(dwellAngle, channel3IgnDegrees, currentStatus.advance, &ignition3EndAngle, &ignition3StartAngle); calculateIgnitionAngle(dwellAngle, channel4IgnDegrees, currentStatus.advance, &ignition4EndAngle, &ignition4StartAngle); + #if (IGN_CHANNELS >= 5) calculateIgnitionAngle(dwellAngle, channel5IgnDegrees, currentStatus.advance, &ignition5EndAngle, &ignition5StartAngle); + #endif break; //6 cylinders case 6: