Add state_terminate() that saves settings to flash

replace/1bfb246e9971dcf582013ffc6512ee8d4ac806c4
Federico Amedeo Izzo 2021-02-21 16:44:31 +01:00
rodzic d4981ee288
commit 35bde9bccb
3 zmienionych plików z 19 dodań i 0 usunięć

Wyświetl plik

@ -121,6 +121,12 @@ extern state_t state;
*/
void state_init();
/**
* This function terminates the Radio state,
* Saving persistent settings to flash.
*/
void state_terminate();
/**
* This function applies the selected timezone after reading the time from
* the RTC.

Wyświetl plik

@ -90,6 +90,12 @@ void state_init()
}
}
void state_terminate()
{
// Write settings to flash memory
nvm_writeSettings(&state.settings);
}
void state_applyTimezone()
{
if(state.time.hour + state.settings.utc_timezone >= 24)

Wyświetl plik

@ -696,6 +696,13 @@ void ui_saveState()
void ui_updateFSM(event_t event, bool *sync_rtx)
{
// The volume knob has been set to OFF, shutdown the radio
if(state.v_bat <= 0)
{
state_terminate();
platform_terminate();
return;
}
// Check if battery has enough charge to operate
float charge = battery_getCharge(state.v_bat);
if (!state.emergency && charge <= 0)