From a98065f09faeadc5ff2cd84ae9f4f8ac7960a3e6 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Tue, 18 Aug 2026 16:16:34 -0400 Subject: [PATCH] Vibe(+zap) when attempting to overwrite recovery/awareness alarm --- README.md | 2 +- src/c/main.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3081284..bb3e949 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ Because it requires the perfect amount of thought to activate your brain in the - The vibration pattern is randomized. It derives the length of the three pulses from the angles in the generated triangle. Neat! - Some of the alarm scheduling code was taken from [Gentle Wake](https://github.com/SeaPea/GentleWake). It seems trusted by the community, so... I stole it! The beauty of open source, no AI needed! - A custom font was made to satisfy the need for something that looks like LECO but is monospaced. The version I made contains only numbers, period, and colon, but if you want to build off of it, [it's public](https://git.wetfence.xyz/RandyTheSilly/pebble-misc/src/branch/main/fonts) and easy to modify! +- Trigalarm can optionally integrate with [Pavlok](https://pavlok.com/pages/how-it-works) to shock you for failing to respond to alarms or for force-quitting the alarm! ## Future Goals (1.1 and beyond) -- [Pavlok](https://pavlok.com/pages/how-it-works) integration to shock the user on failure to complete secondary (awareness) alarm and when force-exiting alarm - Timeline integration - Speaker support - Full touch navigation diff --git a/src/c/main.c b/src/c/main.c index 8401a43..c3a1855 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -200,6 +200,7 @@ static void send_zap() { if (result != APP_MSG_OK) { return; } + return; } ////////////////////// MISC ////////////////////// @@ -213,17 +214,11 @@ static bool schedule_alarm(WakeupReason schedule_reason) { target = time(NULL) + 15; // no need to cancel alarms, as RECOVERY_ALARM is short-lived and is expired by the time another is being scheduled status = wakeup_schedule_simple_robust(target, 15, schedule_reason); - if (s_alarm_reason != WAKE_RECOVERY_ALARM) { - persist_write_int(STORAGE_KEY_ALARM_REASON, WAKE_RECOVERY_ALARM); - } break; case WAKE_AWARENESS_ALARM: target = time(NULL) + 9 * SECONDS_PER_MINUTE; wakeup_cancel_all(); status = wakeup_schedule_simple_robust(target, SECONDS_PER_MINUTE, schedule_reason); - if (s_alarm_reason != WAKE_AWARENESS_ALARM) { - persist_write_int(STORAGE_KEY_ALARM_REASON, WAKE_AWARENESS_ALARM); - } break; case WAKE_MAIN_ALARM: { time_t now = time(NULL); @@ -237,15 +232,16 @@ static bool schedule_alarm(WakeupReason schedule_reason) { } wakeup_cancel_all(); status = wakeup_schedule_simple_robust(target, SECONDS_PER_MINUTE, schedule_reason); - if (s_alarm_reason != WAKE_MAIN_ALARM) { - persist_write_int(STORAGE_KEY_ALARM_REASON, WAKE_MAIN_ALARM); - } } } if (status < 0) { push_status_window(STATUS_SET_FAILURE); + persist_write_int(STORAGE_KEY_ALARM_REASON, WAKE_MAIN_ALARM); return false; } + if (s_alarm_reason != schedule_reason) { + persist_write_int(STORAGE_KEY_ALARM_REASON, schedule_reason); + } return true; } @@ -838,6 +834,11 @@ static void setter_down_click_handler(void *recognizer, void *ctx) { static void setter_select_click_handler(void *recognizer, void *ctx) { if (s_highlight_pos == 2) { + if (s_alarm_reason != WAKE_MAIN_ALARM) { + send_zap(); + vibes_double_pulse(); + return; // early return to avoid overwriting recovery/awareness alarm + } bool success = schedule_alarm(WAKE_MAIN_ALARM); if (!success) { return; // early return to avoid indicating alarm was set when it was not @@ -967,10 +968,9 @@ static void init() { app_message_register_inbox_received(inbox_received_handler); app_message_open(64, 64); // TODO tighten sizes + s_alarm_reason = persist_read_int(STORAGE_KEY_ALARM_REASON); switch (launch_reason()) { - // case APP_LAUNCH_PHONE: // DEBUG, REMOVE PRIOR TO RELEASE! case APP_LAUNCH_WAKEUP: - s_alarm_reason = persist_read_int(STORAGE_KEY_ALARM_REASON); if (s_alarm_reason == WAKE_RECOVERY_ALARM) { send_zap(); }