timed-remote

Flipper Zero app for sending delayed IR commands
git clone git://src.adamsgaard.dk/timed-remote # fast
git clone https://src.adamsgaard.dk/timed-remote.git # slow
Log | Files | Refs | README | LICENSE Back to index

commit 09f8cce335b7eb2dcf12759af4137d8432e49b94
parent 97baa48656eef679ac9aea5c173bea6c06cb020a
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sat, 31 Jan 2026 09:43:46 +0100

fix(timer): roll scheduled times to next day and make unlimited repeats infinite

Diffstat:
Mhelpers/time_helper.c | 6++++--
Mhelpers/time_helper.h | 7++++---
Mscenes/scene_timer_running.c | 19+++++++++++++------
3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/helpers/time_helper.c b/helpers/time_helper.c @@ -31,10 +31,12 @@ uint32_t time_helper_seconds_until(uint8_t target_h, uint8_t target_m, uint32_t target_seconds = time_helper_hms_to_seconds(target_h, target_m, target_s); - if (target_seconds <= now_seconds) { - return 0; /* Target time has already passed today */ + if (target_seconds < now_seconds) { + /* Roll to next day */ + return (24 * 3600 - now_seconds) + target_seconds; } + /* Target time is now or later today */ return target_seconds - now_seconds; } diff --git a/helpers/time_helper.h b/helpers/time_helper.h @@ -27,13 +27,14 @@ void time_helper_seconds_to_hms(uint32_t total_seconds, uint8_t *h, uint8_t *m, #ifndef TIMED_REMOTE_TEST_BUILD /** - * Calculate seconds remaining until a target time (today). - * Uses Flipper's RTC. If target time has passed, returns 0. + * Calculate seconds remaining until a target time. + * Uses Flipper's RTC. If target time has passed, rolls to next day. + * If target time is exactly now, returns 0. * * @param target_h Target hour (0-23) * @param target_m Target minute (0-59) * @param target_s Target second (0-59) - * @return Seconds until target, or 0 if already passed + * @return Seconds until target (today or next day), or 0 if now */ uint32_t time_helper_seconds_until(uint8_t target_h, uint8_t target_m, uint8_t target_s); diff --git a/scenes/scene_timer_running.c b/scenes/scene_timer_running.c @@ -92,16 +92,23 @@ bool timed_remote_scene_timer_running_on_event(void *context, ir_helper_transmit(app->ir_signal); } - app->repeats_remaining--; - - if (app->repeat_count != 0 && app->repeats_remaining > 0) { - /* Reset countdown for next repeat */ + if (app->repeat_count == 255) { + /* Unlimited repeat */ app->seconds_remaining = time_helper_hms_to_seconds(app->hours, app->minutes, app->seconds); update_display(app); } else { - /* Done - show confirmation */ - scene_manager_next_scene(app->scene_manager, TimedRemoteSceneConfirm); + app->repeats_remaining--; + + if (app->repeat_count != 0 && app->repeats_remaining > 0) { + /* Reset countdown for next repeat */ + app->seconds_remaining = time_helper_hms_to_seconds( + app->hours, app->minutes, app->seconds); + update_display(app); + } else { + /* Done - show confirmation */ + scene_manager_next_scene(app->scene_manager, TimedRemoteSceneConfirm); + } } consumed = true; }