refactor watch faces to use new advisory API
This commit is contained in:
parent
f843156968
commit
cfd04be4fb
@ -160,7 +160,7 @@ void decimal_time_face_resign(void *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// void decimal_time_face_wants_background_task() {
|
// void decimal_time_face_advise() {
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ void decimal_time_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void decimal_time_face_activate(void *context);
|
void decimal_time_face_activate(void *context);
|
||||||
bool decimal_time_face_loop(movement_event_t event, void *context);
|
bool decimal_time_face_loop(movement_event_t event, void *context);
|
||||||
void decimal_time_face_resign(void *context);
|
void decimal_time_face_resign(void *context);
|
||||||
// void decimal_time_face_wants_background_task();
|
// void decimal_time_face_advise();
|
||||||
|
|
||||||
|
|
||||||
#define decimal_time_face ((const watch_face_t){ \
|
#define decimal_time_face ((const watch_face_t){ \
|
||||||
|
|||||||
@ -225,11 +225,14 @@ void minute_repeater_decimal_face_resign(void *context) {
|
|||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool minute_repeater_decimal_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t minute_repeater_decimal_face_advise(void *context) {
|
||||||
minute_repeater_decimal_state_t *state = (minute_repeater_decimal_state_t *)context;
|
minute_repeater_decimal_state_t *state = (minute_repeater_decimal_state_t *)context;
|
||||||
if (!state->signal_enabled) return false;
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
watch_date_time date_time = watch_rtc_get_date_time();
|
if (state->signal_enabled) {
|
||||||
|
watch_date_time date_time = watch_rtc_get_date_time();
|
||||||
|
retval.wants_background_task = date_time.unit.minute == 0;
|
||||||
|
}
|
||||||
|
|
||||||
return date_time.unit.minute == 0;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,14 +71,14 @@ void minute_repeater_decimal_face_setup(uint8_t watch_face_index, void ** contex
|
|||||||
void minute_repeater_decimal_face_activate(void *context);
|
void minute_repeater_decimal_face_activate(void *context);
|
||||||
bool minute_repeater_decimal_face_loop(movement_event_t event, void *context);
|
bool minute_repeater_decimal_face_loop(movement_event_t event, void *context);
|
||||||
void minute_repeater_decimal_face_resign(void *context);
|
void minute_repeater_decimal_face_resign(void *context);
|
||||||
bool minute_repeater_decimal_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t minute_repeater_decimal_face_advise(void *context);
|
||||||
|
|
||||||
#define minute_repeater_decimal_face ((const watch_face_t){ \
|
#define minute_repeater_decimal_face ((const watch_face_t){ \
|
||||||
minute_repeater_decimal_face_setup, \
|
minute_repeater_decimal_face_setup, \
|
||||||
minute_repeater_decimal_face_activate, \
|
minute_repeater_decimal_face_activate, \
|
||||||
minute_repeater_decimal_face_loop, \
|
minute_repeater_decimal_face_loop, \
|
||||||
minute_repeater_decimal_face_resign, \
|
minute_repeater_decimal_face_resign, \
|
||||||
minute_repeater_decimal_face_wants_background_task, \
|
minute_repeater_decimal_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // MINUTE_REPEATER_DECIMAL_FACE_H_
|
#endif // MINUTE_REPEATER_DECIMAL_FACE_H_
|
||||||
|
|||||||
@ -208,11 +208,14 @@ void repetition_minute_face_resign(void *context) {
|
|||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool repetition_minute_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t repetition_minute_face_advise(void *context) {
|
||||||
repetition_minute_state_t *state = (repetition_minute_state_t *)context;
|
repetition_minute_state_t *state = (repetition_minute_state_t *)context;
|
||||||
if (!state->signal_enabled) return false;
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
watch_date_time date_time = watch_rtc_get_date_time();
|
if (state->signal_enabled) {
|
||||||
|
watch_date_time date_time = watch_rtc_get_date_time();
|
||||||
|
retval.wants_background_task = date_time.unit.minute == 0;
|
||||||
|
}
|
||||||
|
|
||||||
return date_time.unit.minute == 0;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,14 +70,14 @@ void repetition_minute_face_setup(uint8_t watch_face_index, void ** context_ptr)
|
|||||||
void repetition_minute_face_activate(void *context);
|
void repetition_minute_face_activate(void *context);
|
||||||
bool repetition_minute_face_loop(movement_event_t event, void *context);
|
bool repetition_minute_face_loop(movement_event_t event, void *context);
|
||||||
void repetition_minute_face_resign(void *context);
|
void repetition_minute_face_resign(void *context);
|
||||||
bool repetition_minute_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t repetition_minute_face_advise(void *context);
|
||||||
|
|
||||||
#define repetition_minute_face ((const watch_face_t){ \
|
#define repetition_minute_face ((const watch_face_t){ \
|
||||||
repetition_minute_face_setup, \
|
repetition_minute_face_setup, \
|
||||||
repetition_minute_face_activate, \
|
repetition_minute_face_activate, \
|
||||||
repetition_minute_face_loop, \
|
repetition_minute_face_loop, \
|
||||||
repetition_minute_face_resign, \
|
repetition_minute_face_resign, \
|
||||||
repetition_minute_face_wants_background_task, \
|
repetition_minute_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // REPETITION_MINUTE_FACE_H_
|
#endif // REPETITION_MINUTE_FACE_H_
|
||||||
|
|||||||
@ -209,11 +209,14 @@ void simple_clock_bin_led_face_resign(void *context) {
|
|||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simple_clock_bin_led_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t simple_clock_bin_led_face_advise(void *context) {
|
||||||
simple_clock_bin_led_state_t *state = (simple_clock_bin_led_state_t *)context;
|
simple_clock_bin_led_state_t *state = (simple_clock_bin_led_state_t *)context;
|
||||||
if (!state->signal_enabled) return false;
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
watch_date_time date_time = watch_rtc_get_date_time();
|
if (state->signal_enabled) {
|
||||||
|
watch_date_time date_time = watch_rtc_get_date_time();
|
||||||
|
retval.wants_background_task = date_time.unit.minute == 0;
|
||||||
|
}
|
||||||
|
|
||||||
return date_time.unit.minute == 0;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,14 +68,14 @@ void simple_clock_bin_led_face_setup(uint8_t watch_face_index, void ** context_p
|
|||||||
void simple_clock_bin_led_face_activate(void *context);
|
void simple_clock_bin_led_face_activate(void *context);
|
||||||
bool simple_clock_bin_led_face_loop(movement_event_t event, void *context);
|
bool simple_clock_bin_led_face_loop(movement_event_t event, void *context);
|
||||||
void simple_clock_bin_led_face_resign(void *context);
|
void simple_clock_bin_led_face_resign(void *context);
|
||||||
bool simple_clock_bin_led_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t simple_clock_bin_led_face_advise(void *context);
|
||||||
|
|
||||||
#define simple_clock_bin_led_face ((const watch_face_t){ \
|
#define simple_clock_bin_led_face ((const watch_face_t){ \
|
||||||
simple_clock_bin_led_face_setup, \
|
simple_clock_bin_led_face_setup, \
|
||||||
simple_clock_bin_led_face_activate, \
|
simple_clock_bin_led_face_activate, \
|
||||||
simple_clock_bin_led_face_loop, \
|
simple_clock_bin_led_face_loop, \
|
||||||
simple_clock_bin_led_face_resign, \
|
simple_clock_bin_led_face_resign, \
|
||||||
simple_clock_bin_led_face_wants_background_task, \
|
simple_clock_bin_led_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // SIIMPLE_CLOCK_BIN_LED_FACE_H_
|
#endif // SIIMPLE_CLOCK_BIN_LED_FACE_H_
|
||||||
|
|||||||
@ -143,11 +143,14 @@ void weeknumber_clock_face_resign(void *context) {
|
|||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool weeknumber_clock_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t weeknumber_clock_face_advise(void *context) {
|
||||||
weeknumber_clock_state_t *state = (weeknumber_clock_state_t *)context;
|
weeknumber_clock_state_t *state = (weeknumber_clock_state_t *)context;
|
||||||
if (!state->signal_enabled) return false;
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
watch_date_time date_time = watch_rtc_get_date_time();
|
if (state->signal_enabled) {
|
||||||
|
watch_date_time date_time = watch_rtc_get_date_time();
|
||||||
|
retval.wants_background_task = date_time.unit.minute == 0;
|
||||||
|
}
|
||||||
|
|
||||||
return date_time.unit.minute == 0;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,14 +48,14 @@ void weeknumber_clock_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void weeknumber_clock_face_activate(void *context);
|
void weeknumber_clock_face_activate(void *context);
|
||||||
bool weeknumber_clock_face_loop(movement_event_t event, void *context);
|
bool weeknumber_clock_face_loop(movement_event_t event, void *context);
|
||||||
void weeknumber_clock_face_resign(void *context);
|
void weeknumber_clock_face_resign(void *context);
|
||||||
bool weeknumber_clock_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t weeknumber_clock_face_advise(void *context);
|
||||||
|
|
||||||
#define weeknumber_clock_face ((const watch_face_t){ \
|
#define weeknumber_clock_face ((const watch_face_t){ \
|
||||||
weeknumber_clock_face_setup, \
|
weeknumber_clock_face_setup, \
|
||||||
weeknumber_clock_face_activate, \
|
weeknumber_clock_face_activate, \
|
||||||
weeknumber_clock_face_loop, \
|
weeknumber_clock_face_loop, \
|
||||||
weeknumber_clock_face_resign, \
|
weeknumber_clock_face_resign, \
|
||||||
weeknumber_clock_face_wants_background_task, \
|
weeknumber_clock_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // SIMPLE_CLOCK_FACE_H_
|
#endif // SIMPLE_CLOCK_FACE_H_
|
||||||
|
|||||||
@ -77,7 +77,7 @@ void wyoscan_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void wyoscan_face_activate(void *context);
|
void wyoscan_face_activate(void *context);
|
||||||
bool wyoscan_face_loop(movement_event_t event, void *context);
|
bool wyoscan_face_loop(movement_event_t event, void *context);
|
||||||
void wyoscan_face_resign(void *context);
|
void wyoscan_face_resign(void *context);
|
||||||
bool wyoscan_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t wyoscan_face_advise(void *context);
|
||||||
|
|
||||||
#define wyoscan_face ((const watch_face_t){ \
|
#define wyoscan_face ((const watch_face_t){ \
|
||||||
wyoscan_face_setup, \
|
wyoscan_face_setup, \
|
||||||
|
|||||||
@ -232,11 +232,13 @@ void alarm_face_resign(void *context) {
|
|||||||
movement_request_tick_frequency(1);
|
movement_request_tick_frequency(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool alarm_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t alarm_face_advise(void *context) {
|
||||||
alarm_state_t *state = (alarm_state_t *)context;
|
alarm_state_t *state = (alarm_state_t *)context;
|
||||||
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
watch_date_time now = watch_rtc_get_date_time();
|
watch_date_time now = watch_rtc_get_date_time();
|
||||||
// just a failsafe: never fire more than one alarm within a minute
|
// just a failsafe: never fire more than one alarm within a minute
|
||||||
if (state->alarm_handled_minute == now.unit.minute) return false;
|
if (state->alarm_handled_minute == now.unit.minute) return retval;
|
||||||
state->alarm_handled_minute = now.unit.minute;
|
state->alarm_handled_minute = now.unit.minute;
|
||||||
// check the rest
|
// check the rest
|
||||||
for (uint8_t i = 0; i < ALARM_ALARMS; i++) {
|
for (uint8_t i = 0; i < ALARM_ALARMS; i++) {
|
||||||
@ -246,17 +248,24 @@ bool alarm_face_wants_background_task(void *context) {
|
|||||||
state->alarm_playing_idx = i;
|
state->alarm_playing_idx = i;
|
||||||
if (state->alarm[i].day == ALARM_DAY_EACH_DAY || state->alarm[i].day == ALARM_DAY_ONE_TIME) return true;
|
if (state->alarm[i].day == ALARM_DAY_EACH_DAY || state->alarm[i].day == ALARM_DAY_ONE_TIME) return true;
|
||||||
uint8_t weekday_idx = _get_weekday_idx(now);
|
uint8_t weekday_idx = _get_weekday_idx(now);
|
||||||
if (state->alarm[i].day == weekday_idx) return true;
|
if (state->alarm[i].day == weekday_idx) retval.wants_background_task = true;
|
||||||
if (state->alarm[i].day == ALARM_DAY_WORKDAY && weekday_idx < 5) return true;
|
if (state->alarm[i].day == ALARM_DAY_WORKDAY && weekday_idx < 5) retval.wants_background_task = true;
|
||||||
if (state->alarm[i].day == ALARM_DAY_WEEKEND && weekday_idx >= 5) return true;
|
if (state->alarm[i].day == ALARM_DAY_WEEKEND && weekday_idx >= 5) retval.wants_background_task = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (retval.wants_background_task) {
|
||||||
|
// FIXME for #SecondMovement: I think that this replicates the previous behavior of returning true in the conditionals above,
|
||||||
|
// but would like to do more testing
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
state->alarm_handled_minute = -1;
|
state->alarm_handled_minute = -1;
|
||||||
// update the movement's alarm indicator five times an hour
|
// update the movement's alarm indicator five times an hour
|
||||||
if (now.unit.minute % 12 == 0) _alarm_update_alarm_enabled(state);
|
if (now.unit.minute % 12 == 0) _alarm_update_alarm_enabled(state);
|
||||||
return false;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool alarm_face_loop(movement_event_t event, void *context) {
|
bool alarm_face_loop(movement_event_t event, void *context) {
|
||||||
|
|||||||
@ -89,14 +89,14 @@ void alarm_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void alarm_face_activate(void *context);
|
void alarm_face_activate(void *context);
|
||||||
bool alarm_face_loop(movement_event_t event, void *context);
|
bool alarm_face_loop(movement_event_t event, void *context);
|
||||||
void alarm_face_resign(void *context);
|
void alarm_face_resign(void *context);
|
||||||
bool alarm_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t alarm_face_advise(void *context);
|
||||||
|
|
||||||
#define alarm_face ((const watch_face_t){ \
|
#define alarm_face ((const watch_face_t){ \
|
||||||
alarm_face_setup, \
|
alarm_face_setup, \
|
||||||
alarm_face_activate, \
|
alarm_face_activate, \
|
||||||
alarm_face_loop, \
|
alarm_face_loop, \
|
||||||
alarm_face_resign, \
|
alarm_face_resign, \
|
||||||
alarm_face_wants_background_task, \
|
alarm_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // ALARM_FACE_H_
|
#endif // ALARM_FACE_H_
|
||||||
|
|||||||
@ -229,7 +229,7 @@ static void _background_alarm_play(deadline_state_t *state)
|
|||||||
static void _background_alarm_schedule(deadline_state_t *state)
|
static void _background_alarm_schedule(deadline_state_t *state)
|
||||||
{
|
{
|
||||||
/* We simply re-use the scheduling in the background task */
|
/* We simply re-use the scheduling in the background task */
|
||||||
deadline_face_wants_background_task(state);
|
deadline_face_advise(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cancel background alarm */
|
/* Cancel background alarm */
|
||||||
@ -606,7 +606,7 @@ void deadline_face_resign(void *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Want background task */
|
/* Want background task */
|
||||||
bool deadline_face_wants_background_task(void *context)
|
movement_watch_face_advisory_t deadline_face_advise(void *context)
|
||||||
{
|
{
|
||||||
deadline_state_t *state = (deadline_state_t *) context;
|
deadline_state_t *state = (deadline_state_t *) context;
|
||||||
|
|
||||||
|
|||||||
@ -52,14 +52,14 @@ void deadline_face_setup(uint8_t watch_face_index, void **context_ptr);
|
|||||||
void deadline_face_activate(void *context);
|
void deadline_face_activate(void *context);
|
||||||
bool deadline_face_loop(movement_event_t event, void *context);
|
bool deadline_face_loop(movement_event_t event, void *context);
|
||||||
void deadline_face_resign(void *context);
|
void deadline_face_resign(void *context);
|
||||||
bool deadline_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t deadline_face_advise(void *context);
|
||||||
|
|
||||||
#define deadline_face ((const watch_face_t){ \
|
#define deadline_face ((const watch_face_t){ \
|
||||||
deadline_face_setup, \
|
deadline_face_setup, \
|
||||||
deadline_face_activate, \
|
deadline_face_activate, \
|
||||||
deadline_face_loop, \
|
deadline_face_loop, \
|
||||||
deadline_face_resign, \
|
deadline_face_resign, \
|
||||||
deadline_face_wants_background_task \
|
deadline_face_advise \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // DEADLINE_FACE_H_
|
#endif // DEADLINE_FACE_H_
|
||||||
|
|||||||
@ -124,26 +124,36 @@ void ships_bell_face_resign(void *context) {
|
|||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ships_bell_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t ships_bell_face_advise(void *context) {
|
||||||
|
|
||||||
ships_bell_state_t *state = (ships_bell_state_t *) context;
|
ships_bell_state_t *state = (ships_bell_state_t *) context;
|
||||||
if (!state->bell_enabled) return false;
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
|
if (!state->bell_enabled) return retval;
|
||||||
|
|
||||||
watch_date_time date_time = watch_rtc_get_date_time();
|
watch_date_time date_time = watch_rtc_get_date_time();
|
||||||
if (!(date_time.unit.minute == 0 || date_time.unit.minute == 30)) return false;
|
if (!(date_time.unit.minute == 0 || date_time.unit.minute == 30)) return retval;
|
||||||
|
|
||||||
date_time.unit.hour %= 12;
|
date_time.unit.hour %= 12;
|
||||||
|
// #SecondMovement: This was migrated to the new advisory API but not tested. Needs more testing!
|
||||||
switch (state->on_watch) {
|
switch (state->on_watch) {
|
||||||
case 1:
|
case 1:
|
||||||
return (date_time.unit.hour >= 4 && date_time.unit.hour < 8) ||
|
if ((date_time.unit.hour >= 4 && date_time.unit.hour < 8) ||
|
||||||
(date_time.unit.hour == 8 && date_time.unit.minute == 0);
|
(date_time.unit.hour == 8 && date_time.unit.minute == 0))
|
||||||
|
retval.wants_background_task = true;
|
||||||
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
return (date_time.unit.hour >= 8 && date_time.unit.hour < 12) ||
|
if ((date_time.unit.hour >= 8 && date_time.unit.hour < 12) ||
|
||||||
(date_time.unit.hour == 0 && date_time.unit.minute == 0);
|
(date_time.unit.hour == 0 && date_time.unit.minute == 0))
|
||||||
|
retval.wants_background_task = true;
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
return (date_time.unit.hour >= 0 && date_time.unit.hour < 4) ||
|
if ((date_time.unit.hour >= 0 && date_time.unit.hour < 4) ||
|
||||||
(date_time.unit.hour == 4 && date_time.unit.minute == 0);
|
(date_time.unit.hour == 4 && date_time.unit.minute == 0))
|
||||||
|
retval.wants_background_task = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return true;
|
retval.wants_background_task = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,14 +55,14 @@ void ships_bell_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void ships_bell_face_activate(void *context);
|
void ships_bell_face_activate(void *context);
|
||||||
bool ships_bell_face_loop(movement_event_t event, void *context);
|
bool ships_bell_face_loop(movement_event_t event, void *context);
|
||||||
void ships_bell_face_resign(void *context);
|
void ships_bell_face_resign(void *context);
|
||||||
bool ships_bell_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t ships_bell_face_advise(void *context);
|
||||||
|
|
||||||
#define ships_bell_face ((const watch_face_t){ \
|
#define ships_bell_face ((const watch_face_t){ \
|
||||||
ships_bell_face_setup, \
|
ships_bell_face_setup, \
|
||||||
ships_bell_face_activate, \
|
ships_bell_face_activate, \
|
||||||
ships_bell_face_loop, \
|
ships_bell_face_loop, \
|
||||||
ships_bell_face_resign, \
|
ships_bell_face_resign, \
|
||||||
ships_bell_face_wants_background_task, \
|
ships_bell_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // SHIPS_BELL_FACE_H_
|
#endif // SHIPS_BELL_FACE_H_
|
||||||
|
|||||||
@ -133,10 +133,13 @@ void tempchart_face_resign(void *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//background freq correction
|
//background freq correction
|
||||||
bool tempchart_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t tempchart_face_advise(void *context) {
|
||||||
(void) context;
|
(void) context;
|
||||||
watch_date_time date_time = watch_rtc_get_date_time();
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
//Updating data every 5 minutes
|
watch_date_time date_time = watch_rtc_get_date_time();
|
||||||
return date_time.unit.minute % 5 == 0;
|
// Updating data every 5 minutes
|
||||||
|
retval.wants_background_task = date_time.unit.minute % 5 == 0;
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ void tempchart_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void tempchart_face_activate(void *context);
|
void tempchart_face_activate(void *context);
|
||||||
bool tempchart_face_loop(movement_event_t event, void *context);
|
bool tempchart_face_loop(movement_event_t event, void *context);
|
||||||
void tempchart_face_resign(void *context);
|
void tempchart_face_resign(void *context);
|
||||||
bool tempchart_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t tempchart_face_advise(void *context);
|
||||||
|
|
||||||
|
|
||||||
#define tempchart_face ((const watch_face_t){ \
|
#define tempchart_face ((const watch_face_t){ \
|
||||||
@ -52,7 +52,7 @@ bool tempchart_face_wants_background_task(void *context);
|
|||||||
tempchart_face_activate, \
|
tempchart_face_activate, \
|
||||||
tempchart_face_loop, \
|
tempchart_face_loop, \
|
||||||
tempchart_face_resign, \
|
tempchart_face_resign, \
|
||||||
tempchart_face_wants_background_task, \
|
tempchart_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // TEMPCHART_FACE_H_
|
#endif // TEMPCHART_FACE_H_
|
||||||
|
|||||||
@ -80,14 +80,14 @@ void wake_face_resign(void *context) {
|
|||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wake_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t wake_face_advise(void *context) {
|
||||||
wake_face_state_t *state = (wake_face_state_t *)context;
|
wake_face_state_t *state = (wake_face_state_t *)context;
|
||||||
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
bool rc = false;
|
|
||||||
if ( state->mode ) {
|
if ( state->mode ) {
|
||||||
watch_date_time now = watch_rtc_get_date_time();
|
watch_date_time now = watch_rtc_get_date_time();
|
||||||
rc = state->hour==now.unit.hour && state->minute==now.unit.minute;
|
retval.wants_background_task = state->hour==now.unit.hour && state->minute==now.unit.minute;
|
||||||
// We’re at the mercy of the wants_background_task handler
|
// We’re at the mercy of the advise handler
|
||||||
// In Safari, the emulator triggers at the ›end‹ of the minute
|
// In Safari, the emulator triggers at the ›end‹ of the minute
|
||||||
// Converting to Unix timestamps and taking a difference between now and wake
|
// Converting to Unix timestamps and taking a difference between now and wake
|
||||||
// is not an easy win — because the timestamp for wake has to rely on now
|
// is not an easy win — because the timestamp for wake has to rely on now
|
||||||
@ -95,7 +95,8 @@ bool wake_face_wants_background_task(void *context) {
|
|||||||
// of now. If it is, take tomorrow’s date, calculating month and year rollover
|
// of now. If it is, take tomorrow’s date, calculating month and year rollover
|
||||||
// if need be.
|
// if need be.
|
||||||
}
|
}
|
||||||
return rc;
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wake_face_loop(movement_event_t event, void *context) {
|
bool wake_face_loop(movement_event_t event, void *context) {
|
||||||
|
|||||||
@ -52,14 +52,14 @@ void wake_face_setup(uint8_t watch_face_index, void **context_ptr);
|
|||||||
void wake_face_activate(void *context);
|
void wake_face_activate(void *context);
|
||||||
bool wake_face_loop(movement_event_t event, void *context);
|
bool wake_face_loop(movement_event_t event, void *context);
|
||||||
void wake_face_resign(void *context);
|
void wake_face_resign(void *context);
|
||||||
bool wake_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t wake_face_advise(void *context);
|
||||||
|
|
||||||
#define wake_face ((const watch_face_t){ \
|
#define wake_face ((const watch_face_t){ \
|
||||||
wake_face_setup, \
|
wake_face_setup, \
|
||||||
wake_face_activate, \
|
wake_face_activate, \
|
||||||
wake_face_loop, \
|
wake_face_loop, \
|
||||||
wake_face_resign, \
|
wake_face_resign, \
|
||||||
wake_face_wants_background_task \
|
wake_face_advise \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // WAKE_FACE_H_
|
#endif // WAKE_FACE_H_
|
||||||
|
|||||||
@ -187,9 +187,10 @@ void lis2dw_logging_face_resign(void *context) {
|
|||||||
watch_disable_digital_input(A4);
|
watch_disable_digital_input(A4);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lis2dw_logging_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t lis2dw_logging_face_advise(void *context) {
|
||||||
lis2dw_logger_state_t *logger_state = (lis2dw_logger_state_t *)context;
|
lis2dw_logger_state_t *logger_state = (lis2dw_logger_state_t *)context;
|
||||||
watch_date_time date_time = watch_rtc_get_date_time();
|
watch_date_time date_time = watch_rtc_get_date_time();
|
||||||
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
// this is kind of an abuse of the API, but, let's use the 1 minute tick to shift all our data over.
|
// this is kind of an abuse of the API, but, let's use the 1 minute tick to shift all our data over.
|
||||||
logger_state->interrupts[2] = logger_state->interrupts[1];
|
logger_state->interrupts[2] = logger_state->interrupts[1];
|
||||||
@ -197,5 +198,7 @@ bool lis2dw_logging_face_wants_background_task(void *context) {
|
|||||||
logger_state->interrupts[0] = 0;
|
logger_state->interrupts[0] = 0;
|
||||||
|
|
||||||
// and do our logging task every 15 minutes
|
// and do our logging task every 15 minutes
|
||||||
return (date_time.unit.minute % 15) == 0;
|
retval.wants_background_task = date_time.unit.minute % 15 == 0;
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,14 +61,14 @@ void lis2dw_logging_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void lis2dw_logging_face_activate(void *context);
|
void lis2dw_logging_face_activate(void *context);
|
||||||
bool lis2dw_logging_face_loop(movement_event_t event, void *context);
|
bool lis2dw_logging_face_loop(movement_event_t event, void *context);
|
||||||
void lis2dw_logging_face_resign(void *context);
|
void lis2dw_logging_face_resign(void *context);
|
||||||
bool lis2dw_logging_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t lis2dw_logging_face_advise(void *context);
|
||||||
|
|
||||||
#define lis2dw_logging_face ((const watch_face_t){ \
|
#define lis2dw_logging_face ((const watch_face_t){ \
|
||||||
lis2dw_logging_face_setup, \
|
lis2dw_logging_face_setup, \
|
||||||
lis2dw_logging_face_activate, \
|
lis2dw_logging_face_activate, \
|
||||||
lis2dw_logging_face_loop, \
|
lis2dw_logging_face_loop, \
|
||||||
lis2dw_logging_face_resign, \
|
lis2dw_logging_face_resign, \
|
||||||
lis2dw_logging_face_wants_background_task, \
|
lis2dw_logging_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // LIS2DW_LOGGING_FACE_H_
|
#endif // LIS2DW_LOGGING_FACE_H_
|
||||||
|
|||||||
@ -153,7 +153,9 @@ void accel_interrupt_count_face_resign(void *context) {
|
|||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool accel_interrupt_count_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t accel_interrupt_count_face_advise(void *context) {
|
||||||
(void) context;
|
(void) context;
|
||||||
return false;
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,12 +47,12 @@ void accel_interrupt_count_face_setup(uint8_t watch_face_index, void ** context_
|
|||||||
void accel_interrupt_count_face_activate(void *context);
|
void accel_interrupt_count_face_activate(void *context);
|
||||||
bool accel_interrupt_count_face_loop(movement_event_t event, void *context);
|
bool accel_interrupt_count_face_loop(movement_event_t event, void *context);
|
||||||
void accel_interrupt_count_face_resign(void *context);
|
void accel_interrupt_count_face_resign(void *context);
|
||||||
bool accel_interrupt_count_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t accel_interrupt_count_face_advise(void *context);
|
||||||
|
|
||||||
#define accel_interrupt_count_face ((const watch_face_t){ \
|
#define accel_interrupt_count_face ((const watch_face_t){ \
|
||||||
accel_interrupt_count_face_setup, \
|
accel_interrupt_count_face_setup, \
|
||||||
accel_interrupt_count_face_activate, \
|
accel_interrupt_count_face_activate, \
|
||||||
accel_interrupt_count_face_loop, \
|
accel_interrupt_count_face_loop, \
|
||||||
accel_interrupt_count_face_resign, \
|
accel_interrupt_count_face_resign, \
|
||||||
accel_interrupt_count_face_wants_background_task, \
|
accel_interrupt_count_face_advise, \
|
||||||
})
|
})
|
||||||
|
|||||||
@ -143,8 +143,13 @@ void minmax_face_resign(void *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool minmax_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t minmax_face_advise(void *context) {
|
||||||
(void) context;
|
(void) context;
|
||||||
|
|
||||||
// this will get called at the top of each minute; always request bg task
|
// this will get called at the top of each minute; always request bg task
|
||||||
return true;
|
movement_watch_face_advisory_t retval = {
|
||||||
|
.wants_background_task = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,14 +55,14 @@ void minmax_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void minmax_face_activate(void *context);
|
void minmax_face_activate(void *context);
|
||||||
bool minmax_face_loop(movement_event_t event, void *context);
|
bool minmax_face_loop(movement_event_t event, void *context);
|
||||||
void minmax_face_resign(void *context);
|
void minmax_face_resign(void *context);
|
||||||
bool minmax_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t minmax_face_advise(void *context);
|
||||||
|
|
||||||
#define minmax_face ((const watch_face_t){ \
|
#define minmax_face ((const watch_face_t){ \
|
||||||
minmax_face_setup, \
|
minmax_face_setup, \
|
||||||
minmax_face_activate, \
|
minmax_face_activate, \
|
||||||
minmax_face_loop, \
|
minmax_face_loop, \
|
||||||
minmax_face_resign, \
|
minmax_face_resign, \
|
||||||
minmax_face_wants_background_task, \
|
minmax_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // MINMAX_FACE_H_
|
#endif // MINMAX_FACE_H_
|
||||||
|
|||||||
@ -127,9 +127,13 @@ void thermistor_logging_face_resign(void *context) {
|
|||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool thermistor_logging_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t thermistor_logging_face_advise(void *context) {
|
||||||
(void) context;
|
(void) context;
|
||||||
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
|
|
||||||
// this will get called at the top of each minute, so all we check is if we're at the top of the hour as well.
|
// this will get called at the top of each minute, so all we check is if we're at the top of the hour as well.
|
||||||
// if we are, we ask for a background task.
|
// if we are, we ask for a background task.
|
||||||
return watch_rtc_get_date_time().unit.minute == 0;
|
retval.wants_background_task = watch_rtc_get_date_time().unit.minute == 0;
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,14 +74,14 @@ void thermistor_logging_face_setup(uint8_t watch_face_index, void ** context_ptr
|
|||||||
void thermistor_logging_face_activate(void *context);
|
void thermistor_logging_face_activate(void *context);
|
||||||
bool thermistor_logging_face_loop(movement_event_t event, void *context);
|
bool thermistor_logging_face_loop(movement_event_t event, void *context);
|
||||||
void thermistor_logging_face_resign(void *context);
|
void thermistor_logging_face_resign(void *context);
|
||||||
bool thermistor_logging_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t thermistor_logging_face_advise(void *context);
|
||||||
|
|
||||||
#define thermistor_logging_face ((const watch_face_t){ \
|
#define thermistor_logging_face ((const watch_face_t){ \
|
||||||
thermistor_logging_face_setup, \
|
thermistor_logging_face_setup, \
|
||||||
thermistor_logging_face_activate, \
|
thermistor_logging_face_activate, \
|
||||||
thermistor_logging_face_loop, \
|
thermistor_logging_face_loop, \
|
||||||
thermistor_logging_face_resign, \
|
thermistor_logging_face_resign, \
|
||||||
thermistor_logging_face_wants_background_task, \
|
thermistor_logging_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // THERMISTOR_LOGGING_FACE_H_
|
#endif // THERMISTOR_LOGGING_FACE_H_
|
||||||
|
|||||||
@ -361,11 +361,15 @@ void nanosec_face_resign(void *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Background freq correction
|
// Background freq correction
|
||||||
bool nanosec_face_wants_background_task(void *context) {
|
movement_watch_face_advisory_t nanosec_face_advise(void *context) {
|
||||||
(void) context;
|
(void) context;
|
||||||
if (nanosec_state.correction_profile == 0)
|
movement_watch_face_advisory_t retval = { 0 };
|
||||||
return 0; // No need for background correction if we are on profile 0 - static hardware correction.
|
|
||||||
watch_date_time date_time = watch_rtc_get_date_time();
|
|
||||||
|
|
||||||
return date_time.unit.minute % nanosec_state.correction_cadence == 0;
|
// No need for background correction if we are on profile 0 - static hardware correction.
|
||||||
|
if (nanosec_state.correction_profile != 0) {
|
||||||
|
watch_date_time date_time = watch_rtc_get_date_time();
|
||||||
|
retval.wants_background_task = date_time.unit.minute % nanosec_state.correction_cadence == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,7 +90,7 @@ void nanosec_face_setup(uint8_t watch_face_index, void ** context_ptr);
|
|||||||
void nanosec_face_activate(void *context);
|
void nanosec_face_activate(void *context);
|
||||||
bool nanosec_face_loop(movement_event_t event, void *context);
|
bool nanosec_face_loop(movement_event_t event, void *context);
|
||||||
void nanosec_face_resign(void *context);
|
void nanosec_face_resign(void *context);
|
||||||
bool nanosec_face_wants_background_task(void *context);
|
movement_watch_face_advisory_t nanosec_face_advise(void *context);
|
||||||
void nanosec_ui_save(void);
|
void nanosec_ui_save(void);
|
||||||
void nanosec_save(void);
|
void nanosec_save(void);
|
||||||
float nanosec_get_aging(void);
|
float nanosec_get_aging(void);
|
||||||
@ -101,7 +101,7 @@ float nanosec_get_aging(void);
|
|||||||
nanosec_face_activate, \
|
nanosec_face_activate, \
|
||||||
nanosec_face_loop, \
|
nanosec_face_loop, \
|
||||||
nanosec_face_resign, \
|
nanosec_face_resign, \
|
||||||
nanosec_face_wants_background_task, \
|
nanosec_face_advise, \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif // NANOSEC_FACE_H_
|
#endif // NANOSEC_FACE_H_
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user