FEATURE: new correct initial configuration after flashing with full chip erase
This commit is contained in:
parent
bf9d8dafb6
commit
33ab540653
@ -60,7 +60,7 @@ namespace floatpump {
|
||||
|
||||
|
||||
void saveToFlash() {
|
||||
uint32_t data[11];
|
||||
uint32_t data[12];
|
||||
data[0] = TankCalibLow.getValue();
|
||||
data[1] = TankCalibHigh.getValue();
|
||||
data[2] = TankMinLevel.getValue();
|
||||
@ -72,16 +72,20 @@ namespace floatpump {
|
||||
data[8] = RefillBelow.getValue();
|
||||
data[9] = RefillHysteresis.getValue();
|
||||
data[10] = RefillCooldown.getValue();
|
||||
data[11] = 0xf0f0;
|
||||
|
||||
StoreInFlash(startAddr, data, 11);
|
||||
StoreInFlash(startAddr, data, 12);
|
||||
return;
|
||||
};
|
||||
|
||||
void resetDefaults();
|
||||
|
||||
void loadFromFlash() {
|
||||
uint32_t data[11];
|
||||
ReadFromFlash(startAddr, data, 11);
|
||||
uint32_t data[12];
|
||||
ReadFromFlash(startAddr, data, 12);
|
||||
|
||||
//Check if intial values must be loaded
|
||||
if(data[11] == 0xf0f0) {
|
||||
TankCalibLow.setValue(data[0]);
|
||||
TankCalibHigh.setValue(data[1]);
|
||||
TankMinLevel.setValue(data[2]);
|
||||
@ -94,6 +98,22 @@ namespace floatpump {
|
||||
RefillHysteresis.setValue(data[9]);
|
||||
RefillCooldown.setValue(data[10]);
|
||||
return;
|
||||
} else {
|
||||
//Set default values for fist initialization only
|
||||
//TODO: refactor this, maybe edit linker script to initially store values to correct flash location
|
||||
TankCalibLow.setValue(0);
|
||||
TankCalibHigh.setValue(10000);
|
||||
TankMinLevel.setValue(25);
|
||||
TankHysteresis.setValue(5);
|
||||
TankPumpInvert.setValue(1);
|
||||
RefillEnable.setValue(0);
|
||||
RefillBlockInvert.setValue(0);
|
||||
RefillBlockEnable.setValue(1);
|
||||
RefillBelow.setValue(35);
|
||||
RefillHysteresis.setValue(5);
|
||||
RefillCooldown.setValue(5);
|
||||
saveToFlash();
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
Loading…
Reference in New Issue
Block a user