Merge branch 'timeout-event-and-sleep-logic'

Currently, movement drops timeout events in case the previous loop
indicates that sleep is not possible. This is due to unintended
short circuiting behavior of && and is fixed with a temporary variable.

The static qualifier of can_sleep is also removed.

Helped-by: Alex Maestas <git@se30.xyz>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/376
This commit is contained in:
Matheus Afonso Martins Moreira 2024-03-05 22:03:54 -03:00
commit 8bf652f213

View File

@ -537,7 +537,7 @@ bool app_loop(void) {
}
// default to being allowed to sleep by the face.
static bool can_sleep = true;
bool can_sleep = true;
if (event.event_type) {
event.subsecond = movement_state.subsecond;
@ -561,7 +561,8 @@ bool app_loop(void) {
// first trip | can sleep | cannot sleep | can sleep | cannot sleep
// second trip | can sleep | cannot sleep | cannot sleep | can sleep
// && | can sleep | cannot sleep | cannot sleep | cannot sleep
can_sleep = can_sleep && wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
bool can_sleep2 = wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
can_sleep = can_sleep && can_sleep2;
event.event_type = EVENT_NONE;
if (movement_state.settings.bit.to_always && movement_state.current_face_idx != 0) {
// ...but if the user has "timeout always" set, give it the boot.