Further memory fixes for sequential trims

This commit is contained in:
Josh Stewart 2016-11-01 23:19:16 +11:00
parent 30a48dc364
commit 7aeff0cbda
3 changed files with 29 additions and 25 deletions

View File

@ -303,7 +303,7 @@ void receiveValue(int valueOffset, byte newValue)
//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 < page_size)
{
*((byte *)pnt_configPage + (byte)valueOffset) = newValue; //Need to subtract 80 because the map and bins (Which make up 80 bytes) aren't part of the config pages
*((byte *)pnt_configPage + (byte)valueOffset) = newValue;
}
break;
@ -432,6 +432,7 @@ void receiveValue(int valueOffset, byte newValue)
else if (valueOffset < 192) { valueOffset = valueOffset - 186; trim4Table.axisY[(5 - valueOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
break;
default:
break;
}
@ -666,11 +667,11 @@ void sendPage(bool useChar)
//Boost table
for (int x = 0; x < 64; x++) { response[x] = boostTable.values[7 - x / 8][x % 8]; }
for (int x = 64; x < 72; x++) { response[x] = byte(boostTable.axisX[(x - 64)] / 100); }
for (int x = 64; x < 72; x++) { response[x] = byte(boostTable.axisX[(x - 64)] / TABLE_RPM_MULTIPLIER); }
for (int y = 72; y < 80; y++) { response[y] = byte(boostTable.axisY[7 - (y - 72)]); }
//VVT table
for (int x = 0; x < 64; x++) { response[x + 80] = vvtTable.values[7 - x / 8][x % 8]; }
for (int x = 64; x < 72; x++) { response[x + 80] = byte(vvtTable.axisX[(x - 64)] / 100); }
for (int x = 64; x < 72; x++) { response[x + 80] = byte(vvtTable.axisX[(x - 64)] / TABLE_RPM_MULTIPLIER); }
for (int y = 72; y < 80; y++) { response[y + 80] = byte(vvtTable.axisY[7 - (y - 72)]); }
Serial.write((byte *)&response, sizeof(response));
return;
@ -792,12 +793,12 @@ void sendPage(bool useChar)
//MS format has origin (0,0) in the bottom left corner, we use the top left for efficiency reasons
byte response[map_page_size];
for (int x = 0; x < 256; x++) { response[x] = currentTable.values[15 - x / 16][x % 16]; if ( (x & 15) == 1) { loop(); } } //This is slightly non-intuitive, but essentially just flips the table vertically (IE top line becomes the bottom line etc). Columns are unchanged. Every 16 loops, manually call loop() to avoid potential misses
loop();
for (int x = 256; x < 272; x++) { response[x] = byte(currentTable.axisX[(x - 256)] / 100); } //RPM Bins for VE table (Need to be dvidied by 100)
loop();
for (int x = 0; x < 256; x++) { response[x] = currentTable.values[15 - x / 16][x % 16]; } //This is slightly non-intuitive, but essentially just flips the table vertically (IE top line becomes the bottom line etc). Columns are unchanged. Every 16 loops, manually call loop() to avoid potential misses
//loop();
for (int x = 256; x < 272; x++) { response[x] = byte(currentTable.axisX[(x - 256)] / TABLE_RPM_MULTIPLIER); } //RPM Bins for VE table (Need to be dvidied by 100)
//loop();
for (int y = 272; y < 288; y++) { response[y] = byte(currentTable.axisY[15 - (y - 272)]); } //MAP or TPS bins for VE table
loop();
//loop();
Serial.write((byte *)&response, sizeof(response));
}
}
@ -820,8 +821,9 @@ void sendPage(bool useChar)
for (byte x = 0; x < page_size; x++)
{
response[x] = *((byte *)pnt_configPage + x); //Each byte is simply the location in memory of the configPage + the offset + the variable number (x)
if ( (x & 31) == 1) { loop(); } //Every 32 loops, do a manual call to loop() to ensure that there is no misses
//if ( (x & 31) == 1) { loop(); } //Every 32 loops, do a manual call to loop() to ensure that there is no misses
}
Serial.write((byte *)&response, sizeof(response));
// }
}

View File

