Migrate to SDK4.44+MV2

This commit is contained in:
RandyTheSilly committed 2026-11-05 20:51:09 -05:00
1 parent bf7a8a30b4
commit d286450c92
4 files changed
+102 -104

No files matched your search

+4 -4
View File
@@ -75,7 +75,7 @@ static uint8_t s_zap_cooldown;
static uint8_t s_countdown_int = 0;
static bool s_continuous_zap_on_first_triangle;
static char s_countdown_buf[4];
static char s_progress_buf[6];
static char s_progress_buf[8];
// constants
//// shared (setter+alarm)
@@ -183,7 +183,7 @@ static void status_window_load(StatusWindowPurpose purpose) {
scroll_layer_set_content_size(s_status_scroll_layer, GSize(bounds.size.w, max_size.h));
return;
case STATUS_CONFIRMATION: {
static char s_status_confirmed_buffer[86];
static char s_status_confirmed_buffer[88];
snprintf(s_status_confirmed_buffer, sizeof(s_status_confirmed_buffer), "Alarm disarmed and re-set (%02u:%02u) successfully.\n\nSELECT: Exit\nBACK: Change alarm time", the_time.HourSet, the_time.MinuteSet);
text_layer_set_text(s_status_txt_layer, s_status_confirmed_buffer);
window_set_click_config_provider(s_status_window, status_confirmation_click_config_provider);
@@ -246,13 +246,13 @@ static bool schedule_alarm(WakeupReason schedule_reason) {
case WAKE_ALARM: {
target = compute_alarm_time(the_time.HourWIP, the_time.MinuteWIP);
wakeup_cancel_all();
status = wakeup_schedule_simple_robust(target, SECONDS_PER_MINUTE, schedule_reason);
status = wakeup_schedule_simple_robust(target, schedule_reason);
break;
}
case WAKE_RECOVERY_ALARM:
target = time(NULL) + 15;
// no need to cancel alarms, as recovery alarms are short-lived and are expired by the time another is being scheduled
status = wakeup_schedule_simple_robust(target, 15, schedule_reason);
status = wakeup_schedule_simple_robust(target, schedule_reason);
}
if (status < 0) {
push_status_window(STATUS_FAILURE);
+5 -15
View File
@@ -16,29 +16,19 @@ static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit
app_glance_add_slice(session, slice);
}
// Mostly stolen from https://github.com/SeaPea/GentleWake;
// A slightly more robust wakeup scheduler that retries on certain errors and
// can retry for a different wakeup time offset by retry_diff up to retry_max times
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, WakeupReason wakeup_reason) {
// Originally stolen from https://github.com/SeaPea/GentleWake (simplified by me for SDK 4.44+);
// A slightly more robust wakeup scheduler that retries on errors
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, WakeupReason wakeup_reason) {
WakeupId result = 0;
uint8_t try_count = 0;
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
if (result < 0) {
// If result is negative, something went wrong, so make sure all wakeups for this app are cancelled and try again
wakeup_cancel_all();
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
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 * 8) minutes before/after.
while (result == E_RANGE && try_count++ < 8) {
wakeup_time += retry_diff;
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
}
}
// As of SDK 4.44, E_RANGE result no longer needs handled, as it now only reports wakeups scheduled by THIS app;
// we call wakeup_cancel_all() above, so E_RANGE will never be encountered
}
if (result >= 0) {
+1 -1
View File
@@ -16,4 +16,4 @@ typedef struct TheTime {
extern struct TheTime the_time;
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, WakeupReason wakeup_reason);
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, WakeupReason wakeup_reason);