New per page based EEPROM writes
This commit is contained in:
parent
1fa85bbbdb
commit
ae780dc940
|
@ -805,6 +805,8 @@ void loop()
|
|||
readIAT();
|
||||
readO2();
|
||||
readBat();
|
||||
if(eepromWritesPending == true) { writeAllConfig(); } //Check for any outstanding EEPROM writes.
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //ATmega2561 does not have Serial3
|
||||
//if Can interface is enabled then check for serial3 requests.
|
||||
if (configPage10.enable_canbus == 1) // megas only support can via secondary serial
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
#ifndef STORAGE_H
|
||||
#define STORAGE_H
|
||||
|
||||
void writeAllConfig();
|
||||
void writeConfig();
|
||||
void loadConfig();
|
||||
void loadCalibration();
|
||||
void writeCalibration();
|
||||
|
||||
#define EEPROM_MAX_WRITE_BLOCK 50 //The maximum number of write operations that will be performed in one go. If we try to write to the EEPROM too fast (Each write takes ~3ms) then the rest of the system can hang)
|
||||
bool eepromWritesPending = false;
|
||||
|
||||
/*
|
||||
Current layout of EEPROM data (Version 3) is as follows (All sizes are in bytes):
|
||||
|---------------------------------------------------|
|
||||
|
|
|
@ -7,13 +7,30 @@ A full copy of the license may be found in the projects root directory
|
|||
#include "storage.h"
|
||||
#include "globals.h"
|
||||
#include "table.h"
|
||||
#include "comms.h"
|
||||
#include <EEPROM.h>
|
||||
|
||||
void writeAllConfig()
|
||||
{
|
||||
writeConfig(1);
|
||||
writeConfig(2);
|
||||
writeConfig(3);
|
||||
writeConfig(4);
|
||||
writeConfig(5);
|
||||
writeConfig(6);
|
||||
writeConfig(7);
|
||||
writeConfig(8);
|
||||
writeConfig(9);
|
||||
writeConfig(10);
|
||||
writeConfig(11);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Takes the current configuration (config pages and maps)
|
||||
and writes them to EEPROM as per the layout defined in storage.h
|
||||
*/
|
||||
void writeConfig()
|
||||
void writeConfig(byte tableNum)
|
||||
{
|
||||
/*
|
||||
We only ever write to the EEPROM where the new value is different from the currently stored byte
|
||||
|
@ -21,9 +38,12 @@ void writeConfig()
|
|||
*/
|
||||
|
||||
int offset;
|
||||
int writeCounter = 0;
|
||||
//Create a pointer to the config page
|
||||
byte* pnt_configPage;
|
||||
|
||||
switch(tableNum)
|
||||
{
|
||||
case veMapPage:
|
||||
/*---------------------------------------------------
|
||||
| Fuel table (See storage.h for data layout) - Page 1
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
|
@ -32,25 +52,29 @@ void writeConfig()
|
|||
if(EEPROM.read(EEPROM_CONFIG1_YSIZE) != fuelTable.ySize) { EEPROM.write(EEPROM_CONFIG1_YSIZE, fuelTable.ySize); } //Write the VE Tables MAP/TPS dimension size
|
||||
for(int x=EEPROM_CONFIG1_MAP; x<EEPROM_CONFIG1_XBINS; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG1_MAP;
|
||||
if( EEPROM.read(x) != (fuelTable.values[15-(offset/16)][offset%16]) ) { EEPROM.write(x, fuelTable.values[15-(offset/16)][offset%16]); } //Write the 16x16 map
|
||||
if( EEPROM.read(x) != (fuelTable.values[15-(offset/16)][offset%16]) ) { EEPROM.write(x, fuelTable.values[15-(offset/16)][offset%16]); writeCounter++; } //Write the 16x16 map
|
||||
}
|
||||
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG1_XBINS; x<EEPROM_CONFIG1_YBINS; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG1_XBINS;
|
||||
if( EEPROM.read(x) != (byte(fuelTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) ) { EEPROM.write(x, byte(fuelTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
if( EEPROM.read(x) != (byte(fuelTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) ) { EEPROM.write(x, byte(fuelTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); writeCounter++; } //RPM bins are divided by 100 and converted to a byte
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG1_YBINS; x<EEPROM_CONFIG2_START; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG1_YBINS;
|
||||
EEPROM.update(x, fuelTable.axisY[offset] / TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
}
|
||||
break;
|
||||
//That concludes the writing of the VE table
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
case veSetPage:
|
||||
/*---------------------------------------------------
|
||||
| Config page 2 (See storage.h for data layout)
|
||||
| 64 byte long config table
|
||||
|
@ -58,11 +82,12 @@ void writeConfig()
|
|||
pnt_configPage = (byte *)&configPage1; //Create a pointer to Page 2 in memory
|
||||
for(int x=EEPROM_CONFIG2_START; x<EEPROM_CONFIG2_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG2_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG2_START))); }
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG2_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG2_START))); writeCounter++; }
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
break;
|
||||
|
||||
case ignMapPage:
|
||||
/*---------------------------------------------------
|
||||
| Ignition table (See storage.h for data layout) - Page 1
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
|
@ -73,24 +98,28 @@ void writeConfig()
|
|||
|
||||
for(int x=EEPROM_CONFIG3_MAP; x<EEPROM_CONFIG3_XBINS; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG3_MAP;
|
||||
if(EEPROM.read(x) != (ignitionTable.values[15-(offset/16)][offset%16]) ) { EEPROM.write(x, ignitionTable.values[15-(offset/16)][offset%16]); } //Write the 16x16 map with translation
|
||||
if(EEPROM.read(x) != (ignitionTable.values[15-(offset/16)][offset%16]) ) { EEPROM.write(x, ignitionTable.values[15-(offset/16)][offset%16]); writeCounter++; } //Write the 16x16 map with translation
|
||||
}
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG3_XBINS; x<EEPROM_CONFIG3_YBINS; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG3_XBINS;
|
||||
if(EEPROM.read(x) != byte(ignitionTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(ignitionTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
if(EEPROM.read(x) != byte(ignitionTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(ignitionTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); writeCounter++; } //RPM bins are divided by 100 and converted to a byte
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG3_YBINS; x<EEPROM_CONFIG4_START; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG3_YBINS;
|
||||
EEPROM.update(x, ignitionTable.axisY[offset]/TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
}
|
||||
//That concludes the writing of the IGN table
|
||||
//*********************************************************************************************************************************************************************************
|
||||
break;
|
||||
|
||||
case ignSetPage:
|
||||
/*---------------------------------------------------
|
||||
| Config page 2 (See storage.h for data layout)
|
||||
| 64 byte long config table
|
||||
|
@ -98,11 +127,12 @@ void writeConfig()
|
|||
pnt_configPage = (byte *)&configPage2; //Create a pointer to Page 2 in memory
|
||||
for(int x=EEPROM_CONFIG4_START; x<EEPROM_CONFIG4_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG4_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG4_START))); }
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG4_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG4_START))); writeCounter++; }
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
break;
|
||||
|
||||
case afrMapPage:
|
||||
/*---------------------------------------------------
|
||||
| AFR table (See storage.h for data layout) - Page 5
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
|
@ -113,24 +143,28 @@ void writeConfig()
|
|||
|
||||
for(int x=EEPROM_CONFIG5_MAP; x<EEPROM_CONFIG5_XBINS; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG5_MAP;
|
||||
if(EEPROM.read(x) != (afrTable.values[15-(offset/16)][offset%16]) ) { EEPROM.write(x, afrTable.values[15-(offset/16)][offset%16]); } //Write the 16x16 map
|
||||
if(EEPROM.read(x) != (afrTable.values[15-(offset/16)][offset%16]) ) { EEPROM.write(x, afrTable.values[15-(offset/16)][offset%16]); writeCounter++; } //Write the 16x16 map
|
||||
}
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG5_XBINS; x<EEPROM_CONFIG5_YBINS; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG5_XBINS;
|
||||
if(EEPROM.read(x) != byte(afrTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(afrTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
if(EEPROM.read(x) != byte(afrTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(afrTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); writeCounter++; } //RPM bins are divided by 100 and converted to a byte
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG5_YBINS; x<EEPROM_CONFIG6_START; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG5_YBINS;
|
||||
EEPROM.update(x, afrTable.axisY[offset]/TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
}
|
||||
//That concludes the writing of the AFR table
|
||||
//*********************************************************************************************************************************************************************************
|
||||
break;
|
||||
|
||||
case afrSetPage:
|
||||
/*---------------------------------------------------
|
||||
| Config page 3 (See storage.h for data layout)
|
||||
| 64 byte long config table
|
||||
|
@ -138,10 +172,12 @@ void writeConfig()
|
|||
pnt_configPage = (byte *)&configPage3; //Create a pointer to Page 3 in memory
|
||||
for(int x=EEPROM_CONFIG6_START; x<EEPROM_CONFIG6_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG6_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG6_START))); }
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG6_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG6_START))); writeCounter++; }
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
break;
|
||||
|
||||
case iacPage:
|
||||
/*---------------------------------------------------
|
||||
| Config page 4 (See storage.h for data layout)
|
||||
| 64 byte long config table
|
||||
|
@ -150,9 +186,13 @@ void writeConfig()
|
|||
//The next 128 bytes can simply be pulled straight from the configTable
|
||||
for(int x=EEPROM_CONFIG7_START; x<EEPROM_CONFIG7_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))); }
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))); writeCounter++; }
|
||||
}
|
||||
break;
|
||||
|
||||
case boostvvtPage:
|
||||
{
|
||||
/*---------------------------------------------------
|
||||
| Boost and vvt tables (See storage.h for data layout) - Page 8
|
||||
| 8x8 table itself + the 8 values along each of the axis
|
||||
|
@ -166,33 +206,40 @@ void writeConfig()
|
|||
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++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
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
|
||||
if(EEPROM.read(x) != (boostTable.values[7-(offset/8)][offset%8]) ) { EEPROM.write(x, boostTable.values[7-(offset/8)][offset%8]); writeCounter++; } //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
|
||||
if(EEPROM.read(y) != (vvtTable.values[7-(offset/8)][offset%8]) ) { EEPROM.write(y, vvtTable.values[7-(offset/8)][offset%8]); writeCounter++; } //Write the 8x8 map
|
||||
y++;
|
||||
}
|
||||
//RPM bins
|
||||
y = EEPROM_CONFIG8_XBINS2;
|
||||
for(int x=EEPROM_CONFIG8_XBINS1; x<EEPROM_CONFIG8_YBINS1; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG8_XBINS1;
|
||||
if(EEPROM.read(x) != byte(boostTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(boostTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
if(EEPROM.read(x) != byte(boostTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(boostTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); writeCounter++; } //RPM bins are divided by 100 and converted to a byte
|
||||
offset = y - EEPROM_CONFIG8_XBINS2;
|
||||
if(EEPROM.read(y) != byte(vvtTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(y, byte(vvtTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
if(EEPROM.read(y) != byte(vvtTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(y, byte(vvtTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); writeCounter++; } //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_XSIZE2; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG8_YBINS1;
|
||||
EEPROM.update(x, boostTable.axisY[offset]); //TABLE_LOAD_MULTIPLIER is NOT used for boost as it is TPS based (0-100)
|
||||
offset = y - EEPROM_CONFIG8_YBINS2;
|
||||
EEPROM.update(y, vvtTable.axisY[offset]); //TABLE_LOAD_MULTIPLIER is NOT used for VVT as it is TPS based (0-100)
|
||||
y++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case seqFuelPage:
|
||||
{
|
||||
/*---------------------------------------------------
|
||||
| Fuel trim tables (See storage.h for data layout) - Page 9
|
||||
| 6x6 tables itself + the 6 values along each of the axis
|
||||
|
@ -207,11 +254,12 @@ void writeConfig()
|
|||
EEPROM.update(EEPROM_CONFIG9_XSIZE4,trim4Table.xSize); //Write the boost Table RPM dimension size
|
||||
EEPROM.update(EEPROM_CONFIG9_YSIZE4,trim4Table.ySize); //Write the boost Table MAP/TPS dimension size
|
||||
|
||||
y = EEPROM_CONFIG9_MAP2; //We do the 4 maps together in the same loop
|
||||
int y = EEPROM_CONFIG9_MAP2; //We do the 4 maps together in the same loop
|
||||
int z = EEPROM_CONFIG9_MAP3; //We do the 4 maps together in the same loop
|
||||
int i = EEPROM_CONFIG9_MAP4; //We do the 4 maps together in the same loop
|
||||
for(int x=EEPROM_CONFIG9_MAP1; x<EEPROM_CONFIG9_XBINS1; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG9_MAP1;
|
||||
EEPROM.update(x, (trim1Table.values[5-(offset/6)][offset%6]) ); //Write the 6x6 map
|
||||
offset = y - EEPROM_CONFIG9_MAP2;
|
||||
|
@ -230,6 +278,7 @@ void writeConfig()
|
|||
i = EEPROM_CONFIG9_XBINS4;
|
||||
for(int x=EEPROM_CONFIG9_XBINS1; x<EEPROM_CONFIG9_YBINS1; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG9_XBINS1;
|
||||
EEPROM.update(x, byte(trim1Table.axisX[offset]/TABLE_RPM_MULTIPLIER)); //RPM bins are divided by 100 and converted to a byte
|
||||
offset = y - EEPROM_CONFIG9_XBINS2;
|
||||
|
@ -248,6 +297,7 @@ void writeConfig()
|
|||
i=EEPROM_CONFIG9_YBINS4;
|
||||
for(int x=EEPROM_CONFIG9_YBINS1; x<EEPROM_CONFIG9_XSIZE2; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
offset = x - EEPROM_CONFIG9_YBINS1;
|
||||
EEPROM.update(x, trim1Table.axisY[offset]/TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
offset = y - EEPROM_CONFIG9_YBINS2;
|
||||
|
@ -260,8 +310,10 @@ void writeConfig()
|
|||
z++;
|
||||
i++;
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
}
|
||||
break;
|
||||
|
||||
case canbusPage:
|
||||
/*---------------------------------------------------
|
||||
| Config page 10 (See storage.h for data layout)
|
||||
| 128 byte long config table
|
||||
|
@ -269,11 +321,12 @@ void writeConfig()
|
|||
pnt_configPage = (byte *)&configPage10; //Create a pointer to Page 10 in memory
|
||||
for(int x=EEPROM_CONFIG10_START; x<EEPROM_CONFIG10_END; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG10_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG10_START))); }
|
||||
}
|
||||
break;
|
||||
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
case warmupPage:
|
||||
/*---------------------------------------------------
|
||||
| Config page 11 (See storage.h for data layout)
|
||||
| 192 byte long config table
|
||||
|
@ -282,8 +335,14 @@ void writeConfig()
|
|||
//As there are no 3d tables in this page, all 192 bytes can simply be read in
|
||||
for(int x=EEPROM_CONFIG11_START; x<EEPROM_CONFIG11_END; x++)
|
||||
{
|
||||
if( (writeCounter > EEPROM_MAX_WRITE_BLOCK) ) { eepromWritesPending = true; break; } //This is a safety check to make sure we don't attempt to write too much to the EEPROM at a time.
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG11_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG11_START))); }
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void loadConfig()
|
||||
|
|
|
@ -20,7 +20,7 @@ void doUpdates()
|
|||
ignitionTable.values[x][y] = ignitionTable.values[x][y] + 40;
|
||||
}
|
||||
}
|
||||
writeConfig();
|
||||
writeAllConfig();
|
||||
EEPROM.write(EEPROM_DATA_VERSION, 3);
|
||||
}
|
||||
//June 2017 required the forced addition of some CAN values to avoid weird errors
|
||||
|
@ -33,7 +33,7 @@ void doUpdates()
|
|||
//There was a bad value in the May base tune for the spark duration setting, fix it here if it's a problem
|
||||
if(configPage2.sparkDur == 255) { configPage2.sparkDur = 10; }
|
||||
|
||||
writeConfig();
|
||||
writeAllConfig();
|
||||
EEPROM.write(EEPROM_DATA_VERSION, 4);
|
||||
}
|
||||
//July 2017 adds a cranking enrichment curve in place of the single value. This converts that single value to the curve
|
||||
|
@ -50,7 +50,7 @@ void doUpdates()
|
|||
configPage11.crankingEnrichValues[2] = 100 + configPage1.crankingPct;
|
||||
configPage11.crankingEnrichValues[3] = 100 + configPage1.crankingPct;
|
||||
|
||||
writeConfig();
|
||||
writeAllConfig();
|
||||
EEPROM.write(EEPROM_DATA_VERSION, 5);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue