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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 3 deletions

View File

@ -181,7 +181,7 @@ void TwoButton::isrSecondary()
void TwoButton::startThread() void TwoButton::startThread()
{ {
if (!OSThread::enabled) { if (!OSThread::enabled) {
OSThread::setInterval(50); OSThread::setInterval(10);
OSThread::enabled = true; OSThread::enabled = true;
} }
} }

View File

@ -210,6 +210,14 @@ bool RadioLibInterface::canSleep()
return res; 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 */ /** Attempt to cancel a previously sent packet. Returns true if a packet was found we could cancel */
bool RadioLibInterface::cancelSending(NodeNum from, PacketId id) bool RadioLibInterface::cancelSending(NodeNum from, PacketId id)
{ {

View File

@ -132,6 +132,11 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified
*/ */
virtual bool isActivelyReceiving() = 0; 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 */ /** 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; virtual bool cancelSending(NodeNum from, PacketId id) override;

View File

@ -29,6 +29,12 @@
#include "graphics/niche/Fonts/FreeSans6pt8bCyrillic.h" #include "graphics/niche/Fonts/FreeSans6pt8bCyrillic.h"
#include <Fonts/FreeSans9pt7b.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() void setupNicheGraphics()
{ {
using namespace NicheGraphics; using namespace NicheGraphics;
@ -115,13 +121,22 @@ void setupNicheGraphics()
buttons->setWiring(TOUCH_BUTTON, PIN_BUTTON_TOUCH); 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->setTiming(TOUCH_BUTTON, 50, 5000); // 5 seconds before latch - limited by T-Echo's capacitive touch IC
buttons->setHandlerDown(TOUCH_BUTTON, [backlight]() { 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(); 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->setHandlerLongPress(TOUCH_BUTTON, [backlight]() { backlight->latch(); });
buttons->setHandlerShortPress(TOUCH_BUTTON, [backlight]() { backlight->off(); }); buttons->setHandlerShortPress(TOUCH_BUTTON, [backlight]() { backlight->off(); });
// Begin handling button events
buttons->start(); buttons->start();
} }