CLI ascii boost and vvt table view

This commit is contained in:
ConnerMcLaughlin 2016-09-11 18:12:01 -05:00 committed by GitHub
parent fe65f4bddd
commit afad30ff34
2 changed files with 92 additions and 42 deletions

View File

@ -22,7 +22,9 @@ const char pageTitles[] PROGMEM //This is being stored in the avr flash instead
"\nPage 2 Config\0"
"\nAir/Fuel Ratio Map\0"
"\nPage 3 Config\0"
"\nPage 4 Config"//No need to put a trailing null because it's the last string and the compliler does it for you.
"\nPage 4 Config\0"
"\nBoost Map\0"
"\nVVT Map"//No need to put a trailing null because it's the last string and the compliler does it for you.
};
void command();//This is the heart of the Command Line Interpeter. All that needed to be done was to make it human readable.
@ -34,4 +36,4 @@ void receiveCalibration(byte tableID);
void sendToothLog(bool useChar);
void testComm();
#endif // COMMS_H
#endif // COMMS_H

128
comms.ino
View File

@ -45,7 +45,7 @@ void command()
if (currentPage >= '0') {//This converts the ascii number char into binary
currentPage -= '0';
}
if (currentPage == veMapPage || currentPage == ignMapPage || currentPage == afrMapPage) {// Detecting if the current page is a table/map
if (currentPage == veMapPage || currentPage == ignMapPage || currentPage == afrMapPage || currentPage == boostvvtPage) {// Detecting if the current page is a table/map
isMap = true;
}
else {
@ -62,14 +62,39 @@ void command()
break;
case 'S': // send code version
Serial.print("Speeduino 2016.09");
//Serial.print(signature);
//break;
/*
char titleString[18];
strcat(titleString, displaySignature);
strcat(titleString, " ");
strcat(titleString, TSfirmwareVersion);
//Serial.print(titleString);
//Serial.write(titleString,16);
*/
Serial.print("Speeduino 2016.08");
currentStatus.secl = 0; //This is required in TS3 due to its stricter timings
break;
case 'Q': // send code signature
Serial.print("speeduino 201609-dev");
case 'Q': // send code version
Serial.print("speeduino 201608");
//Serial.print(signature);
//Serial.write(signature);
break;
//The following requires TunerStudio 3
/*
strcat(titleString, signature);
strcat(titleString, " ");
strcat(titleString, TSfirmwareVersion);
Serial.write(titleString,19);
break;
*/
case 'V': // send VE table and constants in binary
sendPage(false);
break;
@ -206,8 +231,6 @@ void sendValues(int length)
if(requestCount == 0) { currentStatus.secl = 0; }
requestCount++;
currentStatus.spark ^= (-currentStatus.hasSync ^ currentStatus.spark) & (1 << BIT_SPARK_SYNC); //Set the sync bit of the Spark variable to match the hasSync variable
response[0] = currentStatus.secl; //secl is simply a counter that increments each second. Used to track unexpected resets (Which will reset this count to 0)
response[1] = currentStatus.squirt; //Squirt Bitfield
response[2] = currentStatus.engine; //Engine Status Bitfield
@ -628,7 +651,12 @@ void sendPage(bool useChar)
case boostvvtPage:
{
if(!useChar)
if(useChar)
{
currentTable = boostTable;
currentTitleIndex = 121;
}
else
{
//Need to perform a translation of the values[MAP/TPS][RPM] into the MS expected format
byte response[160]; //Bit hacky, but the size is: (8x8 + 8 + 8) + (8x8 + 8 + 8) = 160
@ -644,6 +672,7 @@ void sendPage(bool useChar)
Serial.write((byte *)&response, sizeof(response));
return;
}
break;
}
default:
{
@ -656,49 +685,68 @@ void sendPage(bool useChar)
{
if (useChar)
{
const char spaceChar = ' ';
/*while(pageTitles[currentTitleIndex])
do
{
Serial.print(pageTitles[currentTitleIndex]);
currentTitleIndex++;
}*/
Serial.println((const __FlashStringHelper *)&pageTitles[currentTitleIndex]);// F macro hack
Serial.print(F("\n "));
for (int x = 0; x < currentTable.xSize; x++)// Horizontal bins
{
byte axisX = byte(currentTable.axisX[x] / 100);
if (axisX < 100)
const char spaceChar = ' ';
/*while(pageTitles[currentTitleIndex])
{
Serial.write(spaceChar);
if (axisX < 10)
Serial.print(pageTitles[currentTitleIndex]);
currentTitleIndex++;
}*/
Serial.println((const __FlashStringHelper *)&pageTitles[currentTitleIndex]);// F macro hack
Serial.println();
for (int y = 0; y < currentTable.ySize; y++)
{
byte axisY = byte(currentTable.axisY[y]);
if (axisY < 100)
{
Serial.write(spaceChar);
}
}
Serial.print(axisX);
Serial.write(spaceChar);
}
Serial.println();
for (int y = 0; y < currentTable.ySize; y++)
{
Serial.print(byte(currentTable.axisY[y]));// Vertical Bins
Serial.write(spaceChar);
for (int x = 0; x < currentTable.xSize; x++)
{
byte value = currentTable.values[y][x];
if (value < 100)
{
Serial.write(spaceChar);
if (value < 10)
if (axisY < 10)
{
Serial.write(spaceChar);
}
}
Serial.print(value);
Serial.print(axisY);// Vertical Bins
Serial.write(spaceChar);
for (int x = 0; x < currentTable.xSize; x++)
{
byte value = currentTable.values[y][x];
if (value < 100)
{
Serial.write(spaceChar);
if (value < 10)
{
Serial.write(spaceChar);
}
}
Serial.print(value);
Serial.write(spaceChar);
}
Serial.println();
}
Serial.print(F(" "));
for (int x = 0; x < currentTable.xSize; x++)// Horizontal bins
{
byte axisX = byte(currentTable.axisX[x] / 100);
if (axisX < 100)
{
Serial.write(spaceChar);
if (axisX < 10)
{
Serial.write(spaceChar);
}
}
Serial.print(axisX);
Serial.write(spaceChar);
}
Serial.println();
}
if(currentTitleIndex == 121)
{
currentTitleIndex = 132;
currentTable = vvtTable;
}
else currentTitleIndex = 0;
}while(currentTitleIndex == 132);
}
else
{
@ -869,4 +917,4 @@ void testComm()
{
Serial.write(1);
return;
}
}