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() {
|
void saveToFlash() {
|
||||||
uint32_t data[11];
|
uint32_t data[12];
|
||||||
data[0] = TankCalibLow.getValue();
|
data[0] = TankCalibLow.getValue();
|
||||||
data[1] = TankCalibHigh.getValue();
|
data[1] = TankCalibHigh.getValue();
|
||||||
data[2] = TankMinLevel.getValue();
|
data[2] = TankMinLevel.getValue();
|
||||||
@ -72,28 +72,48 @@ namespace floatpump {
|
|||||||
data[8] = RefillBelow.getValue();
|
data[8] = RefillBelow.getValue();
|
||||||
data[9] = RefillHysteresis.getValue();
|
data[9] = RefillHysteresis.getValue();
|
||||||
data[10] = RefillCooldown.getValue();
|
data[10] = RefillCooldown.getValue();
|
||||||
|
data[11] = 0xf0f0;
|
||||||
|
|
||||||
StoreInFlash(startAddr, data, 11);
|
StoreInFlash(startAddr, data, 12);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
void resetDefaults();
|
void resetDefaults();
|
||||||
|
|
||||||
void loadFromFlash() {
|
void loadFromFlash() {
|
||||||
uint32_t data[11];
|
uint32_t data[12];
|
||||||
ReadFromFlash(startAddr, data, 11);
|
ReadFromFlash(startAddr, data, 12);
|
||||||
TankCalibLow.setValue(data[0]);
|
|
||||||
TankCalibHigh.setValue(data[1]);
|
//Check if intial values must be loaded
|
||||||
TankMinLevel.setValue(data[2]);
|
if(data[11] == 0xf0f0) {
|
||||||
TankHysteresis.setValue(data[3]);
|
TankCalibLow.setValue(data[0]);
|
||||||
TankPumpInvert.setValue(data[4]);
|
TankCalibHigh.setValue(data[1]);
|
||||||
RefillEnable.setValue(data[5]);
|
TankMinLevel.setValue(data[2]);
|
||||||
RefillBlockInvert.setValue(data[6]);
|
TankHysteresis.setValue(data[3]);
|
||||||
RefillBlockEnable.setValue(data[7]);
|
TankPumpInvert.setValue(data[4]);
|
||||||
RefillBelow.setValue(data[8]);
|
RefillEnable.setValue(data[5]);
|
||||||
RefillHysteresis.setValue(data[9]);
|
RefillBlockInvert.setValue(data[6]);
|
||||||
RefillCooldown.setValue(data[10]);
|
RefillBlockEnable.setValue(data[7]);
|
||||||
return;
|
RefillBelow.setValue(data[8]);
|
||||||
|
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>
|
template<class T>
|
||||||
|
Loading…
Reference in New Issue
Block a user