movement: fix unintended timeout short circuiting

Currently, movement drops time out events in case the previous loop
indicates that sleep is not possible due to short circuiting behavior
of logical and in C: if the left-hand side is false, the right hand
side is not evaluated at all, which means the loop is not called.
This was not intended to happen.

Fix it by storing the result in a second boolean variable
and working out the logic after the fact.
This commit is contained in:
Matheus Afonso Martins Moreira 2024-03-05 21:49:32 -03:00
parent 6ca553e648
commit b1adbd548e

View File

@ -533,7 +533,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.