@ -226,6 +226,7 @@ struct config1 {
byte baroCorr : 1;
byte injLayout : 2;
byte canEnable : 1; //is can interface enabled
byte unused2_38h : 1;
byte primePulse;
byte dutyLim;

View File

@ -106,8 +106,8 @@
delayAfterPortOpen=1000
;validateArrayBounds = true
blockReadTimeout = 2000
;tsWriteBlocks = on
; writeBlocks = on
;tsWriteBlocks = off
;writeBlocks = off
interWriteDelay = 10
;Page 1 is the fuel map and axis bins only
@ -138,7 +138,7 @@ page = 2
aseCount = scalar, U08, 3, "s", 1.0, 0.0, 0.0, 255, 0
wueRates = array, U08, 4, [10], "%", 1.0, 0.0, 0.0, 255, 0
crankingPct= scalar, U08, 14, "%", 1.0, 0.0, 0.0, 255, 0
pinLayout = bits, U08, 15, [0:7], "Speeduino v0.1", "Speeduino v0.2", "Speeduino v0.3", "Speeduino v0.4", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "NA6 MX5 PNP", "Turtana PCB", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "Plazomat I/O 0.1", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "Daz V6 Shield 0.1", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID",
pinLayout = bits, U08, 15, [0:7], "Speeduino v0.1", "Speeduino v0.2", "Speeduino v0.3", "Speeduino v0.4", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "NA6 MX5 PNP", "Turtana PCB", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "Plazomat I/O 0.1", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "Daz V6 Shield 0.1", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
tachoPin = bits, U08, 16, [0:5], "Board Default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
unused2-16f= bits, U08, 16, [6:7], "One", "Two", "INVALID", "INVALID"
tdePct = scalar, U08, 17, "ms", 0.1, 0.0, 0.0, 25.5, 1
@ -183,20 +183,21 @@ page = 2
; Config2
cltType = bits, U08, 37, [0:1], "GM", "Unknown1", "Unknown2", "Unknown3"
matType = bits, U08, 37, [2:3], "GM", "Unknown1", "Unknown2", "Unknown3"
nInjectors = bits, U08, 37, [4:7+1]
nInjectors = bits, U08, 37, [4:7], "INVALID","1","2","3","4","INVALID","6","INVALID","8","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID","INVALID"
; Config3
engineType = bits, U08, 38, [0:0], "Even fire", "Odd fire"
flexEnabled= bits, U08, 38, [1:1], "Off", "On"
algorithm = bits, U08, 38, [2:2], "Speed Density", "Alpha-N"
baroCorr = bits, U08, 38, [3:3], "Off", "On"
injLayout = bits, U08, 38, [4:5], "Paired", "Semi-Sequential", "Bank", "Sequential"
injLayout = bits, U08, 38, [4:5], "Paired", "Semi-Sequential", "INVALID", "Sequential"
canEnable = bits, U08, 38, [6:6], "Disable", "Enable"
unused2-38h= bits, U08, 38, [7:7], "No", "Yes"
primePulse = scalar, U08, 39, "ms", 0.1, 0.0, 0.0, 25.5, 1
dutyLim = scalar, U08, 40, "%", 1.0, 0.0, 0.0, 100.0, 0
unused41 = scalar, U08, 41, "RPM", 100.0, 0.0, 100, 25500, 0
egoSwitch = scalar, U08, 42, "v", 0.0196, 0.0, 0.0, 5.0, 3
unused42 = scalar, U08, 42, "RPM", 100.0, 0.0, 100, 25500, 0
taeColdM = scalar, U08, 43, "%", 1.0, 0.0, 0.0, 250.0, 0
tpsMin = scalar, U08, 44, "ADC", 1.0, 0.0, 0.0, 255.0, 0
tpsMax = scalar, U08, 45, "ADC", 1.0, 0.0, 0.0, 255.0, 0
@ -204,9 +205,9 @@ page = 2
mapMax = scalar, U16, 47, "kpa", 1.0, 0.0, 0.0, 25500, 0
fpPrime = scalar, U08, 49, "s", 1.0, 0.0, 0.0, 255.0, 0
stoich = scalar, U08, 50, ":1", 0.1, 0.0, 0.0, 25.5, 1
oddfire2 = scalar, U16, 51, "", 1.0, 0.0, 0.0, 720, 0 ; * ( 2 byte)
oddfire3 = scalar, U16, 53, "", 1.0, 0.0, 0.0, 720, 0 ; * ( 2 byte)
oddfire4 = scalar, U16, 55, "", 1.0, 0.0, 0.0, 720, 0 ; * ( 2 byte)
oddfire2 = scalar, U16, 51, "deg", 1.0, 0.0, 0.0, 720, 0 ; * ( 2 byte)
oddfire3 = scalar, U16, 53, "deg", 1.0, 0.0, 0.0, 720, 0 ; * ( 2 byte)
oddfire4 = scalar, U16, 55, "deg", 1.0, 0.0, 0.0, 720, 0 ; * ( 2 byte)
unused2-57 = scalar, U08, 57, "RPM", 100.0, 0.0, 100, 25500, 0
unused2-58 = scalar, U08, 58, "RPM", 100.0, 0.0, 100, 25500, 0
unused2-59 = scalar, U08, 59, "RPM", 100.0, 0.0, 100, 25500, 0
@ -649,7 +650,7 @@ menuDialog = main
;subMenu = battcalib, "Calibrate Battery Voltage"
;subMenu = std_separator ;----------------------------------------------
;subMenu = flash_unlock, "Un/Lock calibrations"
subMenu = std_ms2gentherm, "Calibrate T&hermistor Tables", 0 ;, {flashlock}
subMenu = std_ms2gentherm, "Calibrate Thermistor Tables", 0 ;, {flashlock}
subMenu = std_ms2geno2, "Calibrate &AFR Table", 0;, {flashlock}
menuDialog = main
@ -673,14 +674,14 @@ menuDialog = main
nInjectors = "Number of primary injectors."
mapSample = "The method used for calculating the MAP reading\nFor 1-2 Cylinder engines, Cycle Minimum is recommended.\nFor more than 2 cylinders Cycle Average is recommended"
stoich = "The stoichiometric ration of the fuel being used. For flex fuel, choose the primary fuel"
injLayout = "The injector layout and timing to be used. Options are: \n 1. Paired - 2 injectors per output. Outputs active is equal to half the number of cylinders. Outputs are timed over 1 crank revolution. \n 2. Semi-sequential: Same as paired except that injector channels are mirrored (1&4, 2&3) meaning the number of outputs used are equal to the number of cylinders. Only valid for 4 cylinders or less. \n 3. Banked: 2 outputs only used. \n 4. Sequential: 1 injector per output and outputs used equals the number of cylinders. Injection is timed over full cycle.
injLayout = "The injector layout and timing to be used. Options are: \n 1. Paired - 2 injectors per output. Outputs active is equal to half the number of cylinders. Outputs are timed over 1 crank revolution. \n 2. Semi-sequential: Same as paired except that injector channels are mirrored (1&4, 2&3) meaning the number of outputs used are equal to the number of cylinders. Only valid for 4 cylinders or less. \n 3. Banked: 2 outputs only used. \n 4. Sequential: 1 injector per output and outputs used equals the number of cylinders. Injection is timed over full cycle. "
TrigPattern = "The type of input trigger decoder to be used."
numteeth = "Number of teeth on Primary Wheel."
TrigSpeed = "Primary trigger speed."
onetwo = "Number of Missing teeth on Primary Wheel."
TrigAng = "The Angle ATDC when tooth No:1 on the primary wheel passes the primary sensor."
TrigAngMul = "A multiplier used by non-360 degree tooth wheels (i.e. Wheels where the tooth count doesn't divide evenly into 360. Usage: (360 * <multiplier>) / tooth_count = Whole number
TrigAngMul = "A multiplier used by non-360 degree tooth wheels (i.e. Wheels where the tooth count doesn't divide evenly into 360. Usage: (360 * <multiplier>) / tooth_count = Whole number"
StgCycles = "The number of revolutions that will be skipped during cranking before the injectors and coils are fired."
TrigEdge = "The Trigger edge of the primary sensor.\nLeading.\nTrailing."
TrigFilter = "Tuning of the trigger filter algorithm. The more aggressive the setting, the more noise will be removed, however this increases the chance of some true readings being filtered out (False positive). Medium is safe for most setups. Only select 'Aggressive' if no other options are working"
@ -1019,7 +1020,7 @@ menuDialog = main
panel = inj_trim4TblTitle
dialog = inj_trimad,"Injector Cyl 1-4 Trims", yAxis
field = "Individual fuel trim enabled", fuelTrimEnabled
field = "Individual fuel trim enabled", fuelTrimEnabled, { injLayout == 3 }
panel = inj_trimadt, North
panel = inj_trimadb, South
@ -1531,7 +1532,7 @@ menuDialog = main
;cycleTime = { 60000.0 / rpm * (2.0-twoStroke) }
cycleTime = { 60000.0 / rpm }
nSquirts = { nCylinders/divider }
;nSquirts = { nCylinders/divider }
dutyCycle = { 100.0*pulseWidth/cycleTime }
boostCutOut = { boostCutFuel || boostCutSpark }