]> git.earman.xyz Git - sensor-watch.git/commitdiff
movement: reset tick to 1 Hz between watch faces (fixes #36)
authorJoey Castillo <joeycastillo@utexas.edu>
Wed, 19 Jan 2022 16:16:10 +0000 (11:16 -0500)
committerJoey Castillo <joeycastillo@utexas.edu>
Wed, 19 Jan 2022 16:16:10 +0000 (11:16 -0500)
12 files changed:
movement/README.md
movement/movement.c
movement/watch_faces/clock/world_clock_face.c
movement/watch_faces/complications/beats_face.c
movement/watch_faces/complications/countdown_face.c
movement/watch_faces/complications/day_one_face.c
movement/watch_faces/complications/pulsometer_face.c
movement/watch_faces/complications/sunrise_sunset_face.c
movement/watch_faces/demos/character_set_face.c
movement/watch_faces/demos/demo_face.c
movement/watch_faces/settings/preferences_face.c
movement/watch_faces/settings/set_time_face.c

index 66c1f890a096bd709d13418d142e14f9f13751d3..4b52bbd469d949b5489843b7449ec0357a2050c1 100644 (file)
@@ -17,7 +17,7 @@ You can implement a watch face using just four functions:
 * `watch_face_loop`
 * `watch_face_resign`
 
-A fifth optional function, `watch_face_wants_background_task`, has not yet had its implementation ironed out, but it will be added to the guide at a later date.
+A fifth optional function, `watch_face_wants_background_task`, will be added to the guide at a later date. You may omit it.
 
 To create a new watch face, you should create a new C header and source file in the watch-faces folder (i.e. for a watch face that displays moon phases: `moon_phase_face.h`, `moon_phase_face.c`), and implement these functions with your own unique prefix (i.e. `moon_phase_face_setup`). Then declare your watch face in your header file as follows:
 
@@ -61,7 +61,7 @@ You should set up a switch statement that handles, at the very least, the `EVENT
 
 ### watch_face_resign
 
-This function is called just before your watch face goes off screen. You should disable any peripherals you enabled in `watch_face_activate`. If you requested a tick frequency other than 1 Hz at any point in your code, **you must reset it to 1 Hz when you resign**. The watch_face_resign function is passed the same settings and context as the other functions.
+This function is called just before your watch face goes off screen. You should disable any peripherals you enabled in `watch_face_activate`. The watch_face_resign function is passed the same settings and context as the other functions.
 
 Putting it into practice: the Pulsometer watch face
 ---------------------------------------------------
@@ -242,13 +242,12 @@ case EVENT_TIMEOUT:
 
 #### Watch Face Resignation
 
-The resign function doesn't have to do much here; it just resets the tick frequency to 1 Hz.
+The resign function doesn't have anything to do; it just has to be there.
 
 ```c
 void pulsometer_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
-    movement_request_tick_frequency(1);
 }
 ```
 
index a6d3d111f12778f89bf24f5d6a25630d86662ff5..2fc08d8039bedd3f75823ff3d34be9e836385497 100644 (file)
@@ -278,6 +278,7 @@ bool app_loop(void) {
         watch_faces[movement_state.current_watch_face].resign(&movement_state.settings, watch_face_contexts[movement_state.current_watch_face]);
         movement_state.current_watch_face = movement_state.next_watch_face;
         watch_clear_display();
+        movement_request_tick_frequency(1);
         watch_faces[movement_state.current_watch_face].activate(&movement_state.settings, watch_face_contexts[movement_state.current_watch_face]);
         event.subsecond = 0;
         event.event_type = EVENT_ACTIVATE;
index afde8cf78ccf39b255af64be92b5b62fbfbf108c..6910eca0e0547defd7bf24a7dc7a0917bb5992bf 100644 (file)
@@ -208,5 +208,4 @@ bool world_clock_face_loop(movement_event_t event, movement_settings_t *settings
 void world_clock_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
-    movement_request_tick_frequency(1);
 }
index b4c76db1da4d774e56a71cad79e04dcf914c6396..d1466b33ce860318fa34457aecd9b9c266e0b7f9 100644 (file)
@@ -76,7 +76,6 @@ bool beats_face_loop(movement_event_t event, movement_settings_t *settings, void
 void beats_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
-    movement_request_tick_frequency(1);
 }
 
 uint32_t clock2beats(uint32_t hours, uint32_t minutes, uint32_t seconds, uint32_t subseconds, int16_t utc_offset) {
index 99eb12430d4490ec40103229926880ce4aba0f01..3dcc08c2a4865609760b99c9bee6f5a887669417 100644 (file)
@@ -219,6 +219,8 @@ bool countdown_face_loop(movement_event_t event, movement_settings_t *settings,
 
 void countdown_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
-    (void) context;
-    movement_request_tick_frequency(1);
+    countdown_state_t *state = (countdown_state_t *)context;
+    if (state->mode == cd_setting) {
+        state->mode = cd_waiting;
+    }
 }
index 4fa14a7f58481547ebdbb065a0623b0539d6d89e..18d02d4d5fb001672f6c84212cff6369aae9733e 100644 (file)
@@ -187,8 +187,6 @@ void day_one_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     day_one_state_t *state = (day_one_state_t *)context;
 
-    movement_request_tick_frequency(1);
-
     // if the user changed their birth date, store it to the birth date register
     if (state->birthday_changed) {
         day_one_state_t *state = (day_one_state_t *)context;
index 145b3cfe0990f2993a944bb1c8c5c909eaa8fd00..28ca1a50fcaf5b49f05a6a877155e7e052fccc99 100644 (file)
@@ -111,5 +111,4 @@ bool pulsometer_face_loop(movement_event_t event, movement_settings_t *settings,
 void pulsometer_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
-    movement_request_tick_frequency(1);
 }
index bb7323ec80ee6c2f503c7e6ed765ad6b6564ddeb..ceca3515a49526d646808a4442d289055408fe3d 100644 (file)
@@ -144,6 +144,4 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti
 void sunrise_sunset_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
-
-    movement_request_tick_frequency(1);
 }
index 7c2740e1397f215cc03f6910002c839c58fcf7a2..6aa42083b4b9f46d376ae448f049de775e8caa53 100644 (file)
@@ -72,5 +72,4 @@ bool character_set_face_loop(movement_event_t event, movement_settings_t *settin
 void character_set_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
-    movement_request_tick_frequency(1);
 }
index dc2269b7d7a1c6b19abf22b943d292e22bb96956..c9a929a1573d82733d1d370ea0bbc3e5eb8bd305 100644 (file)
@@ -138,5 +138,4 @@ bool demo_face_loop(movement_event_t event, movement_settings_t *settings, void
 void demo_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
-    movement_request_tick_frequency(1);
 }
index 725be01ef7919cb73ccfe6a302de703168453365..790c9de53bb55493f771c233db27151043742a1f 100644 (file)
@@ -189,6 +189,5 @@ void preferences_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
     watch_set_led_off();
-    movement_request_tick_frequency(1);
     watch_store_backup_data(settings->reg, 0);
 }
index ad59843d93790f7b6a8140ca0726a7f39af3bb52..f0e7dc6ca94fddb87a0e2a942e362bf7fed063c6 100644 (file)
@@ -147,6 +147,5 @@ void set_time_face_resign(movement_settings_t *settings, void *context) {
     (void) settings;
     (void) context;
     watch_set_led_off();
-    movement_request_tick_frequency(1);
     watch_store_backup_data(settings->reg, 0);
 }