From c20e8079be7e22fc1f994e5df2f30bd12a953f91 Mon Sep 17 00:00:00 2001 From: Sebastian Nieto Date: Mon, 21 Sep 2026 23:40:49 -0300 Subject: [PATCH] fix(touch): calibrar umbral Z a 170 para eliminar toques fantasma con sensibilidad equilibrada --- sketch/obd2_gauge/XPT2046_TouchscreenSOFTSPI.cpp | 4 ++-- sketch/obd2_gauge/obd2_gauge.ino | 7 ++++--- sketch/obd2_gauge/touchscreen.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sketch/obd2_gauge/XPT2046_TouchscreenSOFTSPI.cpp b/sketch/obd2_gauge/XPT2046_TouchscreenSOFTSPI.cpp index 56f25b0..9292dcd 100644 --- a/sketch/obd2_gauge/XPT2046_TouchscreenSOFTSPI.cpp +++ b/sketch/obd2_gauge/XPT2046_TouchscreenSOFTSPI.cpp @@ -22,8 +22,8 @@ #include "XPT2046_TouchscreenSOFTSPI.h" -#define Z_THRESHOLD 400 -#define Z_THRESHOLD_INT 75 +#define Z_THRESHOLD 170 +#define Z_THRESHOLD_INT 100 #define MSEC_THRESHOLD 3 #define SPI_SETTING SPISettings(2000000, MSBFIRST, SPI_MODE0) diff --git a/sketch/obd2_gauge/obd2_gauge.ino b/sketch/obd2_gauge/obd2_gauge.ino index 9550619..816ca45 100644 --- a/sketch/obd2_gauge/obd2_gauge.ino +++ b/sketch/obd2_gauge/obd2_gauge.ino @@ -633,12 +633,13 @@ void loop() { // Touch / button released if (isTouching) { isTouching = false; + if (!longPressHandled) { int16_t deltaX = (int16_t)lastTouchX - (int16_t)touchStartX; int16_t deltaY = (int16_t)lastTouchY - (int16_t)touchStartY; - // Check for horizontal swipe gesture (displacement > 45px, mostly horizontal) - if (deltaX < -45 && abs(deltaY) < 90) { + // Balanced swipe detection: 40px displacement required, horizontal gesture + if (deltaX < -40 && abs(deltaY) < 90) { // SWIPE LEFT: Page 0 -> Page 1 (Tri-Temperature Screen) if (fullScreenCell != -1) { fullScreenCell = -1; @@ -648,7 +649,7 @@ void loop() { currentScreenPage = 1; initScreen(); } - } else if (deltaX > 45 && abs(deltaY) < 90) { + } else if (deltaX > 40 && abs(deltaY) < 90) { // SWIPE RIGHT: Page 1 -> Page 0 (4 Quadrants) if (fullScreenCell != -1) { fullScreenCell = -1; diff --git a/sketch/obd2_gauge/touchscreen.h b/sketch/obd2_gauge/touchscreen.h index 5615fa1..3cf45a9 100644 --- a/sketch/obd2_gauge/touchscreen.h +++ b/sketch/obd2_gauge/touchscreen.h @@ -24,7 +24,7 @@ bool getTouch(uint16_t *x, uint16_t *y) { TS_Point p = ts.getPoint(tsSoftSpi); // Filter noise: require valid touch pressure and coordinates within active screen - if (p.z < 350) return false; + if (p.z < 160) return false; if (p.x < 150 || p.x > 3850 || p.y < 150 || p.y > 3850) return false; int16_t tx = map(p.x, 200, 3700, 0, 320);