]> git.earman.xyz Git - sensor-watch.git/commitdiff
Add movement_cancel_background_task
authorWesley Ellis <tahnok@gmail.com>
Sat, 1 Jan 2022 19:13:04 +0000 (14:13 -0500)
committerWesley Ellis <tahnok@gmail.com>
Sat, 1 Jan 2022 19:13:04 +0000 (14:13 -0500)
Provide a way for a scheduled background task to be cancelled

movement/movement.c
movement/movement.h

index 3e22ace549116a53fb243d524da9e70aeef2f55d..cde6b24c3c9740ac4423260f4eed83e76ed63a1e 100644 (file)
@@ -157,6 +157,18 @@ void movement_schedule_background_task(watch_date_time date_time) {
     }
 }
 
+void movement_cancel_background_task(void) {
+    scheduled_tasks[movement_state.current_watch_face].reg = 0;
+    bool other_tasks_scheduled = false;
+    for(uint8_t i = 0; i < MOVEMENT_NUM_FACES; i++) {
+        if (scheduled_tasks[i].reg != 0) {
+            other_tasks_scheduled = true;
+            break;
+        }
+    }
+    movement_state.has_scheduled_background_task = other_tasks_scheduled;
+}
+
 void movement_play_signal(void) {
     watch_buzzer_play_note(BUZZER_NOTE_C8, 75);
     watch_buzzer_play_note(BUZZER_NOTE_REST, 100);
index edb1fabc82675c9cdb32bf810b622671d8a53a5c..3706b8dbd6ff14e04400acce1cb6d50e6a3f8a07 100644 (file)
@@ -258,6 +258,10 @@ void movement_request_tick_frequency(uint8_t freq);
 // movement will associate the scheduled task with the currently active face.
 void movement_schedule_background_task(watch_date_time date_time);
 
+// note: watch faces can only cancel their background task when in the foreground, since
+// movement will associate the scheduled task with the currently active face.
+void movement_cancel_background_task(void);
+
 void movement_play_signal(void);
 void movement_play_alarm(void);