mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 11:10:29 +08:00
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
This commit is contained in:
commit
5bd0aafc24
|
@ -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) {
|
||||
|
|
|
@ -174,7 +174,11 @@ typedef void (*watch_face_activate)(movement_settings_t *settings, void *context
|
|||
* for a list of all possible event types.
|
||||
* @param settings A pointer to the global Movement settings. @see watch_face_setup.
|
||||
* @param context A pointer to your application's context. @see watch_face_setup.
|
||||
* @return true if Movement can enter STANDBY mode; false to keep it awake. You should almost always return true.
|
||||
* @return true if your watch face is prepared for the system to enter STANDBY mode; false to keep the system awake.
|
||||
* You should almost always return true.
|
||||
* Note that this return value has no effect if your loop function has called movement_move_to_next_face
|
||||
* or movement_move_to_face; in that case, your watch face will resign immediately, and the next watch
|
||||
* face will make the decision on entering standby mode.
|
||||
* @note There are two event types that require some extra thought:
|
||||
The EVENT_LOW_ENERGY_UPDATE event type is a special case. If you are in the foreground when the watch
|
||||
goes into low energy mode, you will receive this tick once a minute (at the top of the minute) so that
|
||||
|
|
Loading…
Reference in a new issue