From 91b6cbfc4b0ce052931103f3b3b341ff8ed0caf5 Mon Sep 17 00:00:00 2001 From: Paxy Date: Sun, 20 Jul 2025 18:26:01 +0200 Subject: [PATCH] Update ButtonThread.cpp Added 4 button click to toggle "Lost and found" role or togle back to Client role. --- src/ButtonThread.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index ec0bc5fc2..8bb073817 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -192,6 +192,24 @@ int32_t ButtonThread::runOnce() screen->forceDisplay(true); // Force a new UI frame, then force an EInk update } break; + + // 4 clicks: toggle Lost and found + case 4: + if (config.device.role == meshtastic_Config_DeviceConfig_Role_CLIENT) { + LOG_WARN("Changing mode to LOST_AND_FOUND"); + config.device.role = meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND; + if (screen) + screen->startAlert("Switching to LOST!"); + nodeDB->saveToDisk(SEGMENT_CONFIG); + }else{ + LOG_WARN("Changing mode to Client"); + config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT; + if (screen) + screen->startAlert("Switching to Client!"); + nodeDB->saveToDisk(SEGMENT_CONFIG); + } + rebootAtMsec = millis() + 5000; + break; #endif #if defined(USE_EINK) && defined(PIN_EINK_EN) // i.e. T-Echo // 4 clicks: toggle backlight @@ -395,4 +413,4 @@ void ButtonThread::userButtonPressedLongStop() if (millis() > c_holdOffTime) { btnEvent = BUTTON_EVENT_LONG_RELEASED; } -} \ No newline at end of file +}