Added repeated touch in menu

This commit is contained in:
Sjef Verhoeven PE5PVB
2025-01-07 16:48:13 +01:00
parent cc396a7653
commit 4dc9256a1c
3 changed files with 26 additions and 5 deletions
+20 -4
View File
@@ -74,6 +74,7 @@ bool dynamicPTYold;
bool edgebeep; bool edgebeep;
bool externaltune; bool externaltune;
bool findMemoryAF; bool findMemoryAF;
bool firstTouchHandled = false;
bool flashing; bool flashing;
bool fmsi; bool fmsi;
bool fullsearchrds; bool fullsearchrds;
@@ -127,6 +128,7 @@ bool StereoToggle;
bool store; bool store;
bool TAold; bool TAold;
bool TPold; bool TPold;
bool touchrepeat = false;
bool touch_detect; bool touch_detect;
bool tuned; bool tuned;
bool USBmode; bool USBmode;
@@ -406,6 +408,7 @@ unsigned long eonticker;
unsigned long eontickerhold; unsigned long eontickerhold;
unsigned long flashingtimer; unsigned long flashingtimer;
unsigned long keypadtimer; unsigned long keypadtimer;
unsigned long lastTouchTime = 0;
unsigned long lowsignaltimer; unsigned long lowsignaltimer;
unsigned long ModulationpreviousMillis; unsigned long ModulationpreviousMillis;
unsigned long ModulationpeakPreviousMillis; unsigned long ModulationpeakPreviousMillis;
@@ -916,15 +919,28 @@ void setup() {
void loop() { void loop() {
if (hardwaremodel == PORTABLE_TOUCH_ILI9341 && touch_detect) { 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; uint16_t x, y;
tft.getTouch(&x, &y); tft.getTouch(&x, &y);
if (x > 0 || y > 0) { 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(); Communication();
+5 -1
View File
@@ -18,7 +18,10 @@ void doTouchEvent(uint16_t x, uint16_t y) {
if (menuopen) { // Menu navigation if (menuopen) { // Menu navigation
if (x > 18 && x < 78 && y > 150 && y < 190) KeyDown(); // --------------- 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 > 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; return;
} else { } else {
if (x > 8 && x < 158) { if (x > 8 && x < 158) {
@@ -86,6 +89,7 @@ void doTouchEvent(uint16_t x, uint16_t y) {
} }
} }
} }
touchrepeat = true;
return; return;
} }
} }
+1
View File
@@ -18,6 +18,7 @@ extern bool menu;
extern bool menuopen; extern bool menuopen;
extern bool scandxmode; extern bool scandxmode;
extern bool seek; extern bool seek;
extern bool touchrepeat;
extern bool XDRGTKTCP; extern bool XDRGTKTCP;
extern bool XDRGTKUSB; extern bool XDRGTKUSB;
extern byte afpagenr; extern byte afpagenr;