Minor ini and comms cleanup

This commit is contained in:
Josh Stewart 2017-08-24 17:24:28 +10:00
parent 630a3bfe2a
commit fc06ce4d1b
2 changed files with 26 additions and 31 deletions

View File

@ -293,7 +293,7 @@ page = 4
;Dwell control ;Dwell control
dwellcont = bits, U08, 12, [0:0], "INVALID", "Dwell control" dwellcont = bits, U08, 12, [0:0], "INVALID", "Dwell control"
useDwellLim= bits, U08, 12, [1:1], "Off", "On" useDwellLim= bits, U08, 12, [1:1], "Off", "On"
sparkMode = bits, U08, 12, [2:4], "Wasted Spark", "Single Channel", "Wasted COP", "Sequential", "Rotary", INVALID, INVALID, INVALID sparkMode = bits, U08, 12, [2:4], "Wasted Spark", "Single Channel", "Wasted COP", "Sequential", "Rotary", "INVALID", "INVALID", "INVALID"
TrigFilter = bits, U08, 12, [5:6], "Off", "Weak", "Medium", "Aggressive" TrigFilter = bits, U08, 12, [5:6], "Off", "Weak", "Medium", "Aggressive"
ignCranklock=bits, U08, 12, [7:7], "Off", "On" ignCranklock=bits, U08, 12, [7:7], "Off", "On"
dwellcrank = scalar, U08, 13, "ms", 0.1, 0, 0, 25, 1 dwellcrank = scalar, U08, 13, "ms", 0.1, 0, 0, 25, 1

View File

@ -62,15 +62,11 @@ void command()
if (Serial.available() > 0) if (Serial.available() > 0)
{ {
currentPage = Serial.read(); currentPage = Serial.read();
if (currentPage >= '0') {//This converts the ascii number char into binary //This converts the ascii number char into binary. Note that this will break everyything if there are ever more than 48 pages (48 = asci code for '0')
currentPage -= '0'; if (currentPage >= '0') { currentPage -= '0'; }
} // Detecting if the current page is a table/map
if ( (currentPage == veMapPage) || (currentPage == ignMapPage) || (currentPage == afrMapPage) ) { // Detecting if the current page is a table/map if ( (currentPage == veMapPage) || (currentPage == ignMapPage) || (currentPage == afrMapPage) ) { isMap = true; }
isMap = true; else { isMap = false; }
}
else {
isMap = false;
}
cmdPending = false; cmdPending = false;
} }
break; break;
@ -507,24 +503,23 @@ void receiveValue(int valueOffset, byte newValue)
break; break;
case seqFuelPage: case seqFuelPage:
{ int tempOffset;
int tempOffset; if (valueOffset < 36) { trim1Table.values[5 - (valueOffset / 6)][valueOffset % 6] = newValue; } //Trim1 values
if (valueOffset < 36) { trim1Table.values[5 - (valueOffset / 6)][valueOffset % 6] = newValue; } //Trim1 values else if (valueOffset < 42) { trim1Table.axisX[(valueOffset - 36)] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the trim1 table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
else if (valueOffset < 42) { trim1Table.axisX[(valueOffset - 36)] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the trim1 table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER) else if (valueOffset < 48) { trim1Table.axisY[(5 - (valueOffset - 42))] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (TPS) axis of the boost table
else if (valueOffset < 48) { trim1Table.axisY[(5 - (valueOffset - 42))] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (TPS) axis of the boost table //Trim table 2
//Trim table 2 else if (valueOffset < 84) { tempOffset = valueOffset - 48; trim2Table.values[5 - (tempOffset / 6)][tempOffset % 6] = newValue; } //New value is part of the trim2 map
else if (valueOffset < 84) { tempOffset = valueOffset - 48; trim2Table.values[5 - (tempOffset / 6)][tempOffset % 6] = newValue; } //New value is part of the trim2 map else if (valueOffset < 90) { tempOffset = valueOffset - 84; trim2Table.axisX[tempOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
else if (valueOffset < 90) { tempOffset = valueOffset - 84; trim2Table.axisX[tempOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER) else if (valueOffset < 96) { tempOffset = valueOffset - 90; trim2Table.axisY[(5 - tempOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
else if (valueOffset < 96) { tempOffset = valueOffset - 90; trim2Table.axisY[(5 - tempOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table //Trim table 3
//Trim table 3 else if (valueOffset < 132) { tempOffset = valueOffset - 96; trim3Table.values[5 - (tempOffset / 6)][tempOffset % 6] = newValue; } //New value is part of the trim2 map
else if (valueOffset < 132) { tempOffset = valueOffset - 96; trim3Table.values[5 - (tempOffset / 6)][tempOffset % 6] = newValue; } //New value is part of the trim2 map else if (valueOffset < 138) { tempOffset = valueOffset - 132; trim3Table.axisX[tempOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
else if (valueOffset < 138) { tempOffset = valueOffset - 132; trim3Table.axisX[tempOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER) else if (valueOffset < 144) { tempOffset = valueOffset - 138; trim3Table.axisY[(5 - tempOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
else if (valueOffset < 144) { tempOffset = valueOffset - 138; trim3Table.axisY[(5 - tempOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table //Trim table 4
//Trim table 4 else if (valueOffset < 180) { tempOffset = valueOffset - 144; trim4Table.values[5 - (tempOffset / 6)][tempOffset % 6] = newValue; } //New value is part of the trim2 map
else if (valueOffset < 180) { tempOffset = valueOffset - 144; trim4Table.values[5 - (tempOffset / 6)][tempOffset % 6] = newValue; } //New value is part of the trim2 map else if (valueOffset < 186) { tempOffset = valueOffset - 180; trim4Table.axisX[tempOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER)
else if (valueOffset < 186) { tempOffset = valueOffset - 180; trim4Table.axisX[tempOffset] = int(newValue) * TABLE_RPM_MULTIPLIER; } //New value is on the X (RPM) axis of the table. The RPM values sent by TunerStudio are divided by 100, need to multiply it back by 100 to make it correct (TABLE_RPM_MULTIPLIER) else if (valueOffset < 192) { tempOffset = valueOffset - 186; trim4Table.axisY[(5 - tempOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
else if (valueOffset < 192) { tempOffset = valueOffset - 186; trim4Table.axisY[(5 - tempOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
}
break; break;
case canbusPage: case canbusPage:
@ -536,7 +531,7 @@ void receiveValue(int valueOffset, byte newValue)
} }
break; break;
case warmupPage: //Idle Air Control settings page (Page 4) case warmupPage:
pnt_configPage = &configPage11; pnt_configPage = &configPage11;
//For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size //For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size
if (valueOffset < npage_size[currentPage]) if (valueOffset < npage_size[currentPage])
@ -940,7 +935,7 @@ void sendPage(bool useChar)
} }
else currentTitleIndex = 0; else currentTitleIndex = 0;
}while(currentTitleIndex == 132); //Should never loop unless going to display vvtTable }while(currentTitleIndex == 132); //Should never loop unless going to display vvtTable
} } //use char
else else
{ {
//Need to perform a translation of the values[yaxis][xaxis] into the MS expected format //Need to perform a translation of the values[yaxis][xaxis] into the MS expected format
@ -955,7 +950,7 @@ void sendPage(bool useChar)
//loop(); //loop();
Serial.write((byte *)&response, sizeof(response)); Serial.write((byte *)&response, sizeof(response));
} }
} } //is map
else else
{ {
/*if(useChar) /*if(useChar)