Add state_terminate() that saves settings to flash
This commit is contained in:
parent
d4981ee288
commit
35bde9bccb
|
|
@ -121,6 +121,12 @@ extern state_t state;
|
||||||
*/
|
*/
|
||||||
void state_init();
|
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
|
* This function applies the selected timezone after reading the time from
|
||||||
* the RTC.
|
* the RTC.
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,12 @@ void state_init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void state_terminate()
|
||||||
|
{
|
||||||
|
// Write settings to flash memory
|
||||||
|
nvm_writeSettings(&state.settings);
|
||||||
|
}
|
||||||
|
|
||||||
void state_applyTimezone()
|
void state_applyTimezone()
|
||||||
{
|
{
|
||||||
if(state.time.hour + state.settings.utc_timezone >= 24)
|
if(state.time.hour + state.settings.utc_timezone >= 24)
|
||||||
|
|
|
||||||
|
|
@ -696,6 +696,13 @@ void ui_saveState()
|
||||||
|
|
||||||
void ui_updateFSM(event_t event, bool *sync_rtx)
|
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
|
// Check if battery has enough charge to operate
|
||||||
float charge = battery_getCharge(state.v_bat);
|
float charge = battery_getCharge(state.v_bat);
|
||||||
if (!state.emergency && charge <= 0)
|
if (!state.emergency && charge <= 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue