Skip to content

Commit

Permalink
add request_sleep function to Movement
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycastillo committed Sep 29, 2024
1 parent 66960fe commit ff1bbfa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ff1bbfa

Please sign in to comment.