From 591129536338cdab4b6a0fcfed777dfe2551f7cd Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 10 Aug 2026 20:59:02 -0400 Subject: [PATCH] Use wakeup handler to reschedule fallback alarm --- src/c/gentlewake.c | 4 ++-- src/c/main.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/c/gentlewake.c b/src/c/gentlewake.c index 7396190..8ab45b7 100644 --- a/src/c/gentlewake.c +++ b/src/c/gentlewake.c @@ -18,8 +18,8 @@ WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, bo if (result == E_RANGE) { // E_RANGE means some other app has the same wakeup time +/- 1 minute, so try to set - // the wakeup for a time up to (retry_diff * 5) minutes before/after. - while (result == E_RANGE && try_count++ < 5) { + // the wakeup for a time up to (retry_diff * 8) minutes before/after. + while (result == E_RANGE && try_count++ < 8) { wakeup_time += retry_diff; result = wakeup_schedule(wakeup_time, is_fallback, true); } diff --git a/src/c/main.c b/src/c/main.c index 682a031..4418547 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -157,11 +157,6 @@ static void add_bar_layers_to_window(Layer *window_layer, bool small_top) { ////////////////////// ALARM ////////////////////// static void alarm_seconds_handler(struct tm *tick_time, TimeUnits units_changed) { - // re-schedule fallback alarm every 15 seconds - if (tick_time->tm_sec % 15 == 0) { - schedule_alarm(true); // output is not captured, as it is not actionable - } - // update stopwatch if (s_stopwatch_time[1] == 59) { s_stopwatch_time[1] = 0; @@ -259,7 +254,15 @@ static void drop_menu_window_unload(Window *window) { s_drop_menu_layer = NULL; } +static void live_wakeup_handler_for_alarm(WakeupId id, int32_t reason) { + if (reason == 1) { // if fallback alarm, re-schedule it + schedule_alarm(true); // output is not captured, as it is not actionable + } +} + static void alarm_window_load() { + wakeup_service_subscribe(live_wakeup_handler_for_alarm); + Layer *window_layer = window_get_root_layer(s_window); // change highlight color to avoid changing color of bottom bar