summaryrefslogtreecommitdiffstats
path: root/movement/watch_faces
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-10-23 17:55:19 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-10-23 17:55:19 -0400
commit8475ffcd7aaebcbf17c7188ef96ce01a9730e9b3 (patch)
treedd1a12d5a1a00884c50ff4e8ac472d26764855f3 /movement/watch_faces
parentee1b3c8780c5573a11cdd21620243ef4b0bd8488 (diff)
downloadSensor-Watch-8475ffcd7aaebcbf17c7188ef96ce01a9730e9b3.tar.gz
Sensor-Watch-8475ffcd7aaebcbf17c7188ef96ce01a9730e9b3.tar.bz2
Sensor-Watch-8475ffcd7aaebcbf17c7188ef96ce01a9730e9b3.zip
movement: first crack at background tasks API
Diffstat (limited to 'movement/watch_faces')
-rw-r--r--movement/watch_faces/thermistor/thermistor_logging_face.c17
-rw-r--r--movement/watch_faces/thermistor/thermistor_logging_face.h3
2 files changed, 13 insertions, 7 deletions
diff --git a/movement/watch_faces/thermistor/thermistor_logging_face.c b/movement/watch_faces/thermistor/thermistor_logging_face.c
index 1ff20483..5351ce88 100644
--- a/movement/watch_faces/thermistor/thermistor_logging_face.c
+++ b/movement/watch_faces/thermistor/thermistor_logging_face.c
@@ -63,7 +63,6 @@ void thermistor_logging_face_activate(movement_settings_t *settings, void *conte
bool thermistor_logging_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
thermistor_logger_state_t *logger_state = (thermistor_logger_state_t *)context;
- watch_date_time date_time = watch_rtc_get_date_time();
switch (event.event_type) {
case EVENT_TIMEOUT:
movement_move_to_face(0);
@@ -90,11 +89,9 @@ bool thermistor_logging_face_loop(movement_event_t event, movement_settings_t *s
if (logger_state->ts_ticks && --logger_state->ts_ticks == 0) {
_thermistor_logging_face_update_display(logger_state, settings->bit.use_imperial_units, settings->bit.clock_mode_24h);
}
- // this is just temporary for testing: log a data point every 30 seconds.
- if (date_time.unit.second % 30 == 0 && !logger_state->ts_ticks) {
- _thermistor_logging_face_log_data(logger_state);
- _thermistor_logging_face_update_display(logger_state, settings->bit.use_imperial_units, settings->bit.clock_mode_24h);
- }
+ break;
+ case EVENT_BACKGROUND_TASK:
+ _thermistor_logging_face_log_data(logger_state);
break;
default:
break;
@@ -107,3 +104,11 @@ void thermistor_logging_face_resign(movement_settings_t *settings, void *context
(void) settings;
(void) context;
}
+
+bool thermistor_logging_face_wants_background_task(movement_settings_t *settings, void *context) {
+ (void) settings;
+ (void) context;
+ // 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.
+ return watch_rtc_get_date_time().unit.minute == 0;
+}
diff --git a/movement/watch_faces/thermistor/thermistor_logging_face.h b/movement/watch_faces/thermistor/thermistor_logging_face.h
index 43d441be..ece89396 100644
--- a/movement/watch_faces/thermistor/thermistor_logging_face.h
+++ b/movement/watch_faces/thermistor/thermistor_logging_face.h
@@ -22,13 +22,14 @@ void thermistor_logging_face_setup(movement_settings_t *settings, void ** contex
void thermistor_logging_face_activate(movement_settings_t *settings, void *context);
bool thermistor_logging_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
void thermistor_logging_face_resign(movement_settings_t *settings, void *context);
+bool thermistor_logging_face_wants_background_task(movement_settings_t *settings, void *context);
static const watch_face_t thermistor_logging_face = {
thermistor_logging_face_setup,
thermistor_logging_face_activate,
thermistor_logging_face_loop,
thermistor_logging_face_resign,
- NULL
+ thermistor_logging_face_wants_background_task
};
#endif // THERMISTOR_LOGGING_FACE_H_