EEPROM save and load for boost and vvt tables

This commit is contained in:
Josh Stewart 2015-09-25 21:02:15 +10:00
parent 2d1d2b5cce
commit a4c2a71508
2 changed files with 75 additions and 1 deletions

View File

@ -72,6 +72,7 @@ Current layout of EEPROM data (Version 3) is as follows (All sizes are in bytes)
#define EEPROM_CONFIG8_MAP2 1211
#define EEPROM_CONFIG8_XBINS2 1275
#define EEPROM_CONFIG8_YBINS2 1283
#define EEPROM_CONFIG8_END 1291
//Calibration data is stored at the end of the EEPROM (This is in case any further calibration tables are needed as they are large blocks)
#define EEPROM_CALIBRATION_O2 2559

View File

@ -156,6 +156,46 @@ void writeConfig()
{
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))); }
}
/*---------------------------------------------------
| Boost and vvt tables (See storage.h for data layout) - Page 8
| 8x8 table itself + the 8 values along each of the axis
-----------------------------------------------------*/
//Begin writing the 2 tables, basically the same thing as above but we're doing these 2 together (2 tables per page instead of 1)
if(EEPROM.read(EEPROM_CONFIG8_XSIZE1) != boostTable.xSize) { EEPROM.write(EEPROM_CONFIG8_XSIZE1,boostTable.xSize); } //Write the boost Table RPM dimension size
if(EEPROM.read(EEPROM_CONFIG8_YSIZE1) != boostTable.ySize) { EEPROM.write(EEPROM_CONFIG8_YSIZE1,boostTable.ySize); } //Write the boost Table MAP/TPS dimension size
if(EEPROM.read(EEPROM_CONFIG8_XSIZE2) != vvtTable.xSize) { EEPROM.write(EEPROM_CONFIG8_XSIZE2,vvtTable.xSize); } //Write the vvt Table RPM dimension size
if(EEPROM.read(EEPROM_CONFIG8_YSIZE2) != vvtTable.ySize) { EEPROM.write(EEPROM_CONFIG8_YSIZE2,vvtTable.ySize); } //Write the vvt Table MAP/TPS dimension size
int y = EEPROM_CONFIG8_MAP2; //We do the 2 maps together in the same loop
for(int x=EEPROM_CONFIG8_MAP1; x<EEPROM_CONFIG8_XBINS1; x++)
{
offset = x - EEPROM_CONFIG8_MAP1;
if(EEPROM.read(x) != boostTable.values[7-offset/8][offset%8]) { EEPROM.write(x, boostTable.values[7-offset/8][offset%8]); } //Write the 8x8 map
offset = y - EEPROM_CONFIG8_MAP2;
if(EEPROM.read(y) != vvtTable.values[7-offset/8][offset%8]) { EEPROM.write(y, vvtTable.values[7-offset/8][offset%8]); } //Write the 8x8 map
y++;
}
//RPM bins
y = EEPROM_CONFIG8_XBINS2;
for(int x=EEPROM_CONFIG8_XBINS1; x<EEPROM_CONFIG8_YBINS1; x++)
{
offset = x - EEPROM_CONFIG8_XBINS1;
if(EEPROM.read(x) != byte(boostTable.axisX[offset]/100)) { EEPROM.write(x, byte(boostTable.axisX[offset]/100)); } //RPM bins are divided by 100 and converted to a byte
offset = y - EEPROM_CONFIG8_XBINS2;
if(EEPROM.read(y) != byte(vvtTable.axisX[offset]/100)) { EEPROM.write(y, byte(vvtTable.axisX[offset]/100)); } //RPM bins are divided by 100 and converted to a byte
y++;
}
//TPS/MAP bins
y=EEPROM_CONFIG8_YBINS2;
for(int x=EEPROM_CONFIG8_YBINS1; x<EEPROM_CONFIG8_END; x++)
{
offset = x - EEPROM_CONFIG8_YBINS1;
if(EEPROM.read(x) != boostTable.axisY[offset]) { EEPROM.write(x, boostTable.axisY[offset]); }
offset = x - EEPROM_CONFIG8_YBINS1;
if(EEPROM.read(y) != vvtTable.axisY[offset]) { EEPROM.write(y, vvtTable.axisY[offset]); }
x++;
}
}
void loadConfig()
@ -267,7 +307,40 @@ void loadConfig()
for(int x=EEPROM_CONFIG7_START; x<EEPROM_CONFIG7_END; x++)
{
*(pnt_configPage + byte(x - EEPROM_CONFIG7_START)) = EEPROM.read(x);
}
}
//*********************************************************************************************************************************************************************************
// Boost and vvt tables load
int y = EEPROM_CONFIG8_MAP2;
for(int x=EEPROM_CONFIG8_MAP1; x<EEPROM_CONFIG8_XBINS1; x++)
{
offset = x - EEPROM_CONFIG8_MAP1;
boostTable.values[7-offset/8][offset%8] = EEPROM.read(x); //Read the 8x8 map
offset = y - EEPROM_CONFIG8_MAP2;
vvtTable.values[7-offset/8][offset%8] = EEPROM.read(y); //Read the 8x8 map
y++;
}
//RPM bins
y = EEPROM_CONFIG8_XBINS2;
for(int x=EEPROM_CONFIG8_XBINS1; x<EEPROM_CONFIG8_YBINS1; x++)
{
offset = x - EEPROM_CONFIG8_XBINS1;
boostTable.axisX[offset] = (EEPROM.read(x) * 100); //RPM bins are divided by 100 when stored. Multiply them back now
offset = y - EEPROM_CONFIG8_XBINS2;
vvtTable.axisX[offset] = (EEPROM.read(y) * 100); //RPM bins are divided by 100 when stored. Multiply them back now
y++;
}
//TPS/MAP bins
y = EEPROM_CONFIG8_YBINS2;
for(int x=EEPROM_CONFIG8_YBINS1; x<EEPROM_CONFIG8_END; x++)
{
offset = x - EEPROM_CONFIG8_YBINS1;
boostTable.axisY[offset] = EEPROM.read(x);
offset = y - EEPROM_CONFIG8_YBINS2;
vvtTable.axisY[offset] = EEPROM.read(y);
y++;
}
}
/*