summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-01-19 11:16:10 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-01-19 11:16:10 -0500
commit138b3d0c5e4c9bd32adef17c83981b180c676969 (patch)
treef162c22288024a3af22aa26f475dc57c239a2a6a
parentfb71be55ee09c1f7117c6bcdf4f4de30778c8f30 (diff)
downloadSensor-Watch-138b3d0c5e4c9bd32adef17c83981b180c676969.tar.gz
Sensor-Watch-138b3d0c5e4c9bd32adef17c83981b180c676969.tar.bz2
Sensor-Watch-138b3d0c5e4c9bd32adef17c83981b180c676969.zip
movement: reset tick to 1 Hz between watch faces (fixes #36)
-rw-r--r--movement/README.md7
-rw-r--r--movement/movement.c1
-rw-r--r--movement/watch_faces/clock/world_clock_face.c1
-rw-r--r--movement/watch_faces/complications/beats_face.c1
-rw-r--r--movement/watch_faces/complications/countdown_face.c6
-rw-r--r--movement/watch_faces/complications/day_one_face.c2
-rw-r--r--movement/watch_faces/complications/pulsometer_face.c1
-rw-r--r--movement/watch_faces/complications/sunrise_sunset_face.c2
-rw-r--r--movement/watch_faces/demos/character_set_face.c1
-rw-r--r--movement/watch_faces/demos/demo_face.c1
-rw-r--r--movement/watch_faces/settings/preferences_face.c1
-rw-r--r--movement/watch_faces/settings/set_time_face.c1
12 files changed, 8 insertions, 17 deletions
diff --git a/movement/README.md b/movement/README.md
index 66c1f890..4b52bbd4 100644
--- a/movement/README.md
+++ b/movement/README.md
@@ -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);
}
```
diff --git a/movement/movement.c b/movement/movement.c
index a6d3d111..2fc08d80 100644
--- a/movement/movement.c
+++ b/movement/movement.c
@@ -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;
diff --git a/movement/watch_faces/clock/world_clock_face.c b/movement/watch_faces/clock/world_clock_face.c
index afde8cf7..6910eca0 100644
--- a/movement/watch_faces/clock/world_clock_face.c
+++ b/movement/watch_faces/clock/world_clock_face.c
@@ -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);
}
diff --git a/movement/watch_faces/complications/beats_face.c b/movement/watch_faces/complications/beats_face.c
index b4c76db1..d1466b33 100644
--- a/movement/watch_faces/complications/beats_face.c
+++ b/movement/watch_faces/complications/beats_face.c
@@ -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) {
diff --git a/movement/watch_faces/complications/countdown_face.c b/movement/watch_faces/complications/countdown_face.c
index 99eb1243..3dcc08c2 100644
--- a/movement/watch_faces/complications/countdown_face.c
+++ b/movement/watch_faces/complications/countdown_face.c
@@ -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;
+ }
}
diff --git a/movement/watch_faces/complications/day_one_face.c b/movement/watch_faces/complications/day_one_face.c
index 4fa14a7f..18d02d4d 100644
--- a/movement/watch_faces/complications/day_one_face.c
+++ b/movement/watch_faces/complications/day_one_face.c
@@ -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;
diff --git a/movement/watch_faces/complications/pulsometer_face.c b/movement/watch_faces/complications/pulsometer_face.c
index 145b3cfe..28ca1a50 100644
--- a/movement/watch_faces/complications/pulsometer_face.c
+++ b/movement/watch_faces/complications/pulsometer_face.c
@@ -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);
}
diff --git a/movement/watch_faces/complications/sunrise_sunset_face.c b/movement/watch_faces/complications/sunrise_sunset_face.c
index bb7323ec..ceca3515 100644
--- a/movement/watch_faces/complications/sunrise_sunset_face.c
+++ b/movement/watch_faces/complications/sunrise_sunset_face.c
@@ -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);
}
diff --git a/movement/watch_faces/demos/character_set_face.c b/movement/watch_faces/demos/character_set_face.c
index 7c2740e1..6aa42083 100644
--- a/movement/watch_faces/demos/character_set_face.c
+++ b/movement/watch_faces/demos/character_set_face.c
@@ -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);
}
diff --git a/movement/watch_faces/demos/demo_face.c b/movement/watch_faces/demos/demo_face.c
index dc2269b7..c9a929a1 100644
--- a/movement/watch_faces/demos/demo_face.c
+++ b/movement/watch_faces/demos/demo_face.c
@@ -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);
}
diff --git a/movement/watch_faces/settings/preferences_face.c b/movement/watch_faces/settings/preferences_face.c
index 725be01e..790c9de5 100644
--- a/movement/watch_faces/settings/preferences_face.c
+++ b/movement/watch_faces/settings/preferences_face.c
@@ -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);
}
diff --git a/movement/watch_faces/settings/set_time_face.c b/movement/watch_faces/settings/set_time_face.c
index ad59843d..f0e7dc6c 100644
--- a/movement/watch_faces/settings/set_time_face.c
+++ b/movement/watch_faces/settings/set_time_face.c
@@ -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);
}