Add daily notification wakeups and a make watchapp packaging target
build / build (push) Successful in 20s
build / build (push) Successful in 20s
Schedules a one-shot Pebble wakeup for the configured notification time, re-arming it on every launch and config change, and vibrates/ refreshes the report when it fires (foreground or fresh launch). Also adds a `make watchapp` target that builds the watchapp via the Pebble SDK and copies a versioned .pbw to dist/, matching `make package`'s version resolution — deliberately not wired into CI, which has no Pebble SDK installed.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "app_message.h"
|
||||
#include "config.h"
|
||||
#include "i18n_tables.h"
|
||||
#include "notify.h"
|
||||
#include "reading_state.h"
|
||||
#include "ui_report_window.h"
|
||||
#include "ui_text_window.h"
|
||||
@@ -26,6 +27,7 @@ static void on_config_updated(const WatchConfig *cfg) {
|
||||
|
||||
config_log(&s_config); /* the values this newly-recomputed reading is based on */
|
||||
reading_state_recompute(&s_config.birth, s_config.gender);
|
||||
notify_reschedule(&s_config); /* settings may have changed notify_enabled/hour/minute */
|
||||
if (was_configured) {
|
||||
report_window_reload();
|
||||
} else {
|
||||
@@ -33,16 +35,36 @@ static void on_config_updated(const WatchConfig *cfg) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Fires only if the scheduled wakeup goes off while this app is already
|
||||
* open (notify_was_wakeup_launch() below covers the far more common
|
||||
* case: the wakeup launching the app fresh). Refreshes the same way a
|
||||
* new day's config submission would, since the report window is already
|
||||
* on screen and the reading may now be for a new day. */
|
||||
static void on_wakeup(WakeupId wakeup_id, int32_t cookie) {
|
||||
(void)wakeup_id;
|
||||
(void)cookie;
|
||||
vibes_double_pulse();
|
||||
if (!s_config.configured) return;
|
||||
reading_state_recompute(&s_config.birth, s_config.gender);
|
||||
report_window_reload();
|
||||
notify_reschedule(&s_config); /* wakeup_schedule() is one-shot - re-arm for tomorrow */
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
config_load(&s_config);
|
||||
watch_i18n_load(s_config.lang);
|
||||
app_message_init(on_config_updated);
|
||||
notify_subscribe(on_wakeup);
|
||||
|
||||
config_log(&s_config); /* the values this session's reading (if any) is based on */
|
||||
|
||||
if (s_config.configured) {
|
||||
reading_state_recompute(&s_config.birth, s_config.gender);
|
||||
report_window_push();
|
||||
notify_reschedule(&s_config); /* wakeup_schedule() is one-shot - re-arm on every launch */
|
||||
if (notify_was_wakeup_launch()) {
|
||||
vibes_double_pulse();
|
||||
}
|
||||
} else {
|
||||
show_setup_required();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user