fix: Fix cover open being able to bypass lock (whoops) and hopefully fix flickering during password input

This commit is contained in:
3urobeat
2026-09-06 20:25:50 +02:00
parent f2209c338d
commit 47981da98c
+17 -6
View File
@@ -2731,11 +2731,17 @@ void UITask::pollHallSensor() {
digitalWrite(PIN_LED, LOW); // same as the auto-off path -- one less thing lit under a closed cover digitalWrite(PIN_LED, LOW); // same as the auto-off path -- one less thing lit under a closed cover
#endif #endif
} else { // cover opened } else { // cover opened
_locked = false; if (passwordLockEnabled()) { // Redirect flow to usual unlock prompt when password is enabled
syncLockToHome(); _locked = true;
if (_display && !_display->isOn()) _display->turnOn(); if (_display) _display->turnOn();
uint32_t aoff = autoOffMillis(); beginUnlockPrompt();
if (aoff > 0) _auto_off = millis() + aoff; } else {
_locked = false;
syncLockToHome();
if (_display && !_display->isOn()) _display->turnOn();
uint32_t aoff = autoOffMillis();
if (aoff > 0) _auto_off = millis() + aoff;
}
} }
_next_refresh = 0; _next_refresh = 0;
#endif #endif
@@ -2750,7 +2756,7 @@ void UITask::loop() {
uint8_t joy_rot = _node_prefs ? _node_prefs->joystick_rotation : JOYSTICK_ROTATION; uint8_t joy_rot = _node_prefs ? _node_prefs->joystick_rotation : JOYSTICK_ROTATION;
int ev = user_btn.check(); int ev = user_btn.check();
if (ev == BUTTON_EVENT_CLICK) { if (ev == BUTTON_EVENT_CLICK) {
if (back_btn.isPressed()) { if (back_btn.isPressed() && !_unlock_kb) {
// Enter clicked while Back is held — lock/unlock sequence // Enter clicked while Back is held — lock/unlock sequence
if (_display && !_display->isOn()) { if (_display && !_display->isOn()) {
_display->turnOn(); // turn on display so hints are visible _display->turnOn(); // turn on display so hints are visible
@@ -2767,6 +2773,11 @@ void UITask::loop() {
} }
// eat the Enter — don't pass to curr // eat the Enter — don't pass to curr
} else { } else {
// While the password keyboard is open, Back+Enter is just typing
if (_unlock_kb) {
_lock_seq_count = 0;
_lock_seq_ms = 0;
}
enqueueKey(checkDisplayOn(KEY_ENTER)); enqueueKey(checkDisplayOn(KEY_ENTER));
} }
} else if (ev == BUTTON_EVENT_LONG_PRESS) { } else if (ev == BUTTON_EVENT_LONG_PRESS) {