Improved EEPROM-Formatting

This commit is contained in:
Marcel Peterkau 2022-08-24 20:59:00 +02:00
parent 3811834927
commit 685832cff8
4 changed files with 19 additions and 9 deletions

View File

@ -375,7 +375,7 @@
<div class="form-group row"> <div class="form-group row">
<div class="offset-4 col-8"> <div class="offset-4 col-8">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" name="reset_ee_pds" id="reset_ee_cfg"> <input class="form-check-input" type="checkbox" name="reset_ee_cfg" id="reset_ee_cfg">
<label class="form-check-label" for="reset_ee_cfg"> <label class="form-check-label" for="reset_ee_cfg">
Bereich "CFG" Bereich "CFG"
</label> </label>

View File

@ -137,16 +137,16 @@ void GetPersistence_EEPROM()
void FormatConfig_EEPROM() void FormatConfig_EEPROM()
{ {
LubeConfig_t defaults; Serial.println("Formatting Config-Partition");
LubeConfig = defaults; LubeConfig = LubeConfig_defaults;
LubeConfig.EEPROM_Version = eeVersion; LubeConfig.EEPROM_Version = eeVersion;
StoreConfig_EEPROM(); StoreConfig_EEPROM();
} }
void FormatPersistence_EEPROM() void FormatPersistence_EEPROM()
{ {
persistenceData_t defaults; Serial.println("Formatting Persistance-Partition");
PersistenceData = defaults; memset(&PersistenceData, 0, sizeof(PersistenceData));
StorePersistence_EEPROM(); StorePersistence_EEPROM();
} }

View File

@ -94,6 +94,16 @@ typedef struct
uint32_t checksum = 0; uint32_t checksum = 0;
} LubeConfig_t; } LubeConfig_t;
const LubeConfig_t LubeConfig_defaults{
0, 8000, 4000, 320, 72, 30, 1, 150, 70, 18, 2000, 25, SOURCE_IMPULSE,
#ifdef FEATURE_ENABLE_GPS
BAUD_115200,
#endif
#ifdef FEATURE_ENABLE_CAN
KTM_890_ADV_R_2021,
#endif
0};
void InitEEPROM(); void InitEEPROM();
void EEPROM_Process(); void EEPROM_Process();
void StoreConfig_EEPROM(); void StoreConfig_EEPROM();

View File

@ -310,15 +310,15 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
} }
if (p->name() == "reset_ee_btn") if (p->name() == "reset_ee_btn")
{ {
if (request->hasParam("reset_ee_pds")) if (request->hasParam("reset_ee_pds", true))
{ {
AsyncWebParameter *param = request->getParam("reset_ee_pds"); AsyncWebParameter *param = request->getParam("reset_ee_pds", true);
if (param->value() == "on") if (param->value() == "on")
globals.requestEEAction = globals.requestEEAction == EE_CFG_FORMAT ? EE_FORMAT_ALL : EE_PDS_FORMAT; globals.requestEEAction = globals.requestEEAction == EE_CFG_FORMAT ? EE_FORMAT_ALL : EE_PDS_FORMAT;
} }
if (request->hasParam("reset_ee_cfg")) if (request->hasParam("reset_ee_cfg", true))
{ {
AsyncWebParameter *param = request->getParam("reset_ee_cfg"); AsyncWebParameter *param = request->getParam("reset_ee_cfg", true);
if (param->value() == "on") if (param->value() == "on")
globals.requestEEAction = globals.requestEEAction == EE_PDS_FORMAT ? EE_FORMAT_ALL : EE_CFG_FORMAT; globals.requestEEAction = globals.requestEEAction == EE_PDS_FORMAT ? EE_FORMAT_ALL : EE_CFG_FORMAT;
} }