Vibe(+zap) when attempting to overwrite recovery/awareness alarm

This commit is contained in:
2026-08-18 16:16:34 -04:00
parent ad59a338a8
commit a98065f09f
2 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -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! - 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! - 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! - 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) ## 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 - Timeline integration
- Speaker support - Speaker support
- Full touch navigation - Full touch navigation
+11 -11
View File
@@ -200,6 +200,7 @@ static void send_zap() {
if (result != APP_MSG_OK) { if (result != APP_MSG_OK) {
return; return;
} }
return;
} }
////////////////////// MISC ////////////////////// ////////////////////// MISC //////////////////////
@@ -213,17 +214,11 @@ static bool schedule_alarm(WakeupReason schedule_reason) {
target = time(NULL) + 15; 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 // 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); 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; break;
case WAKE_AWARENESS_ALARM: case WAKE_AWARENESS_ALARM:
target = time(NULL) + 9 * SECONDS_PER_MINUTE; target = time(NULL) + 9 * SECONDS_PER_MINUTE;
wakeup_cancel_all(); wakeup_cancel_all();
status = wakeup_schedule_simple_robust(target, SECONDS_PER_MINUTE, schedule_reason); 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; break;
case WAKE_MAIN_ALARM: { case WAKE_MAIN_ALARM: {
time_t now = time(NULL); time_t now = time(NULL);
@@ -237,15 +232,16 @@ static bool schedule_alarm(WakeupReason schedule_reason) {
} }
wakeup_cancel_all(); wakeup_cancel_all();
status = wakeup_schedule_simple_robust(target, SECONDS_PER_MINUTE, schedule_reason); 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) { if (status < 0) {
push_status_window(STATUS_SET_FAILURE); push_status_window(STATUS_SET_FAILURE);
persist_write_int(STORAGE_KEY_ALARM_REASON, WAKE_MAIN_ALARM);
return false; return false;
} }
if (s_alarm_reason != schedule_reason) {
persist_write_int(STORAGE_KEY_ALARM_REASON, schedule_reason);
}
return true; 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) { static void setter_select_click_handler(void *recognizer, void *ctx) {
if (s_highlight_pos == 2) { 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); bool success = schedule_alarm(WAKE_MAIN_ALARM);
if (!success) { if (!success) {
return; // early return to avoid indicating alarm was set when it was not 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_register_inbox_received(inbox_received_handler);
app_message_open(64, 64); // TODO tighten sizes app_message_open(64, 64); // TODO tighten sizes
s_alarm_reason = persist_read_int(STORAGE_KEY_ALARM_REASON);
switch (launch_reason()) { switch (launch_reason()) {
// case APP_LAUNCH_PHONE: // DEBUG, REMOVE PRIOR TO RELEASE!
case APP_LAUNCH_WAKEUP: case APP_LAUNCH_WAKEUP:
s_alarm_reason = persist_read_int(STORAGE_KEY_ALARM_REASON);
if (s_alarm_reason == WAKE_RECOVERY_ALARM) { if (s_alarm_reason == WAKE_RECOVERY_ALARM) {
send_zap(); send_zap();
} }