summaryrefslogtreecommitdiffstats
path: root/movement
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-08-03 10:57:39 -0700
committerJoey Castillo <joeycastillo@utexas.edu>2022-08-03 10:57:39 -0700
commit0c8a81bb5df099210c531bb793479403fab319b9 (patch)
tree9364ed8102f6f25c4447fdbc1260717c27f23a65 /movement
parentcc4275694be97f365096eefb9b7513b41bcfdcd4 (diff)
parente790a025787e0e1aa59b98b95e194cf4318d1578 (diff)
downloadSensor-Watch-totp-lfs.tar.gz
Sensor-Watch-totp-lfs.tar.bz2
Sensor-Watch-totp-lfs.zip
Merge branch 'main' of github.com:joeycastillo/Sensor-Watch into totp-lfstotp-lfs
Diffstat (limited to 'movement')
-rw-r--r--movement/alt_fw/focus.h1
-rw-r--r--movement/alt_fw/timers.h43
-rwxr-xr-xmovement/make/Makefile3
-rw-r--r--movement/movement.c43
-rw-r--r--movement/movement.h3
-rw-r--r--movement/movement_faces.h3
-rw-r--r--movement/watch_faces/complication/probability_face.c182
-rw-r--r--movement/watch_faces/complication/probability_face.h51
-rw-r--r--movement/watch_faces/complication/wake_face.c159
-rw-r--r--movement/watch_faces/complication/wake_face.h53
10 files changed, 529 insertions, 12 deletions
diff --git a/movement/alt_fw/focus.h b/movement/alt_fw/focus.h
index 865459e8..ab5525a5 100644
--- a/movement/alt_fw/focus.h
+++ b/movement/alt_fw/focus.h
@@ -32,6 +32,7 @@ const watch_face_t watch_faces[] = {
tomato_face,
stopwatch_face,
countdown_face,
+ wake_face, // added by @joshber 2022-07-23, per @joeycastillo
preferences_face,
set_time_face,
diff --git a/movement/alt_fw/timers.h b/movement/alt_fw/timers.h
new file mode 100644
index 00000000..c4d27f50
--- /dev/null
+++ b/movement/alt_fw/timers.h
@@ -0,0 +1,43 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2022 Joey Castillo
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MOVEMENT_CONFIG_H_
+#define MOVEMENT_CONFIG_H_
+
+#include "movement_faces.h"
+
+const watch_face_t watch_faces[] = {
+ simple_clock_face,
+ wake_face,
+ interval_face,
+ stopwatch_face,
+ sunrise_sunset_face,
+
+ preferences_face,
+ set_time_face,
+};
+
+#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))
+
+#endif // MOVEMENT_CONFIG_H_
diff --git a/movement/make/Makefile b/movement/make/Makefile
index cf18c37c..6c939cb2 100755
--- a/movement/make/Makefile
+++ b/movement/make/Makefile
@@ -67,6 +67,9 @@ SRCS += \
../watch_faces/complication/orrery_face.c \
../watch_faces/complication/astronomy_face.c \
../watch_faces/complication/tomato_face.c \
+ ../watch_faces/complication/probability_face.c \
+ ../watch_faces/complication/wake_face.c \
+# wake_face.c: Josh Berson, 2022-07-04
# New watch faces go above this line.
# Leave this line at the bottom of the file; it has all the targets for making your project.
diff --git a/movement/movement.c b/movement/movement.c
index 3444a378..d79142ec 100644
--- a/movement/movement.c
+++ b/movement/movement.c
@@ -226,6 +226,11 @@ void movement_cancel_background_task(void) {
movement_state.has_scheduled_background_task = other_tasks_scheduled;
}
+void movement_request_wake() {
+ movement_state.needs_wake = true;
+ _movement_reset_inactivity_countdown();
+}
+
void movement_play_signal(void) {
watch_buzzer_play_note(BUZZER_NOTE_C8, 75);
watch_buzzer_play_note(BUZZER_NOTE_REST, 100);
@@ -233,7 +238,11 @@ void movement_play_signal(void) {
}
void movement_play_alarm(void) {
- movement_state.alarm_ticks = 128 * 5 - 80; // 80 ticks short of 5 seconds, or 4.375 seconds (our beep is 0.375 seconds)
+ movement_request_wake();
+ // alarm length: 75 ticks short of 5 seconds, or 4.414 seconds:
+ // our tone is 0.375 seconds of beep and 0.625 of silence, repeated five times.
+ // so 4.375 + a few ticks to wake up from sleep mode.
+ movement_state.alarm_ticks = 128 * 5 - 75;
_movement_enable_fast_tick_if_needed();
}
@@ -325,6 +334,23 @@ void app_prepare_for_standby(void) {
void app_wake_from_standby(void) {
}
+static void _sleep_mode_app_loop(void) {
+ movement_state.needs_wake = false;
+ // as long as le_mode_ticks is -1 (i.e. we are in low energy mode), we wake up here, update the screen, and go right back to sleep.
+ while (movement_state.le_mode_ticks == -1) {
+ // we also have to handle background tasks here in the mini-runloop
+ if (movement_state.needs_background_tasks_handled) _movement_handle_background_tasks();
+
+ event.event_type = EVENT_LOW_ENERGY_UPDATE;
+ watch_faces[movement_state.current_watch_face].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_watch_face]);
+
+ // if we need to wake immediately, do it!
+ if (movement_state.needs_wake) return;
+ // otherwise enter sleep mode, and when the extwake handler is called, it will reset le_mode_ticks and force us out at the next loop.
+ else watch_enter_sleep_mode();
+ }
+}
+
bool app_loop(void) {
if (movement_state.watch_face_changed) {
if (movement_state.settings.bit.button_should_sound) {
@@ -366,17 +392,10 @@ bool app_loop(void) {
event.event_type = EVENT_NONE;
event.subsecond = 0;
- // this is a little mini-runloop.
- // as long as le_mode_ticks is -1 (i.e. we are in low energy mode), we wake up here, update the screen, and go right back to sleep.
- while (movement_state.le_mode_ticks == -1) {
- // we also have to handle background tasks here in the mini-runloop
- if (movement_state.needs_background_tasks_handled) _movement_handle_background_tasks();
-
- event.event_type = EVENT_LOW_ENERGY_UPDATE;
- watch_faces[movement_state.current_watch_face].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_watch_face]);
- watch_enter_sleep_mode();
- }
- // as soon as le_mode_ticks is reset by the extwake handler, we bail out of the loop and reactivate ourselves.
+ // _sleep_mode_app_loop takes over at this point and loops until le_mode_ticks is reset by the extwake handler,
+ // or wake is requested using the movement_request_wake function.
+ _sleep_mode_app_loop();
+ // as soon as _sleep_mode_app_loop returns, we reactivate ourselves.
event.event_type = EVENT_ACTIVATE;
// this is a hack tho: waking from sleep mode, app_setup does get called, but it happens before we have reset our ticks.
// need to figure out if there's a better heuristic for determining how we woke up.
diff --git a/movement/movement.h b/movement/movement.h
index a29c4469..0442f607 100644
--- a/movement/movement.h
+++ b/movement/movement.h
@@ -257,6 +257,7 @@ typedef struct {
// background task handling
bool needs_background_tasks_handled;
bool has_scheduled_background_task;
+ bool needs_wake;
// low energy mode countdown
int32_t le_mode_ticks;
@@ -287,6 +288,8 @@ void movement_schedule_background_task(watch_date_time date_time);
// movement will associate the scheduled task with the currently active face.
void movement_cancel_background_task(void);
+void movement_request_wake(void);
+
void movement_play_signal(void);
void movement_play_alarm(void);
diff --git a/movement/movement_faces.h b/movement/movement_faces.h
index e7e78ff4..e18f3683 100644
--- a/movement/movement_faces.h
+++ b/movement/movement_faces.h
@@ -52,6 +52,9 @@
#include "orrery_face.h"
#include "astronomy_face.h"
#include "tomato_face.h"
+#include "probability_face.h"
+#include "wake_face.h"
+// #include "interval_face.h"
// New includes go above this line.
#endif // MOVEMENT_FACES_H_
diff --git a/movement/watch_faces/complication/probability_face.c b/movement/watch_faces/complication/probability_face.c
new file mode 100644
index 00000000..7b056b33
--- /dev/null
+++ b/movement/watch_faces/complication/probability_face.c
@@ -0,0 +1,182 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2022 Spencer Bywater
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+// Emulator only: need time() to seed the random number generator.
+#if __EMSCRIPTEN__
+#include <time.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include "probability_face.h"
+
+#define DEFAULT_DICE_SIDES 2
+#define PROBABILITY_ANIMATION_TICK_FREQUENCY 8
+const uint16_t NUM_DICE_TYPES = 8; // Keep this consistent with # of dice types below
+const uint16_t DICE_TYPES[] = {2, 4, 6, 8, 10, 12, 20, 100};
+
+
+// --------------
+// Custom methods
+// --------------
+
+static void display_dice_roll(probability_state_t *state) {
+ char buf[8];
+ if (state->rolled_value == 0) {
+ if (state->dice_sides == 100) {
+ sprintf(buf, " C ");
+ } else {
+ sprintf(buf, "%2d ", state->dice_sides);
+ }
+ } else if (state->dice_sides == 2) {
+ if (state->rolled_value == 1) {
+ sprintf(buf, "%2d H", state->dice_sides);
+ } else {
+ sprintf(buf, "%2d T", state->dice_sides);
+ }
+ } else if (state->dice_sides == 100) {
+ sprintf(buf, " C %3d", state->rolled_value);
+ } else {
+ sprintf(buf, "%2d %3d", state->dice_sides, state->rolled_value);
+ }
+ watch_display_string(buf, 4);
+}
+
+static void generate_random_number(probability_state_t *state) {
+ // Emulator: use rand. Hardware: use arc4random.
+ #if __EMSCRIPTEN__
+ state->rolled_value = rand() % state->dice_sides + 1;
+ #else
+ state->rolled_value = arc4random_uniform(state->dice_sides) + 1;
+ #endif
+}
+
+static void display_dice_roll_animation(probability_state_t *state) {
+ if (state->is_rolling) {
+ if (state->animation_frame == 0) {
+ watch_display_string(" ", 7);
+ watch_set_pixel(1, 4);
+ watch_set_pixel(1, 6);
+ state->animation_frame = 1;
+ } else if (state->animation_frame == 1) {
+ watch_clear_pixel(1, 4);
+ watch_clear_pixel(1, 6);
+ watch_set_pixel(2, 4);
+ watch_set_pixel(0, 6);
+ state->animation_frame = 2;
+ } else if (state->animation_frame == 2) {
+ watch_clear_pixel(2, 4);
+ watch_clear_pixel(0, 6);
+ watch_set_pixel(2, 5);
+ watch_set_pixel(0, 5);
+ state->animation_frame = 3;
+ } else if (state->animation_frame == 3) {
+ state->animation_frame = 0;
+ state->is_rolling = false;
+ movement_request_tick_frequency(1);
+ display_dice_roll(state);
+ }
+ }
+}
+
+
+// ---------------------------
+// Standard watch face methods
+// ---------------------------
+void probability_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
+ (void) settings;
+ (void) watch_face_index;
+ if (*context_ptr == NULL) {
+ *context_ptr = malloc(sizeof(probability_state_t));
+ memset(*context_ptr, 0, sizeof(probability_state_t));
+ }
+ // Emulator only: Seed random number generator
+ #if __EMSCRIPTEN__
+ srand(time(NULL));
+ #endif
+}
+
+void probability_face_activate(movement_settings_t *settings, void *context) {
+ (void) settings;
+ probability_state_t *state = (probability_state_t *)context;
+
+ state->dice_sides = DEFAULT_DICE_SIDES;
+ state->rolled_value = 0;
+ watch_display_string("PR", 0);
+}
+
+bool probability_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
+ (void) settings;
+ probability_state_t *state = (probability_state_t *)context;
+
+ if (state->is_rolling && event.event_type != EVENT_TICK) {
+ return true;
+ }
+
+ switch (event.event_type) {
+ case EVENT_ACTIVATE:
+ display_dice_roll(state);
+ break;
+ case EVENT_TICK:
+ display_dice_roll_animation(state);
+ break;
+ case EVENT_MODE_BUTTON_UP:
+ movement_move_to_next_face();
+ break;
+ case EVENT_LIGHT_BUTTON_UP:
+ // Change how many sides the die has
+ for (int i = 0; i < NUM_DICE_TYPES; i++) {
+ if (DICE_TYPES[i] == state->dice_sides) {
+ if (i == NUM_DICE_TYPES - 1) {
+ state->dice_sides = DICE_TYPES[0];
+ } else {
+ state->dice_sides = DICE_TYPES[i + 1];
+ }
+ break;
+ }
+ }
+ state->rolled_value = 0;
+ display_dice_roll(state);
+ break;
+ case EVENT_ALARM_BUTTON_UP:
+ // Roll the die
+ generate_random_number(state);
+ state->is_rolling = true;
+ // Dice rolling animation begins on next tick and new roll will be displayed on completion
+ movement_request_tick_frequency(PROBABILITY_ANIMATION_TICK_FREQUENCY);
+ break;
+ case EVENT_LOW_ENERGY_UPDATE:
+ watch_display_string("SLEEP ", 4);
+ break;
+ default:
+ break;
+ }
+
+ return true;
+}
+
+void probability_face_resign(movement_settings_t *settings, void *context) {
+ (void) settings;
+ (void) context;
+}
diff --git a/movement/watch_faces/complication/probability_face.h b/movement/watch_faces/complication/probability_face.h
new file mode 100644
index 00000000..c6d3638f
--- /dev/null
+++ b/movement/watch_faces/complication/probability_face.h
@@ -0,0 +1,51 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2022 Spencer Bywater
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef PROBABILITY_FACE_H_
+#define PROBABILITY_FACE_H_
+
+#include "movement.h"
+
+typedef struct {
+ uint8_t dice_sides;
+ uint8_t rolled_value;
+ uint8_t animation_frame;
+ bool is_rolling;
+} probability_state_t;
+
+void probability_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
+void probability_face_activate(movement_settings_t *settings, void *context);
+bool probability_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
+void probability_face_resign(movement_settings_t *settings, void *context);
+
+#define probability_face ((const watch_face_t){ \
+ probability_face_setup, \
+ probability_face_activate, \
+ probability_face_loop, \
+ probability_face_resign, \
+ NULL, \
+})
+
+#endif // PROBABILITY_FACE_H_
+
diff --git a/movement/watch_faces/complication/wake_face.c b/movement/watch_faces/complication/wake_face.c
new file mode 100644
index 00000000..4c265c75
--- /dev/null
+++ b/movement/watch_faces/complication/wake_face.c
@@ -0,0 +1,159 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2022 Josh Berson, building on Wesley Ellis’ countdown_face.c
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+//-----------------------------------------------------------------------------
+
+#include <stdlib.h>
+#include <string.h>
+// #include <threads.h>
+
+#include "wake_face.h"
+#include "watch.h"
+#include "watch_utility.h"
+
+/*
+ UI Notes
+ º Light advances hour by 1
+ º Light long press advances hour by 6
+ º Alarm advances minute by 10
+ º Alarm long press cycles through signal modes (just one at the moment)
+*/
+
+//
+// Private
+//
+
+static
+void _wake_face_update_display(movement_settings_t *settings, wake_face_state_t *state) {
+ (void) settings;
+ uint8_t hour = state->hour;
+
+ watch_clear_display();
+ if ( settings->bit.clock_mode_24h )
+ watch_set_indicator(WATCH_INDICATOR_24H);
+ else {
+ if ( hour >= 12 )
+ watch_set_indicator(WATCH_INDICATOR_PM);
+ hour = hour % 12 ? hour % 12 : 12;
+ }
+
+ if ( state->mode )
+ watch_set_indicator(WATCH_INDICATOR_BELL);
+
+ static char lcdbuf[11];
+ sprintf(lcdbuf, "WA %2d%02d ", hour, state->minute);
+
+ watch_set_colon();
+ watch_display_string(lcdbuf, 0);
+}
+
+//
+// Exported
+//
+
+void wake_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr) {
+ (void) settings;
+ (void) watch_face_index;
+
+ if (*context_ptr == NULL) {
+ *context_ptr = malloc(sizeof(wake_face_state_t));
+ wake_face_state_t *state = (wake_face_state_t *)*context_ptr;
+ memset(*context_ptr, 0, sizeof(wake_face_state_t));
+
+ state->hour = 5;
+ state->minute = 0;
+ state->mode = 0;
+ }
+}
+
+void wake_face_activate(movement_settings_t *settings, void *context) {
+ (void) settings;
+ (void) context;
+}
+void wake_face_resign(movement_settings_t *settings, void *context) {
+ (void) settings;
+ (void) context;
+}
+
+bool wake_face_wants_background_task(movement_settings_t *settings, void *context) {
+ (void) settings;
+ wake_face_state_t *state = (wake_face_state_t *)context;
+
+ bool rc = false;
+ if ( state->mode ) {
+ watch_date_time now = watch_rtc_get_date_time();
+ rc = state->hour==now.unit.hour && state->minute==now.unit.minute;
+ // We’re at the mercy of the wants_background_task handler
+ // In Safari, the emulator triggers at the ›end‹ of the minute
+ // Converting to Unix timestamps and taking a difference between now and wake
+ // is not an easy win — because the timestamp for wake has to rely on now
+ // for its date. So first we’d have to see if the TOD of wake is after that
+ // of now. If it is, take tomorrow’s date, calculating month and year rollover
+ // if need be.
+ }
+ return rc;
+}
+
+bool wake_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
+ (void) settings;
+ wake_face_state_t *state = (wake_face_state_t *)context;
+
+ switch (event.event_type) {
+ case EVENT_ACTIVATE:
+ case EVENT_TICK:
+ _wake_face_update_display(settings, state);
+ break;
+ case EVENT_LIGHT_BUTTON_UP:
+ state->hour = (state->hour + 1) % 24;
+ _wake_face_update_display(settings, state);
+ break;
+ case EVENT_LIGHT_LONG_PRESS:
+ state->hour = (state->hour + 6) % 24;
+ _wake_face_update_display(settings, state);
+ break;
+ case EVENT_ALARM_BUTTON_UP:
+ state->minute = (state->minute + 10) % 60;
+ _wake_face_update_display(settings, state);
+ break;
+ case EVENT_ALARM_LONG_PRESS:
+ state->mode ^= 1;
+ _wake_face_update_display(settings, state);
+ break;
+ case EVENT_BACKGROUND_TASK:
+ movement_play_alarm();
+ // 2022-07-23: Thx @joeycastillo for the dedicated “alarm” signal
+ break;
+ case EVENT_MODE_BUTTON_UP:
+ movement_move_to_next_face();
+ break;
+ case EVENT_TIMEOUT:
+ movement_move_to_face(0);
+ break;
+ case EVENT_LOW_ENERGY_UPDATE:
+ default:
+ break;
+ }
+
+ return true;
+} \ No newline at end of file
diff --git a/movement/watch_faces/complication/wake_face.h b/movement/watch_faces/complication/wake_face.h
new file mode 100644
index 00000000..c091c8f3
--- /dev/null
+++ b/movement/watch_faces/complication/wake_face.h
@@ -0,0 +1,53 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2022 Josh Berson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+//-----------------------------------------------------------------------------
+
+#ifndef WAKE_FACE_H_
+#define WAKE_FACE_H_
+
+#include "movement.h"
+
+typedef struct {
+ uint32_t hour : 5;
+ uint32_t minute : 6;
+ uint32_t mode : 1;
+} wake_face_state_t;
+
+void wake_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr);
+void wake_face_activate(movement_settings_t *settings, void *context);
+bool wake_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
+void wake_face_resign(movement_settings_t *settings, void *context);
+bool wake_face_wants_background_task(movement_settings_t *settings, void *context);
+
+#define wake_face ((const watch_face_t){ \
+ wake_face_setup, \
+ wake_face_activate, \
+ wake_face_loop, \
+ wake_face_resign, \
+ wake_face_wants_background_task \
+})
+
+#endif // WAKE_FACE_H_
+