diff options
author | joeycastillo <joeycastillo@utexas.edu> | 2022-10-15 08:52:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-15 08:52:34 -0500 |
commit | 5bd0aafc24afffe33d4a014bc9af9865f708a65b (patch) | |
tree | 67fb27fc62681eb4ebeed186a87e8a7ba9e2056f /movement/movement.c | |
parent | 4d860f482e68f125788248ec63bd2b9a9120183d (diff) | |
parent | 1bb656db91c6b5b9bc4a5cf60c49b14d346731df (diff) | |
download | Sensor-Watch-5bd0aafc24afffe33d4a014bc9af9865f708a65b.tar.gz Sensor-Watch-5bd0aafc24afffe33d4a014bc9af9865f708a65b.tar.bz2 Sensor-Watch-5bd0aafc24afffe33d4a014bc9af9865f708a65b.zip |
Merge pull request #94 from wryun/long-press-home-default
Long press mode button to return to first watch face + fix lag when watch face changes
Diffstat (limited to 'movement/movement.c')
-rw-r--r-- | movement/movement.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/movement/movement.c b/movement/movement.c index d79142ec..8c58b202 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -407,10 +407,16 @@ bool app_loop(void) { if (event.event_type) { event.subsecond = movement_state.subsecond; can_sleep = watch_faces[movement_state.current_watch_face].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_watch_face]); - // escape hatch: a watch face may not resign on EVENT_MODE_BUTTON_DOWN. In that case, a long press of MODE should let them out. - if (event.event_type == EVENT_MODE_LONG_PRESS) { - movement_move_to_next_face(); - can_sleep = false; + + // Long-pressing MODE brings one back to the first face, provided that the watch face hasn't decided to send them elsewhere + // (and we're not currently on the first face). + // Note that it's the face's responsibility to provide some way to get to the next face, so if EVENT_MODE_BUTTON_* is + // used for face functionality EVENT_MODE_LONG_PRESS should probably be handled and next_face() triggered in the face + // (which would effectively disable the normal 'long press to face 0' behaviour). + if (event.event_type == EVENT_MODE_LONG_PRESS + && movement_state.current_watch_face > 0 + && !movement_state.watch_face_changed) { + movement_move_to_face(0); } event.event_type = EVENT_NONE; } @@ -476,7 +482,13 @@ bool app_loop(void) { event.subsecond = 0; - return can_sleep && (movement_state.light_ticks == -1) && !movement_state.is_buzzing; + // if the watch face changed, we can't sleep because we need to update the display. + if (movement_state.watch_face_changed) can_sleep = false; + + // if the buzzer or the LED is on, we need to stay awake to keep the TCC running. + if (movement_state.is_buzzing || movement_state.light_ticks != -1) can_sleep = false; + + return can_sleep; } static movement_event_type_t _figure_out_button_event(bool pin_level, movement_event_type_t button_down_event_type, uint8_t *down_timestamp) { |