diff --git a/src/graphics/niche/Inputs/TwoButton.cpp b/src/graphics/niche/Inputs/TwoButton.cpp index 1e91d9080..bd29f981d 100644 --- a/src/graphics/niche/Inputs/TwoButton.cpp +++ b/src/graphics/niche/Inputs/TwoButton.cpp @@ -181,7 +181,7 @@ void TwoButton::isrSecondary() void TwoButton::startThread() { if (!OSThread::enabled) { - OSThread::setInterval(50); + OSThread::setInterval(10); OSThread::enabled = true; } } diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index a6faebff4..e3ef58f14 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -210,6 +210,14 @@ bool RadioLibInterface::canSleep() return res; } +/** Allow other firmware components to ask whether we are currently sending a packet +Initially implemented to protect T-Echo's capacitive touch button from spurious presses during tx +*/ +bool RadioLibInterface::isSending() +{ + return sendingPacket != NULL; +} + /** Attempt to cancel a previously sent packet. Returns true if a packet was found we could cancel */ bool RadioLibInterface::cancelSending(NodeNum from, PacketId id) { diff --git a/src/mesh/RadioLibInterface.h b/src/mesh/RadioLibInterface.h index b24879eaf..9622bd625 100644 --- a/src/mesh/RadioLibInterface.h +++ b/src/mesh/RadioLibInterface.h @@ -132,6 +132,11 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified */ virtual bool isActivelyReceiving() = 0; + /** Are we are currently sending a packet? + * This method is public, intending to expose this information to other firmware components + */ + virtual bool isSending(); + /** Attempt to cancel a previously sent packet. Returns true if a packet was found we could cancel */ virtual bool cancelSending(NodeNum from, PacketId id) override; diff --git a/variants/t-echo/nicheGraphics.h b/variants/t-echo/nicheGraphics.h index 5862dcdfb..af310db25 100644 --- a/variants/t-echo/nicheGraphics.h +++ b/variants/t-echo/nicheGraphics.h @@ -29,6 +29,12 @@ #include "graphics/niche/Fonts/FreeSans6pt8bCyrillic.h" #include +// 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(); }