Write app glance in wakeup_schedule_simple_robust to ensure time is accurate
This commit is contained in:
+1
-15
@@ -1,4 +1,4 @@
|
|||||||
#include "gentlewake.h"
|
#include "scheduler.h"
|
||||||
#include "triangles.h"
|
#include "triangles.h"
|
||||||
#include <pebble.h>
|
#include <pebble.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -89,19 +89,6 @@ static char *s_options_under[2];
|
|||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|
||||||
static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit, void *target) {
|
|
||||||
static char s_glance_buffer[22];
|
|
||||||
time_t alarm_time = (time_t)(uintptr_t)target;
|
|
||||||
struct tm wakeup_tm = *localtime(&alarm_time);
|
|
||||||
snprintf(s_glance_buffer, sizeof(s_glance_buffer), "%02u:%02u:%02u, %02u/%02u", wakeup_tm.tm_hour, wakeup_tm.tm_min, wakeup_tm.tm_sec, wakeup_tm.tm_mon, wakeup_tm.tm_mday);
|
|
||||||
AppGlanceSlice slice = {
|
|
||||||
.expiration_time = (time_t)(uintptr_t)target,
|
|
||||||
.layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON,
|
|
||||||
.layout.subtitle_template_string = s_glance_buffer,
|
|
||||||
};
|
|
||||||
app_glance_add_slice(session, slice);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool schedule_alarm(bool is_fallback) {
|
static bool schedule_alarm(bool is_fallback) {
|
||||||
time_t target;
|
time_t target;
|
||||||
WakeupId status;
|
WakeupId status;
|
||||||
@@ -127,7 +114,6 @@ static bool schedule_alarm(bool is_fallback) {
|
|||||||
}
|
}
|
||||||
s_the_time.HourSet = s_the_time.HourWIP;
|
s_the_time.HourSet = s_the_time.HourWIP;
|
||||||
s_the_time.MinuteSet = s_the_time.MinuteWIP;
|
s_the_time.MinuteSet = s_the_time.MinuteWIP;
|
||||||
app_glance_reload(glance_reload_callback, (void *)(uintptr_t)target);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
// lol the code in this file is mostly stolen from https://github.com/SeaPea/GentleWake
|
|
||||||
|
|
||||||
#include <pebble.h>
|
#include <pebble.h>
|
||||||
|
|
||||||
|
static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit, void *target) {
|
||||||
|
static char s_glance_buffer[22];
|
||||||
|
time_t alarm_time = (time_t)(uintptr_t)target;
|
||||||
|
struct tm wakeup_tm = *localtime(&alarm_time);
|
||||||
|
snprintf(s_glance_buffer, sizeof(s_glance_buffer), "%02u:%02u:%02u, %02u/%02u", wakeup_tm.tm_hour, wakeup_tm.tm_min, wakeup_tm.tm_sec, wakeup_tm.tm_mon, wakeup_tm.tm_mday);
|
||||||
|
AppGlanceSlice slice = {
|
||||||
|
.expiration_time = (time_t)(uintptr_t)target,
|
||||||
|
.layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON,
|
||||||
|
.layout.subtitle_template_string = s_glance_buffer,
|
||||||
|
};
|
||||||
|
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
|
// 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
|
// 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, bool is_fallback) {
|
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, bool is_fallback) {
|
||||||
@@ -24,6 +36,8 @@ WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, bo
|
|||||||
result = wakeup_schedule(wakeup_time, is_fallback, true);
|
result = wakeup_schedule(wakeup_time, is_fallback, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
app_glance_reload(glance_reload_callback, (void *)(uintptr_t)wakeup_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
Reference in New Issue
Block a user