Add worst case fallback position to baro reading

This commit is contained in:
Josh Stewart 2016-10-28 20:03:31 +11:00
parent 0a38467fc6
commit a4c9987e99
1 changed files with 7 additions and 1 deletions

View File

@ -238,7 +238,13 @@ void setup()
currentStatus.baro = currentStatus.MAP;
EEPROM.update(EEPROM_LAST_BARO, currentStatus.baro);
}
else { currentStatus.baro = EEPROM.read(EEPROM_LAST_BARO); } //last baro correction
else
{
//Attempt to use the last known good baro reading from EEPROM
if ((EEPROM.read(EEPROM_LAST_BARO) >= BARO_MIN) && (EEPROM.read(EEPROM_LAST_BARO) <= BARO_MAX)) //Make sure it's not invalid (Possible on first run etc)
{ currentStatus.baro = EEPROM.read(EEPROM_LAST_BARO); } //last baro correction
else { currentStatus.baro = 100; } //Final fall back position.
}
//Perform all initialisations
initialiseSchedulers();