Calibration tables load func (EEPROM)

This commit is contained in:
Josh Stewart 2014-05-12 21:28:24 +10:00
parent e50d30f4fe
commit 4aa57039a6
4 changed files with 40 additions and 1 deletions

View File

@ -29,6 +29,9 @@ const byte page_size = 128;
#define BIT_SQUIRT_INJ2SQRT 5 //Injector2 (Schedule2)
#define BIT_SQUIRT_BOOSTCTRLOFF 6 //Squirting Injector 2
#define SIZE_BYTE 8
#define SIZE_INT 16
//The status struct contains the current values for all 'live' variables
//In current version this is 64 bytes
struct statuses {

View File

@ -91,13 +91,22 @@ void setup()
loadConfig();
//Repoint the 2D table structs to the config pages that were just loaded
taeTable.valueSize = SIZE_BYTE; //Set this table to use byte values
taeTable.xSize = 4;
taeTable.values = configPage2.taeValues;
taeTable.axisX = configPage2.taeBins;
WUETable.valueSize = SIZE_BYTE; //Set this table to use byte values
WUETable.xSize = 10;
WUETable.values = configPage1.wueValues;
WUETable.axisX = configPage2.wueBins;
//Setup the calibration tables
cltCalibrationTable.valueSize = SIZE_INT;
iatCalibrationTable.valueSize = SIZE_INT;
o2CalibrationTable.valueSize = SIZE_INT;
loadCalibration();
//Need to check early on whether the coil charging is inverted. If this is not set straight away it can cause an unwanted spark at bootup
if(configPage2.IgInv == 1) { coilHIGH = LOW, coilLOW = HIGH; }
else { coilHIGH = HIGH, coilLOW = LOW; }

View File

@ -1,8 +1,8 @@
#include <EEPROM.h>
void writeConfig();
void loadConfig();
void loadCalibration();
/*
Current layout of EEPROM data (Version 2) is as follows (All sizes are in bytes):

View File

@ -1,4 +1,5 @@
#include <EEPROM.h>
//#include "table.h"
/*
Takes the current configuration (config pages and maps)
@ -143,3 +144,29 @@ void loadConfig()
}
}
/*
Reads the calibration information from EEPROM.
This is separate from the config load as the calibrations do not exist as pages within the ini file for Tuner Studio
*/
void loadCalibration()
{
//Set the table sizes to 3 (This allocates memory for the arrays as well)
table2D_setSize(&cltCalibrationTable, 3);
table2D_setSize(&iatCalibrationTable, 3);
table2D_setSize(&o2CalibrationTable, 3);
for(byte x=0; x<3; x++)
{
int y = 2*x;
cltCalibrationTable.axisX16[x] = EEPROM.read( (EEPROM_CALIBRATION_CLT + y) );
cltCalibrationTable.values16[x] = EEPROM.read( (EEPROM_CALIBRATION_CLT + y + 1) );
iatCalibrationTable.axisX16[x] = EEPROM.read( (EEPROM_CALIBRATION_IAT + y) );
iatCalibrationTable.values16[x] = EEPROM.read( (EEPROM_CALIBRATION_IAT + y + 1) );
o2CalibrationTable.axisX16[x] = EEPROM.read( (EEPROM_CALIBRATION_O2 + y) );
o2CalibrationTable.values16[x] = EEPROM.read( (EEPROM_CALIBRATION_O2 + y + 1) );
}
}