From e5f2193abeab18f7f0e624f33cf7ae01f7b4d832 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Wed, 22 Apr 2020 11:02:35 +1000 Subject: [PATCH] Introduce command button handler and expand the hardware testing to 8 channels --- reference/speeduino.ini | 109 ++++++---- speeduino/TS_CommandButtonHandler.h | 58 ++++++ speeduino/TS_CommandButtonHandler.ino | 286 ++++++++++++++++++++++++++ speeduino/comms.ino | 207 +------------------ speeduino/globals.h | 10 +- speeduino/sensors.ino | 1 + 6 files changed, 423 insertions(+), 248 deletions(-) create mode 100644 speeduino/TS_CommandButtonHandler.h create mode 100644 speeduino/TS_CommandButtonHandler.ino diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 17ac0d8c..1f97a0cc 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -1797,7 +1797,7 @@ menuDialog = main commandButton = "Set Gear 5", cmdVSSratio5, {vssEnable} dialog = vss_gear_6, "", xAxis field = "Speed ratio 6", vssRatio6 - commandButton = "Set Gear 6", cmdVSSratio1, {vssEnable} + commandButton = "Set Gear 6", cmdVSSratio6, {vssEnable} dialog = vss_gear_detection, "Gear Detection", yAxis field = "After setting 'Pulses per km/mile' above" @@ -2364,7 +2364,7 @@ menuDialog = main ; The rem > 0 expression is just for testing.. It works when the arduino is on the Stim with rpm. ; a status bit there would be the expected real expression - commandButton = "Enable Test Mode", cmdEnableTestMode,{!testenabled & !testactive } + commandButton = "Enable Test Mode", cmdEnableTestMode,{!testenabled && !testactive } ; if clickOnCloseIfEnabled is set, then the command assigned to this button will be run on the ; dialog close, but only if the enable condition is true @@ -2376,36 +2376,36 @@ menuDialog = main dialog = outputtestinj1, "Injector CH1", yAxis commandButton = "Off", cmdtestinj1off,{testactive} - commandButton = "50% DC", cmdtestinj150dc,{!testenabled & testactive & 0} + commandButton = "50% DC", cmdtestinj150dc,{!testenabled && testactive && 0} commandButton = "On", cmdtestinj1on,{!testenabled & testactive} dialog = outputtestinj2, "Injector CH2", yAxis - commandButton = "Off", cmdtestinj2off,{testactive} - commandButton = "50% DC", cmdtestinj250dc,{!testenabled &testactive & 0} - commandButton = "On", cmdtestinj2on,{!testenabled & testactive} + commandButton = "Off", cmdtestinj2off,{testactive && nFuelChannels >= 2 } + commandButton = "50% DC", cmdtestinj250dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestinj2on,{ !testenabled && testactive && nFuelChannels >= 2 } dialog = outputtestinj3, "Injector CH3", yAxis - commandButton = "Off", cmdtestinj3off,{testactive} - commandButton = "50% DC", cmdtestinj350dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestinj3on,{!testenabled & testactive} + commandButton = "Off", cmdtestinj3off,{ testactive && nFuelChannels >= 3 } + commandButton = "50% DC", cmdtestinj350dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestinj3on,{ !testenabled && testactive && nFuelChannels >= 3 } dialog = outputtestinj4, "Injector CH4", yAxis - commandButton = "Off", cmdtestinj4off,{testactive} - commandButton = "50% DC", cmdtestinj450dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestinj4on ,{!testenabled & testactive} + commandButton = "Off", cmdtestinj4off,{ testactive && nFuelChannels >= 4 } + commandButton = "50% DC", cmdtestinj450dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestinj4on ,{ !testenabled && testactive && nFuelChannels >= 4 } dialog = outputtestinj5, "Injector CH5", yAxis - commandButton = "Off", cmdtestinj5off,{testactive} - commandButton = "50% DC", cmdtestinj550dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestinj5on,{!testenabled & testactive} + commandButton = "Off", cmdtestinj5off,{ testactive && nFuelChannels >= 5 } + commandButton = "50% DC", cmdtestinj550dc,{!testenabled && testactive & 0} + commandButton = "On", cmdtestinj5on,{ !testenabled && testactive && nFuelChannels >= 5 } dialog = outputtestinj6, "Injector CH6", yAxis - commandButton = "Off", cmdtestinj6off,{testactive} - commandButton = "50% DC", cmdtestinj650dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestinj6on ,{!testenabled & testactive} + commandButton = "Off", cmdtestinj6off,{ testactive && nFuelChannels >= 6 } + commandButton = "50% DC", cmdtestinj650dc,{!testenabled && testactive & 0} + commandButton = "On", cmdtestinj6on ,{ !testenabled & testactive && nFuelChannels >= 6 } dialog = outputtestinj7, "Injector CH7", yAxis - commandButton = "Off", cmdtestinj7off,{testactive} - commandButton = "50% DC", cmdtestinj750dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestinj7on,{!testenabled & testactive} + commandButton = "Off", cmdtestinj7off,{ testactive && nFuelChannels >= 7 } + commandButton = "50% DC", cmdtestinj750dc,{!testenabled && testactive & 0} + commandButton = "On", cmdtestinj7on,{ !testenabled && testactive && nFuelChannels >= 7 } dialog = outputtestinj8, "Injector CH8", yAxis - commandButton = "Off", cmdtestinj8off,{testactive} - commandButton = "50% DC", cmdtestinj850dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestinj8on ,{!testenabled & testactive} + commandButton = "Off", cmdtestinj8off,{ testactive && nFuelChannels >= 8 } + commandButton = "50% DC", cmdtestinj850dc,{!testenabled && testactive & 0} + commandButton = "On", cmdtestinj8on ,{ !testenabled & testactive && nFuelChannels >= 8 } dialog = outputtest_injectors, "Injector Driver Output Test", xAxis panel = outputtestinj1 @@ -2419,26 +2419,46 @@ menuDialog = main dialog = outputtestspk1, "Spark CH1 ", yAxis commandButton = "Off", cmdtestspk1off,{testactive} - commandButton = "50% DC", cmdtestspk150dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestspk1on,{!testenabled & testactive} - dialog = outputtestspk2, "Spark CH2", yAxis - commandButton = "Off", cmdtestspk2off,{testactive} - commandButton = "50% DC", cmdtestspk250dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestspk2on,{!testenabled & testactive} - dialog = outputtestspk3, "Spark CH3", yAxis - commandButton = "Off", cmdtestspk3off,{testactive} - commandButton = "50% DC", cmdtestspk350dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestspk3on,{!testenabled & testactive} + commandButton = "50% DC", cmdtestspk150dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestspk1on,{!testenabled && testactive} + dialog = outputtestspk2, "Spark CH2", yAxis + commandButton = "Off", cmdtestspk2off,{testactive && nIgnChannels >= 2 } + commandButton = "50% DC", cmdtestspk250dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestspk2on,{ !testenabled && testactive && nIgnChannels >= 2 } + dialog = outputtestspk3, "Spark CH3", yAxis + commandButton = "Off", cmdtestspk3off,{testactive && nIgnChannels >= 3 } + commandButton = "50% DC", cmdtestspk350dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestspk3on,{ !testenabled && testactive && nIgnChannels >= 3 } dialog = outputtestspk4, "Spark CH4", yAxis - commandButton = "Off", cmdtestspk4off,{testactive} - commandButton = "50% DC", cmdtestspk450dc,{!testenabled & testactive & 0} - commandButton = "On", cmdtestspk4on,{!testenabled & testactive} + commandButton = "Off", cmdtestspk4off,{testactive && nIgnChannels >= 4 } + commandButton = "50% DC", cmdtestspk450dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestspk4on,{ !testenabled && testactive && nIgnChannels >= 4 } + dialog = outputtestspk5, "Spark CH5", yAxis + commandButton = "Off", cmdtestspk5off,{testactive && nIgnChannels >= 5 } + commandButton = "50% DC", cmdtestspk550dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestspk5on,{ !testenabled && testactive && nIgnChannels >= 5 } + dialog = outputtestspk6, "Spark CH6", yAxis + commandButton = "Off", cmdtestspk6off,{testactive && nIgnChannels >= 6 } + commandButton = "50% DC", cmdtestspk650dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestspk6on,{ !testenabled && testactive && nIgnChannels >= 6 } + dialog = outputtestspk7, "Spark CH7", yAxis + commandButton = "Off", cmdtestspk7off,{testactive && nIgnChannels >= 7 } + commandButton = "50% DC", cmdtestspk750dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestspk7on,{ !testenabled && testactive && nIgnChannels >= 7 } + dialog = outputtestspk8, "Spark CH8", yAxis + commandButton = "Off", cmdtestspk8off,{testactive && nIgnChannels >= 8 } + commandButton = "50% DC", cmdtestspk850dc,{!testenabled && testactive && 0} + commandButton = "On", cmdtestspk8on,{ !testenabled && testactive && nIgnChannels >= 8 } dialog = outputtest_spark, "Spark Driver Output Test", xAxis panel = outputtestspk1 panel = outputtestspk2 panel = outputtestspk3 panel = outputtestspk4 + panel = outputtestspk5 + panel = outputtestspk6 + panel = outputtestspk7 + panel = outputtestspk8 dialog = outputtest1,"Test Output Hardware" topicHelp = "https://wiki.speeduino.com/en/Hardware_testing_page" @@ -3037,7 +3057,20 @@ cmdtestspk350dc = "E\x03\x09" cmdtestspk4on = "E\x03\x0A" cmdtestspk4off = "E\x03\x0B" cmdtestspk450dc = "E\x03\x0C" +cmdtestspk5on = "E\x03\x0D" +cmdtestspk5off = "E\x03\x0E" +cmdtestspk550dc = "E\x03\x0F" +cmdtestspk6on = "E\x03\x10" +cmdtestspk6off = "E\x03\x11" +cmdtestspk650dc = "E\x03\x12" +cmdtestspk7on = "E\x03\x13" +cmdtestspk7off = "E\x03\x14" +cmdtestspk750dc = "E\x03\x15" +cmdtestspk8on = "E\x03\x16" +cmdtestspk8off = "E\x03\x17" +cmdtestspk850dc = "E\x03\x18" +cmdVSS50kmh = "E\x99\x00" cmdVSSratio1 = "E\x99\x01" cmdVSSratio2 = "E\x99\x02" cmdVSSratio3 = "E\x99\x03" @@ -3695,7 +3728,7 @@ cmdVSSratio6 = "E\x99\x06" pulseLimit = { cycleTime / nSquirts } nFuelChannels = { arrayValue( array.boardFuelOutputs, pinLayout ) } - nIgnChannels = { arrayValue( array.boardIgnOutputs, pinLayout ) } + nIgnChannels = { arrayValue( array.boardIgnOutputs, pinLayout ) } sequentialFuelAvailable = { nCylinders <= nFuelChannels } sequentialIgnitionAvailable = { nCylinders <= nIgnChannels } diff --git a/speeduino/TS_CommandButtonHandler.h b/speeduino/TS_CommandButtonHandler.h new file mode 100644 index 00000000..c61df0dd --- /dev/null +++ b/speeduino/TS_CommandButtonHandler.h @@ -0,0 +1,58 @@ + +/** \file + * Header file for the TunerStudio command handler + * The command handler manages all the inputs FROM TS which are issued when a command button is clicked by the user + */ + +#define TS_CMD_INJ1_ON 513 +#define TS_CMD_INJ1_OFF 514 +#define TS_CMD_INJ1_50PC 515 +#define TS_CMD_INJ2_ON 516 +#define TS_CMD_INJ2_OFF 517 +#define TS_CMD_INJ2_50PC 518 +#define TS_CMD_INJ3_ON 519 +#define TS_CMD_INJ3_OFF 520 +#define TS_CMD_INJ3_50PC 521 +#define TS_CMD_INJ4_ON 522 +#define TS_CMD_INJ4_OFF 523 +#define TS_CMD_INJ4_50PC 524 +#define TS_CMD_INJ5_ON 525 +#define TS_CMD_INJ5_OFF 526 +#define TS_CMD_INJ5_50PC 527 +#define TS_CMD_INJ6_ON 528 +#define TS_CMD_INJ6_OFF 529 +#define TS_CMD_INJ6_50PC 530 +#define TS_CMD_INJ7_ON 531 +#define TS_CMD_INJ7_OFF 532 +#define TS_CMD_INJ7_50PC 533 +#define TS_CMD_INJ8_ON 534 +#define TS_CMD_INJ8_OFF 535 +#define TS_CMD_INJ8_50PC 536 + +#define TS_CMD_IGN1_ON 769 +#define TS_CMD_IGN1_OFF 770 +#define TS_CMD_IGN1_50PC 771 +#define TS_CMD_IGN2_ON 772 +#define TS_CMD_IGN2_OFF 773 +#define TS_CMD_IGN2_50PC 774 +#define TS_CMD_IGN3_ON 775 +#define TS_CMD_IGN3_OFF 776 +#define TS_CMD_IGN3_50PC 777 +#define TS_CMD_IGN4_ON 778 +#define TS_CMD_IGN4_OFF 779 +#define TS_CMD_IGN4_50PC 780 +#define TS_CMD_IGN5_ON 781 +#define TS_CMD_IGN5_OFF 782 +#define TS_CMD_IGN5_50PC 783 +#define TS_CMD_IGN6_ON 784 +#define TS_CMD_IGN6_OFF 785 +#define TS_CMD_IGN6_50PC 786 +#define TS_CMD_IGN7_ON 787 +#define TS_CMD_IGN7_OFF 788 +#define TS_CMD_IGN7_50PC 789 +#define TS_CMD_IGN8_ON 790 +#define TS_CMD_IGN8_OFF 791 +#define TS_CMD_IGN8_50PC 792 + + +void TS_CommandButtonsHandler(int); \ No newline at end of file diff --git a/speeduino/TS_CommandButtonHandler.ino b/speeduino/TS_CommandButtonHandler.ino new file mode 100644 index 00000000..cf85bbc0 --- /dev/null +++ b/speeduino/TS_CommandButtonHandler.ino @@ -0,0 +1,286 @@ + +/** \file + * Header file for the TunerStudio command handler + * The command handler manages all the inputs FROM TS which are issued when a command button is clicked by the user + */ + +#include "TS_CommandButtonHandler.h" +#include "globals.h" +#include "utils.h" +#include "scheduledIO.h" + +void TS_CommandButtonsHandler(int buttonCommand) +{ + switch (buttonCommand) + { + case 256: // cmd is stop + BIT_CLEAR(currentStatus.testOutputs, 1); + endCoil1Charge(); + endCoil2Charge(); + endCoil3Charge(); + endCoil4Charge(); + closeInjector1(); + closeInjector2(); + closeInjector3(); + closeInjector4(); + #if INJ_CHANNELS >= 5 + closeInjector5(); + #endif + #if INJ_CHANNELS >= 6 + closeInjector6(); + #endif + #if INJ_CHANNELS >= 7 + closeInjector7(); + #endif + #if INJ_CHANNELS >= 8 + closeInjector8(); + #endif + break; + + case 257: // cmd is enable + // currentStatus.testactive = 1; + BIT_SET(currentStatus.testOutputs, 1); + break; + + case TS_CMD_INJ1_ON: // cmd group is for injector1 on actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector1(); } + break; + + case TS_CMD_INJ1_OFF: // cmd group is for injector1 off actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector1(); } + break; + + case TS_CMD_INJ1_50PC: // cmd group is for injector1 50% dc actions + //for (byte dcloop = 0; dcloop < 11; dcloop++) + //{ + // digitalWrite(pinInjector1, HIGH); + // delay(500); + // digitalWrite(pinInjector1, LOW); + // delay(500); + //} + break; + + case TS_CMD_INJ2_ON: // cmd group is for injector2 on actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector2(); } + break; + + case TS_CMD_INJ2_OFF: // cmd group is for injector2 off actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector2(); } + break; + + case TS_CMD_INJ2_50PC: // cmd group is for injector2 50%dc actions + + break; + + case TS_CMD_INJ3_ON: // cmd group is for injector3 on actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector3(); } + break; + + case TS_CMD_INJ3_OFF: // cmd group is for injector3 off actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector3(); } + break; + + case TS_CMD_INJ3_50PC: // cmd group is for injector3 50%dc actions + + break; + + case TS_CMD_INJ4_ON: // cmd group is for injector4 on actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector4(); } + break; + + case TS_CMD_INJ4_OFF: // cmd group is for injector4 off actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector4(); } + break; + + case TS_CMD_INJ4_50PC: // cmd group is for injector4 50% dc actions + + break; + + case TS_CMD_INJ5_ON: // cmd group is for injector5 on actions + #if INJ_CHANNELS >= 5 + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector5(); } + #endif + break; + + case TS_CMD_INJ5_OFF: // cmd group is for injector5 off actions + #if INJ_CHANNELS >= 5 + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector5(); } + #endif + break; + + case TS_CMD_INJ5_50PC: // cmd group is for injector5 50%dc actions + + break; + + case TS_CMD_INJ6_ON: // cmd group is for injector6 on actions + #if INJ_CHANNELS >= 6 + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector6(); } + #endif + break; + + case TS_CMD_INJ6_OFF: // cmd group is for injector6 off actions + #if INJ_CHANNELS >= 6 + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector6(); } + #endif + break; + + case TS_CMD_INJ6_50PC: // cmd group is for injector6 50% dc actions + + break; + + case TS_CMD_INJ7_ON: // cmd group is for injector7 on actions + #if INJ_CHANNELS >= 7 + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector7(); } + #endif + break; + + case TS_CMD_INJ7_OFF: // cmd group is for injector7 off actions + #if INJ_CHANNELS >= 7 + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector7(); } + #endif + break; + + case TS_CMD_INJ7_50PC: // cmd group is for injector7 50%dc actions + + break; + + case TS_CMD_INJ8_ON: // cmd group is for injector8 on actions + #if INJ_CHANNELS >= 8 + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector8(); } + #endif + break; + + case TS_CMD_INJ8_OFF: // cmd group is for injector8 off actions + #if INJ_CHANNELS >= 8 + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector8(); } + #endif + break; + + case TS_CMD_INJ8_50PC: // cmd group is for injector8 50% dc actions + + break; + + case TS_CMD_IGN1_ON: // cmd group is for spark1 on actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { beginCoil1Charge(); } + break; + + case TS_CMD_IGN1_OFF: // cmd group is for spark1 off actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil1Charge(); } + break; + + case TS_CMD_IGN1_50PC: // cmd group is for spark1 50%dc actions + + break; + + case TS_CMD_IGN2_ON: // cmd group is for spark2 on actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { beginCoil2Charge(); } + break; + + case TS_CMD_IGN2_OFF: // cmd group is for spark2 off actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil2Charge(); } + break; + + case TS_CMD_IGN2_50PC: // cmd group is for spark2 50%dc actions + + break; + + case TS_CMD_IGN3_ON: // cmd group is for spark3 on actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { beginCoil3Charge(); } + break; + + case TS_CMD_IGN3_OFF: // cmd group is for spark3 off actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil3Charge(); } + break; + + case TS_CMD_IGN3_50PC: // cmd group is for spark3 50%dc actions + + break; + + case TS_CMD_IGN4_ON: // cmd group is for spark4 on actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { beginCoil4Charge(); } + break; + + case TS_CMD_IGN4_OFF: // cmd group is for spark4 off actions + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil4Charge(); } + break; + + case TS_CMD_IGN4_50PC: // cmd group is for spark4 50%dc actions + + break; + + case TS_CMD_IGN5_ON: // cmd group is for spark5 on actions + #if IGN_CHANNELS >= 5 + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { beginCoil5Charge(); } + #endif + break; + + case TS_CMD_IGN5_OFF: // cmd group is for spark5 off actions + #if IGN_CHANNELS >= 5 + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil5Charge(); } + #endif + break; + + case TS_CMD_IGN5_50PC: // cmd group is for spark4 50%dc actions + #if IGN_CHANNELS >= 5 + + #endif + break; + + case TS_CMD_IGN6_ON: // cmd group is for spark6 on actions + #if IGN_CHANNELS >= 6 + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { beginCoil6Charge(); } + #endif + break; + + case TS_CMD_IGN6_OFF: // cmd group is for spark6 off actions + #if IGN_CHANNELS >= 6 + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil6Charge(); } + #endif + break; + + case TS_CMD_IGN6_50PC: // cmd group is for spark6 50%dc actions + #if IGN_CHANNELS >= 6 + + #endif + break; + + case TS_CMD_IGN7_ON: // cmd group is for spark7 on actions + #if IGN_CHANNELS >= 7 + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { beginCoil7Charge(); } + #endif + break; + + case TS_CMD_IGN7_OFF: // cmd group is for spark7 off actions + #if IGN_CHANNELS >= 7 + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil7Charge(); } + #endif + break; + + case TS_CMD_IGN7_50PC: // cmd group is for spark7 50%dc actions + #if IGN_CHANNELS >= 7 + + #endif + break; + + case TS_CMD_IGN8_ON: // cmd group is for spark8 on actions + #if IGN_CHANNELS >= 8 + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { beginCoil8Charge(); } + #endif + break; + + case TS_CMD_IGN8_OFF: // cmd group is for spark8 off actions + #if IGN_CHANNELS >= 8 + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil8Charge(); } + #endif + break; + + case TS_CMD_IGN8_50PC: // cmd group is for spark8 50%dc actions + #if IGN_CHANNELS >= 8 + + #endif + break; + + default: + break; + } +} \ No newline at end of file diff --git a/speeduino/comms.ino b/speeduino/comms.ino index 54f454ee..1c87f1f9 100644 --- a/speeduino/comms.ino +++ b/speeduino/comms.ino @@ -10,7 +10,7 @@ A full copy of the license may be found in the projects root directory #include "maths.h" #include "utils.h" #include "decoders.h" -#include "scheduledIO.h" +#include "TS_CommandButtonHandler.h" #include "logger.h" #include "errors.h" @@ -96,7 +96,7 @@ void command() byte cmdGroup = Serial.read(); byte cmdValue = Serial.read(); int cmdCombined = word(cmdGroup, cmdValue); - if (currentStatus.RPM == 0) { commandButtons(cmdCombined); } + if (currentStatus.RPM == 0) { TS_CommandButtonsHandler(cmdCombined); } cmdPending = false; } @@ -1824,206 +1824,3 @@ void testComm() return; } -void commandButtons(int buttonCommand) -{ - switch (buttonCommand) - { - case 256: // cmd is stop - BIT_CLEAR(currentStatus.testOutputs, 1); - endCoil1Charge(); - endCoil2Charge(); - endCoil3Charge(); - endCoil4Charge(); - closeInjector1(); - closeInjector2(); - closeInjector3(); - closeInjector4(); - #if INJ_CHANNELS >= 5 - closeInjector5(); - #endif - #if INJ_CHANNELS >= 6 - closeInjector6(); - #endif - #if INJ_CHANNELS >= 7 - closeInjector7(); - #endif - #if INJ_CHANNELS >= 8 - closeInjector8(); - #endif - break; - - case 257: // cmd is enable - // currentStatus.testactive = 1; - BIT_SET(currentStatus.testOutputs, 1); - break; - - case 513: // cmd group is for injector1 on actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector1(); } - break; - - case 514: // cmd group is for injector1 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector1(); } - break; - - case 515: // cmd group is for injector1 50% dc actions - //for (byte dcloop = 0; dcloop < 11; dcloop++) - //{ - // digitalWrite(pinInjector1, HIGH); - // delay(500); - // digitalWrite(pinInjector1, LOW); - // delay(500); - //} - break; - - case 516: // cmd group is for injector2 on actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector2(); } - break; - - case 517: // cmd group is for injector2 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector2(); } - break; - - case 518: // cmd group is for injector2 50%dc actions - - break; - - case 519: // cmd group is for injector3 on actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector3(); } - break; - - case 520: // cmd group is for injector3 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector3(); } - break; - - case 521: // cmd group is for injector3 50%dc actions - - break; - - case 522: // cmd group is for injector4 on actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector4(); } - break; - - case 523: // cmd group is for injector4 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector4(); } - break; - - case 524: // cmd group is for injector4 50% dc actions - - break; - - case 525: // cmd group is for injector5 on actions - #if INJ_CHANNELS >= 5 - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector5(); } - #endif - break; - - case 526: // cmd group is for injector5 off actions - #if INJ_CHANNELS >= 5 - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector5(); } - #endif - break; - - case 527: // cmd group is for injector5 50%dc actions - - break; - - case 528: // cmd group is for injector6 on actions - #if INJ_CHANNELS >= 6 - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector6(); } - #endif - break; - - case 529: // cmd group is for injector6 off actions - #if INJ_CHANNELS >= 6 - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector6(); } - #endif - break; - - case 530: // cmd group is for injector6 50% dc actions - - break; - - case 531: // cmd group is for injector5 on actions - #if INJ_CHANNELS >= 7 - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector7(); } - #endif - break; - - case 532: // cmd group is for injector5 off actions - #if INJ_CHANNELS >= 7 - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector7(); } - #endif - break; - - case 533: // cmd group is for injector5 50%dc actions - - break; - - case 534: // cmd group is for injector6 on actions - #if INJ_CHANNELS >= 8 - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ openInjector8(); } - #endif - break; - - case 535: // cmd group is for injector6 off actions - #if INJ_CHANNELS >= 8 - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector8(); } - #endif - break; - - case 536: // cmd group is for injector6 50% dc actions - - break; - - case 769: // cmd group is for spark1 on actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { digitalWrite(pinCoil1, coilHIGH); } - break; - - case 770: // cmd group is for spark1 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { digitalWrite(pinCoil1, coilLOW); } - break; - - case 771: // cmd group is for spark1 50%dc actions - - break; - - case 772: // cmd group is for spark2 on actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { digitalWrite(pinCoil2, coilHIGH); } - break; - - case 773: // cmd group is for spark2 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { digitalWrite(pinCoil2, coilLOW); } - break; - - case 774: // cmd group is for spark2 50%dc actions - - break; - - case 775: // cmd group is for spark3 on actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { digitalWrite(pinCoil3, coilHIGH); } - break; - - case 776: // cmd group is for spark3 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { digitalWrite(pinCoil3, coilLOW); } - break; - - case 777: // cmd group is for spark3 50%dc actions - - break; - - case 778: // cmd group is for spark4 on actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { digitalWrite(pinCoil4, coilHIGH); } - break; - - case 779: // cmd group is for spark4 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { digitalWrite(pinCoil4, coilLOW); } - break; - - case 780: // cmd group is for spark4 50%dc actions - - break; - - default: - break; - } -} diff --git a/speeduino/globals.h b/speeduino/globals.h index fd07e943..4551483c 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -654,12 +654,12 @@ struct config2 { byte vssSmoothing; uint16_t vssRatio1; uint16_t vssRatio2; - byte vssRatio3; - byte vssRatio4; - byte vssRatio5; - byte vssRatio6; + uint16_t vssRatio3; + uint16_t vssRatio4; + uint16_t vssRatio5; + uint16_t vssRatio6; - byte unused2_95[14]; + byte unused2_95[10]; #if defined(CORE_AVR) }; diff --git a/speeduino/sensors.ino b/speeduino/sensors.ino index 634292bb..da32d55c 100644 --- a/speeduino/sensors.ino +++ b/speeduino/sensors.ino @@ -10,6 +10,7 @@ A full copy of the license may be found in the projects root directory #include "storage.h" #include "comms.h" #include "idle.h" +#include "corrections.h" void initialiseADC() {