From 4dc9256a1c27ada9dc9023571b2671d4c006c0d9 Mon Sep 17 00:00:00 2001 From: Sjef Verhoeven PE5PVB Date: Tue, 7 Jan 2025 16:48:13 +0100 Subject: [PATCH] Added repeated touch in menu --- TEF6686_ESP32.ino | 24 ++++++++++++++++++++---- src/touch.cpp | 6 +++++- src/touch.h | 1 + 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index ce62c4e..08c14c2 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -74,6 +74,7 @@ bool dynamicPTYold; bool edgebeep; bool externaltune; bool findMemoryAF; +bool firstTouchHandled = false; bool flashing; bool fmsi; bool fullsearchrds; @@ -127,6 +128,7 @@ bool StereoToggle; bool store; bool TAold; bool TPold; +bool touchrepeat = false; bool touch_detect; bool tuned; bool USBmode; @@ -406,6 +408,7 @@ unsigned long eonticker; unsigned long eontickerhold; unsigned long flashingtimer; unsigned long keypadtimer; +unsigned long lastTouchTime = 0; unsigned long lowsignaltimer; unsigned long ModulationpreviousMillis; unsigned long ModulationpeakPreviousMillis; @@ -916,15 +919,28 @@ void setup() { void loop() { if (hardwaremodel == PORTABLE_TOUCH_ILI9341 && touch_detect) { - if (tft.getTouchRawZ() > 100) { + if (tft.getTouchRawZ() > 100) { // Check if the touch is active uint16_t x, y; tft.getTouch(&x, &y); if (x > 0 || y > 0) { - doTouchEvent(x, y); + if (!firstTouchHandled) { + // Handle the initial touch event immediately + doTouchEvent(x, y); + firstTouchHandled = true; // Mark the first touch as handled + lastTouchTime = millis(); // Start tracking the time for the delay + } else if (touchrepeat) { + // Check if the initial 0.5-second delay has passed + if (millis() - lastTouchTime >= 500) { + // Repeat the touch action continuously without delay + doTouchEvent(x, y); + } + } } + } else { + // Touch has been released + firstTouchHandled = false; // Reset the first touch flag + touch_detect = false; // Reset the touch detection flag } - delay(100); - touch_detect = false; } Communication(); diff --git a/src/touch.cpp b/src/touch.cpp index c8281ec..e1e43fe 100644 --- a/src/touch.cpp +++ b/src/touch.cpp @@ -18,7 +18,10 @@ void doTouchEvent(uint16_t x, uint16_t y) { if (menuopen) { // Menu navigation if (x > 18 && x < 78 && y > 150 && y < 190) KeyDown(); // --------------- if (x > 240 && x < 300 && y > 150 && y < 190) KeyUp(); - if ((x > 240 && x < 300 && y > 40 && y < 80) || (x > 130 && x < 190 && y > 150 && y < 190)) ButtonPress(); + if ((x > 240 && x < 300 && y > 40 && y < 80) || (x > 130 && x < 190 && y > 150 && y < 190)) { + touchrepeat = false; + ButtonPress(); + } return; } else { if (x > 8 && x < 158) { @@ -86,6 +89,7 @@ void doTouchEvent(uint16_t x, uint16_t y) { } } } + touchrepeat = true; return; } } diff --git a/src/touch.h b/src/touch.h index ca82208..7d04e98 100644 --- a/src/touch.h +++ b/src/touch.h @@ -18,6 +18,7 @@ extern bool menu; extern bool menuopen; extern bool scandxmode; extern bool seek; +extern bool touchrepeat; extern bool XDRGTKTCP; extern bool XDRGTKUSB; extern byte afpagenr;