diff options
author | Joey Castillo <joeycastillo@utexas.edu> | 2021-11-25 10:38:17 -0500 |
---|---|---|
committer | Joey Castillo <joeycastillo@utexas.edu> | 2021-11-25 10:39:09 -0500 |
commit | b94c0ba65fa012e8f78a2b3c88878570679784f6 (patch) | |
tree | 531f04a80c5b6cd31cdadec01059bfa85dc6ecb4 /movement | |
parent | 5c3967aea28dff5a2731a28862c5cae3b995f875 (diff) | |
download | Sensor-Watch-b94c0ba65fa012e8f78a2b3c88878570679784f6.tar.gz Sensor-Watch-b94c0ba65fa012e8f78a2b3c88878570679784f6.tar.bz2 Sensor-Watch-b94c0ba65fa012e8f78a2b3c88878570679784f6.zip |
movement: store settings in BKUP to persist across resets
Diffstat (limited to 'movement')
-rw-r--r-- | movement/movement.c | 4 | ||||
-rw-r--r-- | movement/movement.h | 8 | ||||
-rw-r--r-- | movement/watch_faces/settings/preferences_face.c | 1 | ||||
-rw-r--r-- | movement/watch_faces/settings/set_time_face.c | 1 |
4 files changed, 9 insertions, 5 deletions
diff --git a/movement/movement.c b/movement/movement.c index 1a31175a..128011b9 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -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) { diff --git a/movement/movement.h b/movement/movement.h index 4e791fca..0379fe7b 100644 --- a/movement/movement.h +++ b/movement/movement.h @@ -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. diff --git a/movement/watch_faces/settings/preferences_face.c b/movement/watch_faces/settings/preferences_face.c index afe71034..03a58834 100644 --- a/movement/watch_faces/settings/preferences_face.c +++ b/movement/watch_faces/settings/preferences_face.c @@ -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); } diff --git a/movement/watch_faces/settings/set_time_face.c b/movement/watch_faces/settings/set_time_face.c index fd414279..0f5af312 100644 --- a/movement/watch_faces/settings/set_time_face.c +++ b/movement/watch_faces/settings/set_time_face.c @@ -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); } |