ui: keep the button lock in UITask only, not in prefs

This commit is contained in:
quyenlt298 committed 2026-11-25 11:29:01 +07:00
1 parent 915b6acc27
commit 8f6140b7d3
5 files changed
+10 -33

No files matched your search

-2
View File
@@ -97,7 +97,6 @@ public:
#else
uint8_t ui_gps_action = 0;
#endif
uint8_t ui_button_lock = 0;
#endif
private:
@@ -274,7 +273,6 @@ private:
def("off_keep_msgs", _parent->ui_auto_off_keep_msgs);
def("nd_name", _parent->ui_nd_name);
def("gps_act", _parent->ui_gps_action);
def("btn_lock", _parent->ui_button_lock);
}
public:
UI_Prefs(NodePrefs* parent) : _parent(parent) {}
+6 -7
View File
@@ -214,7 +214,7 @@ class HomeScreen : public UIScreen {
#if UI_HAS_JOYSTICK
// show lock icon left of the other icons when buttons are locked
if (_node_prefs->ui_button_lock) {
if (_task->isLocked()) {
int x = iconX - (charging ? 18 : 9);
#ifdef PIN_BUZZER
if (_task->isBuzzerQuiet()) x -= 9;
@@ -1015,28 +1015,28 @@ void UITask::loop() {
char c = 0;
#if UI_HAS_JOYSTICK
int ev = user_btn.check();
if (_node_prefs->ui_button_lock) ev = handleLocked(ev, KEY_ENTER);
if (_locked) ev = handleLocked(ev, KEY_ENTER);
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_ENTER);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_ENTER); // REVISIT: could be mapped to different key code
}
ev = joystick_left.check();
if (_node_prefs->ui_button_lock) ev = handleLocked(ev, KEY_LEFT);
if (_locked) ev = handleLocked(ev, KEY_LEFT);
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_LEFT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_LEFT);
}
ev = joystick_right.check();
if (_node_prefs->ui_button_lock) ev = handleLocked(ev, KEY_RIGHT);
if (_locked) ev = handleLocked(ev, KEY_RIGHT);
if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_RIGHT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
c = handleLongPress(KEY_RIGHT);
}
ev = back_btn.check();
if (_node_prefs->ui_button_lock && ev != BUTTON_EVENT_NONE
if (_locked && ev != BUTTON_EVENT_NONE
&& ev != BUTTON_EVENT_TRIPLE_CLICK) { // buzzer toggle still works while locked
checkDisplayOn(0);
if (ev == BUTTON_EVENT_DOUBLE_CLICK) { // unlock needs a joystick press within 3 sec
@@ -1280,9 +1280,8 @@ int UITask::handleLocked(int ev, char key) {
}
void UITask::lockButtons(bool lock) {
_node_prefs->ui_button_lock = lock;
_locked = lock;
_unlock_until = 0;
the_mesh->savePrefs(); // keep the lock after a reboot
checkDisplayOn(0);
showAlert(lock ? "Keys locked" : "Unlocked", 800);
}
+4
View File
@@ -76,6 +76,7 @@ class UITask : public AbstractUITask {
unsigned long _analogue_pin_read_millis = millis();
#endif
#if UI_HAS_JOYSTICK
bool _locked = false;
unsigned long _unlock_until = 0;
#endif
@@ -113,6 +114,9 @@ public:
int getMsgCount() const { return _msgcount; }
bool hasDisplay() const { return _display != NULL; }
bool isButtonPressed() const;
#if UI_HAS_JOYSTICK
bool isLocked() const { return _locked; }
#endif
BaseChatMesh* getMesh() const { return the_mesh; }
uint32_t getBLEPin() const { return _ble_pin; }