refactor watch faces to use new advisory API

This commit is contained in:
joeycastillo
2024-09-29 22:14:55 -04:00
parent f843156968
commit cfd04be4fb
31 changed files with 141 additions and 88 deletions

View File

@@ -187,9 +187,10 @@ void lis2dw_logging_face_resign(void *context) {
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;
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.
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;
// 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;
}

View File

@@ -61,14 +61,14 @@ void lis2dw_logging_face_setup(uint8_t watch_face_index, void ** context_ptr);
void lis2dw_logging_face_activate(void *context);
bool lis2dw_logging_face_loop(movement_event_t event, 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){ \
lis2dw_logging_face_setup, \
lis2dw_logging_face_activate, \
lis2dw_logging_face_loop, \
lis2dw_logging_face_resign, \
lis2dw_logging_face_wants_background_task, \
lis2dw_logging_face_advise, \
})
#endif // LIS2DW_LOGGING_FACE_H_