add request_sleep function to Movement

This commit is contained in:
joeycastillo 2024-09-29 15:21:43 -04:00
parent 66960fe917
commit ff1bbfa7e6
2 changed files with 10 additions and 0 deletions

View 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();

View 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);