Merge pull request #1 from noisymime/master

Update 20151013
This commit is contained in:
ConnerMcLaughlin 2015-10-13 13:50:58 -05:00
commit 84c0f542e1
4 changed files with 583 additions and 549 deletions

View File

@ -42,9 +42,15 @@ void command()
//This loop should never need to run as the byte should already be in the buffer, but is here just in case
while (Serial.available() == 0) { }
currentPage = Serial.read();
if(currentPage >= '0') {currentPage -= '0';}
if(currentPage == veMapPage || currentPage == ignMapPage || currentPage == afrMapPage) {isMap = true;}
else{isMap = false;}
if (currentPage >= '0') {
currentPage -= '0';
}
if (currentPage == veMapPage || currentPage == ignMapPage || currentPage == afrMapPage) {
isMap = true;
}
else {
isMap = false;
}
break;
case 'R': // send 39 bytes of realtime values
@ -194,7 +200,7 @@ void sendValues(int length)
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
response[3] = 0x00; //baro
response[3] = (byte)(divu100(currentStatus.dwell)); //Dwell in ms * 10
response[4] = currentStatus.MAP; //map
response[5] = (byte)(currentStatus.IAT + CALIBRATION_TEMPERATURE_OFFSET); //mat
response[6] = (byte)(currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //Coolant ADC
@ -389,6 +395,7 @@ void receiveValue(int offset, byte newValue)
sendPage() packs the data within the current page (As set with the 'P' command)
into a buffer and sends it.
Note that some translation of the data is required to lay it out in the way Megasqurit / TunerStudio expect it
useChar - If true, all values are send as chars, this is for the serial command line interface. TunerStudio expects data as raw values, so this must be set false in that case
*/
void sendPage(bool useChar)
{
@ -419,7 +426,9 @@ void sendPage(bool useChar)
Serial.print(' ');
}
Serial.println();
for(pnt_configPage=(byte *)&configPage1.wueValues[9]+1;pnt_configPage<&configPage1.inj1Ang;pnt_configPage=(byte *)pnt_configPage+1) Serial.println(*((byte *)pnt_configPage));
for (pnt_configPage = (byte *)&configPage1.wueValues[9] + 1; pnt_configPage < &configPage1.inj1Ang; pnt_configPage = (byte *)pnt_configPage + 1) {
Serial.println(*((byte *)pnt_configPage));
}
for (pnt_configPage = &configPage1.inj1Ang; pnt_configPage < (unsigned int *)&configPage1.inj4Ang + 1; pnt_configPage = (unsigned int *)pnt_configPage + 1) Serial.println(*((unsigned int *)pnt_configPage));
for (pnt_configPage = (unsigned int *)&configPage1.inj4Ang + 1; pnt_configPage < (byte *)&configPage1 + page_size; pnt_configPage = (byte *)pnt_configPage + 1) Serial.println(*((byte *)pnt_configPage));
return;
@ -443,12 +452,18 @@ void sendPage(bool useChar)
//To Display Values from Config Page 2
Serial.println((const __FlashStringHelper *)&pageTitles[56]);
Serial.println(configPage2.triggerAngle);
for (pnt_configPage = (int *)&configPage2 + 1; pnt_configPage < &configPage2.taeBins[0]; pnt_configPage = (byte *)pnt_configPage + 1) Serial.println(*((byte *)pnt_configPage));
for (byte y = 2; y; y--)
{
byte * currentVar;
if(y==2) currentVar=configPage2.taeBins;
else currentVar=configPage2.taeValues;
if (y == 2) {
currentVar = configPage2.taeBins;
}
else {
currentVar = configPage2.taeValues;
}
for (byte x = 4; x; x--)
{
Serial.print(currentVar[4 - x]);
@ -469,7 +484,10 @@ void sendPage(bool useChar)
Serial.print(' ');
}
Serial.println();
for(pnt_configPage=(byte *)&configPage2.dwellCorrectionValues[5]+1;pnt_configPage<(byte *)&configPage2+page_size;pnt_configPage=(byte *)pnt_configPage+1) Serial.println(*((byte *)pnt_configPage));
for (pnt_configPage = (byte *)&configPage2.dwellCorrectionValues[5] + 1; pnt_configPage < (byte *)&configPage2 + page_size; pnt_configPage = (byte *)pnt_configPage + 1)
{
Serial.println(*((byte *)pnt_configPage));
}
return;
}
else pnt_configPage = &configPage2; //Create a pointer to Page 2 in memory
@ -490,12 +508,16 @@ void sendPage(bool useChar)
{
//To Display Values from Config Page 3
Serial.println((const __FlashStringHelper *)&pageTitles[91]);
for(pnt_configPage=&configPage3;pnt_configPage<&configPage3.voltageCorrectionBins[0];pnt_configPage=(byte *)pnt_configPage+1) Serial.println(*((byte *)pnt_configPage));
for (pnt_configPage = &configPage3; pnt_configPage < &configPage3.voltageCorrectionBins[0]; pnt_configPage = (byte *)pnt_configPage + 1)
{
Serial.println(*((byte *)pnt_configPage));
}
for (byte y = 2; y; y--)
{
byte * currentVar;
if(y==2) currentVar=configPage3.voltageCorrectionBins;
else currentVar=configPage3.injVoltageCorrectionValues;
if (y == 2) { currentVar = configPage3.voltageCorrectionBins; }
else { currentVar = configPage3.injVoltageCorrectionValues; }
for (byte x = 6; x; x--)
{
Serial.print(currentVar[6 - x]);
@ -515,7 +537,10 @@ void sendPage(bool useChar)
}
Serial.println();
}
for(pnt_configPage=(byte *)&configPage3.airDenRates[8]+1;pnt_configPage<(byte *)&configPage3+page_size;pnt_configPage=(byte *)pnt_configPage+1) Serial.println(*((byte *)pnt_configPage));
for (pnt_configPage = (byte *)&configPage3.airDenRates[8] + 1; pnt_configPage < (byte *)&configPage3 + page_size; pnt_configPage = (byte *)pnt_configPage + 1)
{
Serial.println(*((byte *)pnt_configPage));
}
return;
}
else pnt_configPage = &configPage3; //Create a pointer to Page 3 in memory
@ -570,6 +595,7 @@ void sendPage(bool useChar)
else pnt_configPage = &configPage4; //Create a pointer to Page 4 in memory
break;
}
case boostvvtPage:
{
//Need to perform a translation of the values[MAP/TPS][RPM] into the MS expected format
@ -749,8 +775,12 @@ void receiveCalibration(byte tableID)
if (every2nd) //Only use every 2nd value
{
if (tempValue > 255) { tempValue = 255; } // Cap the maximum value to prevent overflow when converting to byte
if (tempValue < 0) { tempValue = 0; }
if (tempValue > 255) {
tempValue = 255; // Cap the maximum value to prevent overflow when converting to byte
}
if (tempValue < 0) {
tempValue = 0;
}
pnt_TargetTable[(x / 2)] = (byte)tempValue;
int y = EEPROM_CALIBRATION_O2 + counter;
@ -759,7 +789,9 @@ void receiveCalibration(byte tableID)
analogWrite(13, (counter % 50) );
counter++;
}
else { every2nd = true; }
else {
every2nd = true;
}
}
@ -774,7 +806,9 @@ void sendToothLog(bool useChar)
{
//We need 256 records to send to TunerStudio. If there aren't that many in the buffer (Buffer is 512 long) then we just return and wait for the next call
if (toothHistoryIndex < 256) { return; } //Don't believe this is the best way to go. Just display whatever is in the buffer
if (toothHistoryIndex < 256) {
return; //Don't believe this is the best way to go. Just display whatever is in the buffer
}
unsigned int tempToothHistory[512]; //Create a temporary array that will contain a copy of what is in the main toothHistory array
//Copy the working history into the temporary buffer array. This is done so that, if the history loops whilst the values are being sent over serial, it doesn't affect the values
@ -797,7 +831,7 @@ void sendToothLog(bool useChar)
Serial.write(lowByte(tempToothHistory[x]));
}
}
Serial.flush();
//Serial.flush();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 KiB