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

@ -375,7 +375,7 @@
<div class="form-group row">
<div class="offset-4 col-8">
<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">
Bereich "CFG"
</label>

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

@ -94,6 +94,16 @@ typedef struct
uint32_t checksum = 0;
} 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 EEPROM_Process();
void StoreConfig_EEPROM();

@ -310,15 +310,15 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
}
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")
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")
globals.requestEEAction = globals.requestEEAction == EE_PDS_FORMAT ? EE_FORMAT_ALL : EE_CFG_FORMAT;
}