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
boolean isMap = true;
unsigned long requestCount = 0; //The number of times the A command has been issued
byte cmdgroup = 0;
byte cmdvalue = 0;
int cmdcombined = 0; //the cmdgroup as high byte and cmdvalue as low byte
byte cmdstore[8]; //array storing pre test values
byte cmdGroup = 0;
byte cmdValue = 0;
int cmdCombined = 0; //the cmdgroup as high byte and cmdvalue as low byte
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
{
@ -44,6 +44,6 @@ void sendPage(bool useChar);
void receiveCalibration(byte tableID);
void sendToothLog(bool useChar);
void testComm();
void commandbuttons();
void commandButtons();
#endif // COMMS_H

View File

@ -28,16 +28,17 @@ void command()
case 'C': // test communications. This is used by Tunerstudio to see whether there is an ECU on a given serial port
testComm();
break;
case 'E': // receive command button commands
while (Serial.available() == 0) { }
cmdgroup = Serial.read();
cmdGroup = Serial.read();
while (Serial.available() == 0) { }
cmdvalue = Serial.read();
cmdcombined = word(cmdgroup, cmdvalue);
commandbuttons();
cmdValue = Serial.read();
cmdCombined = word(cmdGroup, cmdValue);
if (currentStatus.RPM == 0) { commandButtons(); }
break;
case 'L': // List the contents of current page in human readable form
sendPage(true);
break;
@ -271,7 +272,7 @@ void sendValues(int packetlength, byte portNum)
response[35] = currentStatus.flexIgnCorrection; //Ignition correction (Increased degrees of advance) for flex fuel
response[36] = getNextError();
response[37] = currentStatus.boostTarget;
response[38] = currentStatus.testoutputs;
response[38] = currentStatus.testOutputs;
//cli();
if (portNum == 0) { Serial.write(response, (size_t)packetlength); }
@ -1038,12 +1039,12 @@ void testComm()
return;
}
void commandbuttons()
void commandButtons()
{
switch (cmdcombined)
switch (cmdCombined)
{
case 256: // cmd is stop
BIT_CLEAR(currentStatus.testoutputs, 1);
BIT_CLEAR(currentStatus.testOutputs, 1);
digitalWrite(pinInjector1, LOW);
digitalWrite(pinInjector2, LOW);
digitalWrite(pinInjector3, LOW);
@ -1053,16 +1054,16 @@ void commandbuttons()
digitalWrite(pinCoil3, LOW);
digitalWrite(pinCoil4, LOW);
break;
case 257: // cmd is enable
// currentStatus.testactive = 1;
BIT_SET(currentStatus.testoutputs, 1);
break;
// currentStatus.testactive = 1;
BIT_SET(currentStatus.testOutputs, 1);
break;
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;
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;
case 515: // cmd group is for injector1 50% dc actions
//for (byte dcloop = 0; dcloop < 11; dcloop++)
@ -1074,68 +1075,67 @@ void commandbuttons()
//}
break;
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;
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;
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)){digitalWrite(pinInjector3, HIGH);}
if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector3, HIGH);}
break;
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;
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)){digitalWrite(pinInjector4, HIGH);}
if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinInjector4, HIGH);}
break;
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;
case 524: // cmd group is for injector4 50% dc actions
break;
case 769: // cmd group is for spark1 on actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil1, HIGH);}
break;
if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil1, HIGH);}
break;
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;
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, HIGH);}
if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil2, HIGH);}
break;
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;
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, HIGH);}
if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil3, HIGH);}
break;
case 776: // cmd group is for spark3 off actions
if(BIT_CHECK(currentStatus.testoutputs, 1)){digitalWrite(pinCoil3, LOW);}
break;
if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil3, LOW);}
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, HIGH);}
if(BIT_CHECK(currentStatus.testOutputs, 1)){digitalWrite(pinCoil4, HIGH);}
break;
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;
case 780: // cmd group is for spark4 50%dc actions
break;
}
}
}

View File

@ -206,10 +206,9 @@ struct statuses {
bool flatShiftingHard;
volatile byte startRevolutions; //A counter for how many revolutions have been completed since sync was achieved.
byte boostTarget;
byte testoutputs;
bool testenabled;
bool testactive;
byte testOutputs;
bool testActive;
//Helpful bitwise operations:
//Useful reference: http://playground.arduino.cc/Code/BitMath
// y = (x >> n) & 1; // n=0..15. stores nth bit of x in y. y becomes 0 or 1.

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
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();
readIAT();
readO2();