From 1a5635d7954ad130796b68e86c5277efecb7e774 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Wed, 26 Oct 2016 00:24:40 +1100 Subject: [PATCH] Store previous baro value in EEPROM. Having this in a variable is insufficient --- speeduino.ino | 9 +++++---- storage.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/speeduino.ino b/speeduino.ino index eb91e569..256f7c7a 100644 --- a/speeduino.ino +++ b/speeduino.ino @@ -100,7 +100,6 @@ unsigned long previousLoopTime; //The time the previous loop started (uS) unsigned long MAPrunningValue; //Used for tracking either the total of all MAP readings in this cycle (Event average) or the lowest value detected in this cycle (event minimum) unsigned int MAPcount; //Number of samples taken in the current MAP cycle byte MAPcurRev = 0; //Tracks which revolution we're sampling on -int LastBaro; //Used for ignore correction if powered on a ruuning engine int CRANK_ANGLE_MAX = 720; int CRANK_ANGLE_MAX_IGN = 360, CRANK_ANGLE_MAX_INJ = 360; // The number of crank degrees that the system track over. 360 for wasted / timed batch and 720 for sequential @@ -234,9 +233,11 @@ void setup() * The lowest measurable sea-level pressure is found at the centers of tropical cyclones and tornadoes, with a record low of 87 kPa; */ if ((currentStatus.MAP >= 87) && (currentStatus.MAP <= 108)) //Check if engine isn't running - LastBaro = currentStatus.baro = currentStatus.MAP; - else - currentStatus.baro = LastBaro; //last baro correction + { + currentStatus.baro = currentStatus.MAP; + EEPROM.update(EEPROM_LAST_BARO, currentStatus.baro); + } + else { currentStatus.baro = EEPROM.read(EEPROM_LAST_BARO); //last baro correction } //Perform all initialisations initialiseSchedulers(); diff --git a/storage.h b/storage.h index 3f562ede..d929affa 100644 --- a/storage.h +++ b/storage.h @@ -96,6 +96,7 @@ Current layout of EEPROM data (Version 3) is as follows (All sizes are in bytes) #define EEPROM_CONFIG9_YBINS4 1385 //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_LAST_BARO 2558 #define EEPROM_CALIBRATION_O2 2559 #define EEPROM_CALIBRATION_IAT 3071 #define EEPROM_CALIBRATION_CLT 3583