summaryrefslogtreecommitdiffstats
path: root/movement
diff options
context:
space:
mode:
authorjoeycastillo <joeycastillo@utexas.edu>2022-10-22 13:16:46 -0500
committerjoeycastillo <joeycastillo@utexas.edu>2022-10-22 13:16:46 -0500
commitb56c60868e84d729a4fd76ff5739a08b87153728 (patch)
treec3eb9d6e8698d626faef89336ef785e60b3fe73d /movement
parent86f34b365375b42279febb20fd744da00f9f1118 (diff)
downloadSensor-Watch-b56c60868e84d729a4fd76ff5739a08b87153728.tar.gz
Sensor-Watch-b56c60868e84d729a4fd76ff5739a08b87153728.tar.bz2
Sensor-Watch-b56c60868e84d729a4fd76ff5739a08b87153728.zip
allow watch faces to schedule tasks from background
Diffstat (limited to 'movement')
-rw-r--r--movement/movement.c14
-rw-r--r--movement/movement.h4
2 files changed, 15 insertions, 3 deletions
diff --git a/movement/movement.c b/movement/movement.c
index e904687c..09ebf0c2 100644
--- a/movement/movement.c
+++ b/movement/movement.c
@@ -211,15 +211,23 @@ void movement_move_to_next_face(void) {
}
void movement_schedule_background_task(watch_date_time date_time) {
+ movement_schedule_background_task_for_face(movement_state.current_watch_face, date_time);
+}
+
+void movement_cancel_background_task(void) {
+ movement_cancel_background_task_for_face(movement_state.current_watch_face);
+}
+
+void movement_schedule_background_task_for_face(uint8_t watch_face_index, watch_date_time date_time) {
watch_date_time now = watch_rtc_get_date_time();
if (date_time.reg > now.reg) {
movement_state.has_scheduled_background_task = true;
- scheduled_tasks[movement_state.current_watch_face].reg = date_time.reg;
+ scheduled_tasks[watch_face_index].reg = date_time.reg;
}
}
-void movement_cancel_background_task(void) {
- scheduled_tasks[movement_state.current_watch_face].reg = 0;
+void movement_cancel_background_task_for_face(uint8_t watch_face_index) {
+ scheduled_tasks[watch_face_index].reg = 0;
bool other_tasks_scheduled = false;
for(uint8_t i = 0; i < MOVEMENT_NUM_FACES; i++) {
if (scheduled_tasks[i].reg != 0) {
diff --git a/movement/movement.h b/movement/movement.h
index a013a861..79222e8c 100644
--- a/movement/movement.h
+++ b/movement/movement.h
@@ -292,6 +292,10 @@ void movement_schedule_background_task(watch_date_time date_time);
// movement will associate the scheduled task with the currently active face.
void movement_cancel_background_task(void);
+// these functions should work around the limitation of the above functions, which will be deprecated.
+void movement_schedule_background_task_for_face(uint8_t watch_face_index, watch_date_time date_time);
+void movement_cancel_background_task_for_face(uint8_t watch_face_index);
+
void movement_request_wake(void);
void movement_play_signal(void);