]> git.earman.xyz Git - sensor-watch.git/commitdiff
add request_sleep function to Movement
authorjoeycastillo <joeycastillo@utexas.edu>
Sun, 29 Sep 2024 19:21:43 +0000 (15:21 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Sun, 29 Sep 2024 19:24:43 +0000 (15:24 -0400)
movement.c
movement.h

index 4327ff5e12868b8fa7b73f660ed36673a3468b0c..e31c0ff5814a497937db5bec13aafde8f3e2aa58 100644 (file)
@@ -243,6 +243,15 @@ void movement_cancel_background_task_for_face(uint8_t watch_face_index) {
     movement_state.has_scheduled_background_task = other_tasks_scheduled;
 }
 
+void movement_request_sleep(void) {
+    /// FIXME: for #SecondMovement: This was a feature request to allow watch faces to request sleep.
+    /// Setting the ticks to 1 means the watch will sleep after the next tick. I'd like to say let's
+    /// set it to 0, have the watch face loop return false, and then we'll fall asleep immediately.
+    /// But could this lead to a race condition where the callback decrements to -1 before the loop?
+    /// This is the safest way but consider more testing here.
+    movement_state.le_mode_ticks = 1;
+}
+
 void movement_request_wake() {
     movement_state.needs_wake = true;
     _movement_reset_inactivity_countdown();
index 6b54380fc12e18c425f5f973ae3c80291957345d..15341557d29fabae1c5b29f6def3ded052a7834c 100644 (file)
@@ -314,6 +314,7 @@ void movement_cancel_background_task(void);
 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_sleep(void);
 void movement_request_wake(void);
 
 void movement_play_signal(void);