summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-10-04 11:09:11 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-10-04 14:12:39 -0400
commit0546859073a3e57ed724e4eb1d741a438a175638 (patch)
treee5f38eb6cf9f4ae810c0bc13f282439c2cc20f3d
parent7f8973a8cc55e37cd8e2d59f7eab2def0045d2a6 (diff)
downloadSensor-Watch-0546859073a3e57ed724e4eb1d741a438a175638.tar.gz
Sensor-Watch-0546859073a3e57ed724e4eb1d741a438a175638.tar.bz2
Sensor-Watch-0546859073a3e57ed724e4eb1d741a438a175638.zip
launcher: improvements to screensaver mode
-rw-r--r--launcher/launcher.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/launcher/launcher.c b/launcher/launcher.c
index 20fd7e59..43921106 100644
--- a/launcher/launcher.c
+++ b/launcher/launcher.c
@@ -130,9 +130,19 @@ bool app_loop() {
watch_rtc_register_alarm_callback(cb_alarm_fired, alarm_time, ALARM_MATCH_SS);
watch_register_extwake_callback(BTN_ALARM, cb_alarm_btn_extwake, true);
event.value = 0;
- event.bit.event_type = EVENT_SCREENSAVER;
- widgets[launcher_state.current_widget].loop(event, &launcher_state.launcher_settings, widget_contexts[launcher_state.current_widget]);
- watch_enter_shallow_sleep(true);
+
+ // this is a little mini-runloop.
+ // as long as screensaver_ticks is -1 (i.e. screensaver is active), we wake up here, update the screen, and go right back to sleep.
+ while (launcher_state.screensaver_ticks == -1) {
+ event.bit.event_type = EVENT_SCREENSAVER;
+ widgets[launcher_state.current_widget].loop(event, &launcher_state.launcher_settings, widget_contexts[launcher_state.current_widget]);
+ watch_enter_shallow_sleep(true);
+ }
+ // as soon as screensaver_ticks is reset by the extwake handler, we bail out of the loop and reactivate ourselves.
+ event.bit.event_type = EVENT_ACTIVATE;
+ // this is a hack tho: waking from shallow sleep, app_setup does get called, but it happens before we have reset our ticks.
+ // need to figure out if there's a better heuristic for determining how we woke up.
+ app_setup();
}
bool can_sleep = true;
@@ -175,10 +185,8 @@ void cb_alarm_btn_interrupt() {
}
void cb_alarm_btn_extwake() {
+ // wake up!
_launcher_reset_screensaver_countdown();
- // this is a hack: waking from shallow sleep, app_setup does get called, but it happens before we reset our ticks.
- // need to figure out if there's a better heuristic for determining how we woke up.
- app_setup();
}
void cb_alarm_fired() {