From 1c0778b00e36832a09f1b074bda9cda8b582889a Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Sun, 12 Jul 2026 15:02:50 +1000 Subject: [PATCH] T-Watch: fix touch method for tw_picker --- examples/companion_radio/MyMesh.h | 2 +- .../lilygo_twatch_s3/TWatchComposeScreens.h | 21 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index cabec53b..163f7685 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -8,7 +8,7 @@ #define FIRMWARE_VER_CODE 11 #ifndef FIRMWARE_BUILD_DATE -#define FIRMWARE_BUILD_DATE "8 July 2026" +#define FIRMWARE_BUILD_DATE "12 July 2026" #endif #ifndef FIRMWARE_VERSION diff --git a/variants/lilygo_twatch_s3/TWatchComposeScreens.h b/variants/lilygo_twatch_s3/TWatchComposeScreens.h index ade7eceb..2c8029c4 100644 --- a/variants/lilygo_twatch_s3/TWatchComposeScreens.h +++ b/variants/lilygo_twatch_s3/TWatchComposeScreens.h @@ -91,6 +91,17 @@ class TWatchChannelPicker : public UIScreen { _highlighted = (uint8_t)((_highlighted + 1) % _numChannels); ensureVisible(); } + // Map a draw-space y coordinate to a channel index, or -1 if the tap is + // above the list or on an empty row. getTouch() returns coords already + // divided by UI_ZOOM, so _downY is directly comparable to the row layout. + int rowAtY(int y) const { + if (y < HEADER_H) return -1; + int i = (y - HEADER_H) / ROW_H; + if (i < 0 || i >= visibleRows()) return -1; + int ci = _scrollTop + i; + if (ci >= _numChannels) return -1; + return ci; + } public: TWatchChannelPicker(DisplayDriver* display) @@ -137,11 +148,11 @@ public: _touchDown = false; unsigned long held = millis() - _downAt; if (_downX < 20 && _downY < HEADER_H) { _wantsExit = true; return; } // back arrow - if (held >= TW_LONG_PRESS_MS) { - if (_numChannels > 0) _confirmed = true; // select highlighted - } else { - if (_downY < _display->height() / 2) moveUp(); else moveDown(); // tap zones - } + int row = rowAtY(_downY); + if (row < 0) return; // tap outside the channel list + _highlighted = (uint8_t)row; // single tap selects the tapped row + ensureVisible(); + if (held >= TW_LONG_PRESS_MS) _confirmed = true; // long press opens it } }