movement: store settings in BKUP to persist across resets

This commit is contained in:
Joey Castillo 2021-11-25 10:38:17 -05:00
parent 5c3967aea2
commit b94c0ba65f
4 changed files with 9 additions and 5 deletions

View File

@ -114,10 +114,12 @@ void app_init() {
}
void app_wake_from_backup() {
// This app does not support BACKUP mode.
movement_state.settings.reg = watch_get_backup_data(0);
}
void app_setup() {
watch_store_backup_data(movement_state.settings.reg, 0);
static bool is_first_launch = true;
if (is_first_launch) {

View File

@ -13,12 +13,12 @@
// stored in BKUP[1] and BKUP[2], respectively.
// * The movement_reserved_t type is here as a placeholder, because I sense there's some other generally useful
// stuff we'll want to make available to all watch faces and stash in the BKUP[3] register.
// Anyway: Eventually, if Movement supports the BACKUP sleep mode, this will allow these preferences to be stored
// before entering BACKUP mode and and restored after waking from reset.
// This allows these preferences to be stored before entering BACKUP mode and and restored after waking from reset.
// movement_settings_t contains global settings that cover watch behavior, including preferences around clock and unit
// display, time zones, buzzer behavior, LED color and low energy mode timeouts.
// Eventually it will be stored in BKUP[0] when Movement enters BACKUP mode.
// display, time zones, buzzer behavior, LED color and low energy mode timeouts. These settings are stored in BKUP[0].
// If your watch face changes one of these settings, you should store your changes in either your loop or resign
// function by calling `watch_store_backup_data(settings->reg, 0)`. Otherwise it may not persist after a reset event.
typedef union {
struct {
bool button_should_sound : 1; // if true, pressing a button emits a sound.

View File

@ -165,4 +165,5 @@ void preferences_face_resign(movement_settings_t *settings, void *context) {
(void) context;
watch_set_led_off();
movement_request_tick_frequency(1);
watch_store_backup_data(settings->reg, 0);
}

View File

@ -123,4 +123,5 @@ void set_time_face_resign(movement_settings_t *settings, void *context) {
(void) context;
watch_set_led_off();
movement_request_tick_frequency(1);
watch_store_backup_data(settings->reg, 0);
}