Cleanup of variable names and Enable check

This commit is contained in:
Josh Stewart 2017-03-15 23:19:08 +11:00
parent 74cf93b979
commit eb334b5a1c
4 changed files with 42 additions and 51 deletions

View File

@ -17,10 +17,10 @@
byte currentPage = 1;//Not the same as the speeduino config page numbers byte currentPage = 1;//Not the same as the speeduino config page numbers
boolean isMap = true; boolean isMap = true;
unsigned long requestCount = 0; //The number of times the A command has been issued unsigned long requestCount = 0; //The number of times the A command has been issued
byte cmdgroup = 0; byte cmdGroup = 0;
byte cmdvalue = 0; byte cmdValue = 0;
int cmdcombined = 0; //the cmdgroup as high byte and cmdvalue as low byte int cmdCombined = 0; //the cmdgroup as high byte and cmdvalue as low byte
byte cmdstore[8]; //array storing pre test values byte cmdStore[8]; //array storing pre test values
const char pageTitles[] PROGMEM //This is being stored in the avr flash instead of SRAM which there is not very much of const char pageTitles[] PROGMEM //This is being stored in the avr flash instead of SRAM which there is not very much of
{ {
@ -44,6 +44,6 @@ void sendPage(bool useChar);
void receiveCalibration(byte tableID); void receiveCalibration(byte tableID);
void sendToothLog(bool useChar); void sendToothLog(bool useChar);
void testComm(); void testComm();
void commandbuttons(); void commandButtons();
#endif // COMMS_H #endif // COMMS_H

View File

@ -31,11 +31,12 @@ void command()
case 'E': // receive command button commands case 'E': // receive command button commands
while (Serial.available() == 0) { } while (Serial.available() == 0) { }
cmdgroup = Serial.read(); cmdGroup = Serial.read();
while (Serial.available() == 0) { } while (Serial.available() == 0) { }
cmdvalue = Serial.read(); cmdValue = Serial.read();
cmdcombined = word(cmdgroup, cmdvalue); cmdCombined = word(cmdGroup, cmdValue);
commandbuttons(); if (currentStatus.RPM == 0) { commandButtons(); }
break; break;
case 'L': // List the contents of current page in human readable form case 'L': // List the contents of current page in human readable form
@ -271,7 +272,7 @@ void sendValues(int packetlength, byte portNum)
response[35] = currentStatus.flexIgnCorrection; //Ignition correction (Increased degrees of advance) for flex fuel response[35] = currentStatus.flexIgnCorrection; //Ignition correction (Increased degrees of advance) for flex fuel
response[36] = getNextError(); response[36] = getNextError();
response[37] = currentStatus.boostTarget; response[37] = currentStatus.boostTarget;
response[38] = currentStatus.testoutputs; response[38] = currentStatus.testOutputs;
//cli(); //cli();
if (portNum == 0) { Serial.write(response, (size_t)packetlength); } if (portNum == 0) { Serial.write(response, (size_t)packetlength); }
@ -1038,12 +1039,12 @@ void testComm()
return; return;
} }
void commandbuttons() void commandButtons()
{ {
switch (cmdcombined) switch (cmdCombined)
{ {
case 256: // cmd is stop case 256: // cmd is stop
BIT_CLEAR(currentStatus.testoutputs, 1); BIT_CLEAR(currentStatus.testOutputs, 1);
digitalWrite(pinInjector1, LOW); digitalWrite(pinInjector1, LOW);
digitalWrite(pinInjector2, LOW); digitalWrite(pinInjector2, LOW);
digitalWrite(pinInjector3, LOW); digitalWrite(pinInjector3, LOW);
@ -1055,14 +1056,14 @@ void commandbuttons()
break; break;
case 257: // cmd is enable case 257: // cmd is enable
// currentStatus.testactive = 1; // currentStatus.testactive = 1;
BIT_SET(currentStatus.testoutputs, 1); BIT_SET(currentStatus.testOutputs, 1);
break; break;
case 513: // cmd group is for injector1 on actions case 513: // cmd group is for injector1 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinInjector1, HIGH);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector1, HIGH);}
break; break;
case 514: // cmd group is for injector1 off actions case 514: // cmd group is for injector1 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinInjector1, LOW);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector1, LOW);}
break; break;
case 515: // cmd group is for injector1 50% dc actions case 515: // cmd group is for injector1 50% dc actions
//for (byte dcloop = 0; dcloop < 11; dcloop++) //for (byte dcloop = 0; dcloop < 11; dcloop++)
@ -1074,68 +1075,67 @@ void commandbuttons()
//} //}
break; break;
case 516: // cmd group is for injector2 on actions case 516: // cmd group is for injector2 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinInjector2, HIGH);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector2, HIGH);}
break; break;
case 517: // cmd group is for injector2 off actions case 517: // cmd group is for injector2 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinInjector2, LOW);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector2, LOW);}
break; break;
case 518: // cmd group is for injector2 50%dc actions case 518: // cmd group is for injector2 50%dc actions
break; break;
case 519: // cmd group is for injector3 on actions case 519: // cmd group is for injector3 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinInjector3, HIGH);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector3, HIGH);}
break; break;
case 520: // cmd group is for injector3 off actions case 520: // cmd group is for injector3 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinInjector3, LOW);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector3, LOW);}
break; break;
case 521: // cmd group is for injector3 50%dc actions case 521: // cmd group is for injector3 50%dc actions
break; break;
case 522: // cmd group is for injector4 on actions case 522: // cmd group is for injector4 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinInjector4, HIGH);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector4, HIGH);}
break; break;
case 523: // cmd group is for injector4 off actions case 523: // cmd group is for injector4 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinInjector4, LOW);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector4, LOW);}
break; break;
case 524: // cmd group is for injector4 50% dc actions case 524: // cmd group is for injector4 50% dc actions
break; break;
case 769: // cmd group is for spark1 on actions case 769: // cmd group is for spark1 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil1, HIGH);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil1, HIGH);}
break; break;
case 770: // cmd group is for spark1 off actions case 770: // cmd group is for spark1 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil1, LOW);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil1, LOW);}
break; break;
case 771: // cmd group is for spark1 50%dc actions case 771: // cmd group is for spark1 50%dc actions
break; break;
case 772: // cmd group is for spark2 on actions case 772: // cmd group is for spark2 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil2, HIGH);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil2, HIGH);}
break; break;
case 773: // cmd group is for spark2 off actions case 773: // cmd group is for spark2 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil2, LOW);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil2, LOW);}
break; break;
case 774: // cmd group is for spark2 50%dc actions case 774: // cmd group is for spark2 50%dc actions
break; break;
case 775: // cmd group is for spark3 on actions case 775: // cmd group is for spark3 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil3, HIGH);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil3, HIGH);}
break; break;
case 776: // cmd group is for spark3 off actions case 776: // cmd group is for spark3 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil3, LOW);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil3, LOW);}
break; break;
case 777: // cmd group is for spark3 50%dc actions case 777: // cmd group is for spark3 50%dc actions
break; break;
case 778: // cmd group is for spark4 on actions case 778: // cmd group is for spark4 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil4, HIGH);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil4, HIGH);}
break; break;
case 779: // cmd group is for spark4 off actions case 779: // cmd group is for spark4 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil4, LOW);} if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil4, LOW);}
break; break;
case 780: // cmd group is for spark4 50%dc actions case 780: // cmd group is for spark4 50%dc actions
break; break;
} }
} }

View File

@ -206,9 +206,8 @@ struct statuses {
bool flatShiftingHard; bool flatShiftingHard;
volatile byte startRevolutions; //A counter for how many revolutions have been completed since sync was achieved. volatile byte startRevolutions; //A counter for how many revolutions have been completed since sync was achieved.
byte boostTarget; byte boostTarget;
byte testoutputs; byte testOutputs;
bool testenabled; bool testActive;
bool testactive;
//Helpful bitwise operations: //Helpful bitwise operations:
//Useful reference: http://playground.arduino.cc/Code/BitMath //Useful reference: http://playground.arduino.cc/Code/BitMath

View File

@ -906,14 +906,6 @@ void loop()
//The IAT and CLT readings can be done less frequently. This still runs about 4 times per second //The IAT and CLT readings can be done less frequently. This still runs about 4 times per second
if ((mainLoopCount & 255) == 1) //Every 256 loops if ((mainLoopCount & 255) == 1) //Every 256 loops
{ {
if (currentStatus.RPM == 0)
{
BIT_CLEAR(currentStatus.testenabled, 0); //cleared when engine is off or stalled
}
else
{
BIT_SET(currentStatus.testenabled, 0); //set if engine is running/cranking
}
readCLT(); readCLT();
readIAT(); readIAT();
readO2(); readO2();