Fix spurious button presses on some T-Echos (#6590)

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
todd-herbert
2025-04-16 13:33:44 +12:00
committed by GitHub
parent 7e8294dfad
commit cf5c8de92e
4 changed files with 31 additions and 3 deletions

View File

@@ -29,6 +29,12 @@
#include "graphics/niche/Fonts/FreeSans6pt8bCyrillic.h"
#include <Fonts/FreeSans9pt7b.h>
// Special case - fix T-Echo's touch button
// ----------------------------------------
// On a handful of T-Echos, LoRa TX triggers the capacitive touch
// To avoid this, we lockout the button during TX
#include "mesh/RadioLibInterface.h"
void setupNicheGraphics()
{
using namespace NicheGraphics;
@@ -115,13 +121,22 @@ void setupNicheGraphics()
buttons->setWiring(TOUCH_BUTTON, PIN_BUTTON_TOUCH);
buttons->setTiming(TOUCH_BUTTON, 50, 5000); // 5 seconds before latch - limited by T-Echo's capacitive touch IC
buttons->setHandlerDown(TOUCH_BUTTON, [backlight]() {
// Discard the button press if radio is active
// Rare hardware fault: LoRa activity triggers touch button
if (!RadioLibInterface::instance || RadioLibInterface::instance->isSending())
return;
// Backlight on (while held)
backlight->peek();
InkHUD::InkHUD::getInstance()->persistence->settings.optionalMenuItems.backlight =
false; // We've proved user still has the button. No need to make backlight togglable via the menu.
// Handler has run, which confirms touch button wasn't removed as part of DIY build.
// No longer need the fallback backlight toggle in menu.
InkHUD::InkHUD::getInstance()->persistence->settings.optionalMenuItems.backlight = false;
});
buttons->setHandlerLongPress(TOUCH_BUTTON, [backlight]() { backlight->latch(); });
buttons->setHandlerShortPress(TOUCH_BUTTON, [backlight]() { backlight->off(); });
// Begin handling button events
buttons->start();
}