fix(display): make the USER button click immediate, 3 s hold to power off

Power-off now needs a 3 second hold; any shorter press toggles the display.
MomentaryButton reports a CLICK for any release short of its threshold, so
that single value defines both.

The button also felt unreliable - "a brief press doesn't wake it, more often
than not". MomentaryButton's multi-click detection withholds a CLICK for
MULTI_CLICK_WINDOW_MS (280 ms) after release, and folds a second press
arriving inside that window into a DOUBLE_CLICK. Since the handler only acts
on CLICK, an impatient second press produced nothing at all: press, see
nothing, press again, still nothing. Multi-click is now off for these targets,
so CLICK fires on release.

Both settings are build flags defaulted in variants/heltec_v4_r8/target.cpp
and overridden only on the two TFT observer bases, because the companion
builds share this user_btn and do use double/triple click.

DISPLAY_TOUCH_DEBUG additionally logs which input caused a toggle
("Display: button -> on"), so any remaining flake can be attributed to the
button or to a spurious touch read rather than guessed at.
This commit is contained in:
agessaman committed 2026-08-28 15:37:09 -07:00
1 parent 970ae395a8
commit 5da46cc518
6 files changed
+39 -9

No files matched your search

+8 -3
View File
@@ -303,12 +303,17 @@ void UITask::updateActivityRows() {
#endif
#ifdef DISPLAY_TOUCH_TOGGLE
void UITask::toggleDisplay() {
void UITask::toggleDisplay(const char* source) {
if (_display->isOn()) {
_display->turnOff();
} else {
_display->turnOn();
}
#ifdef DISPLAY_TOUCH_DEBUG
Serial.printf("Display: %s -> %s\n", source, _display->isOn() ? "on" : "off");
#else
(void)source;
#endif
#ifdef DISPLAY_REDRAW_ON_CHANGE
_frame_valid = false; // wake draws one complete current frame
#endif
@@ -327,7 +332,7 @@ void UITask::loop() {
if (btnState != _prevBtnState) {
if (btnState == USER_BTN_PRESSED) { // pressed?
#ifdef DISPLAY_TOUCH_TOGGLE
toggleDisplay(); // same action as tapping the panel
toggleDisplay("button"); // same action as tapping the panel
#else
if (_display->isOn()) {
// TODO: any action ?
@@ -371,7 +376,7 @@ void UITask::loop() {
unsigned long now = millis();
if (millisReached(now, _next_touch)) {
_next_touch = now + TOUCH_POLL_MILLIS;
if (_touch.checkTap(now)) toggleDisplay();
if (_touch.checkTap(now)) toggleDisplay("touch");
}
}
#endif