perf(touch): maxima sensibilidad tactil con swipe en tiempo real a 28px y umbral Z a 65

This commit is contained in:
Sebastián Nieto 2026-09-21 23:43:56 -03:00
parent c20e8079be
commit 26b0cd2ab3
3 changed files with 49 additions and 18 deletions

View file

@ -22,8 +22,8 @@
#include "XPT2046_TouchscreenSOFTSPI.h"
#define Z_THRESHOLD 170
#define Z_THRESHOLD_INT 100
#define Z_THRESHOLD 65
#define Z_THRESHOLD_INT 50
#define MSEC_THRESHOLD 3
#define SPI_SETTING SPISettings(2000000, MSBFIRST, SPI_MODE0)

View file

@ -614,19 +614,50 @@ void loop() {
lastTouchX = touchX;
lastTouchY = touchY;
// Long press check: only trigger if finger was held stationary (displacement < 30px)
int16_t currentDistX = abs((int16_t)lastTouchX - (int16_t)touchStartX);
int16_t currentDistY = abs((int16_t)lastTouchY - (int16_t)touchStartY);
int16_t liveDeltaX = (int16_t)lastTouchX - (int16_t)touchStartX;
int16_t liveDeltaY = (int16_t)lastTouchY - (int16_t)touchStartY;
if (!longPressHandled && (millis() - touchStartTime > 1000) && currentDistX < 30 && currentDistY < 30) {
// Long press (> 1s): Open Config Menu immediately!
longPressHandled = true;
touchBeep(); // Confirmation chirp
configMenu();
waitForTouchRelease();
lastActivityTime = millis();
initScreen();
isTouching = false;
// FAST LIVE SWIPE DETECTION:
// Trigger immediately as soon as finger moves >= 28px horizontally (no need to lift or press hard)
if (!longPressHandled) {
if (liveDeltaX < -28 && abs(liveDeltaY) < 85) {
// SWIPE LEFT: Page 0 -> Page 1 (Tri-Temperature Screen)
longPressHandled = true;
if (fullScreenCell != -1) {
fullScreenCell = -1;
}
if (currentScreenPage == 0) {
animateSlideTransition(true);
currentScreenPage = 1;
initScreen();
}
waitForTouchRelease();
isTouching = false;
lastActivityTime = millis();
} else if (liveDeltaX > 28 && abs(liveDeltaY) < 85) {
// SWIPE RIGHT: Page 1 -> Page 0 (4 Quadrants)
longPressHandled = true;
if (fullScreenCell != -1) {
fullScreenCell = -1;
}
if (currentScreenPage == 1) {
animateSlideTransition(false);
currentScreenPage = 0;
initScreen();
}
waitForTouchRelease();
isTouching = false;
lastActivityTime = millis();
} else if ((millis() - touchStartTime > 1000) && abs(liveDeltaX) < 20 && abs(liveDeltaY) < 20) {
// Long press (> 1s) held stationary: Open Config Menu immediately!
longPressHandled = true;
touchBeep(); // Confirmation chirp
configMenu();
waitForTouchRelease();
lastActivityTime = millis();
initScreen();
isTouching = false;
}
}
}
} else {
@ -638,8 +669,8 @@ void loop() {
int16_t deltaX = (int16_t)lastTouchX - (int16_t)touchStartX;
int16_t deltaY = (int16_t)lastTouchY - (int16_t)touchStartY;
// Balanced swipe detection: 40px displacement required, horizontal gesture
if (deltaX < -40 && abs(deltaY) < 90) {
// Quick flick swipe fallback in case finger was lifted very rapidly
if (deltaX < -25 && abs(deltaY) < 85) {
// SWIPE LEFT: Page 0 -> Page 1 (Tri-Temperature Screen)
if (fullScreenCell != -1) {
fullScreenCell = -1;
@ -649,7 +680,7 @@ void loop() {
currentScreenPage = 1;
initScreen();
}
} else if (deltaX > 40 && abs(deltaY) < 90) {
} else if (deltaX > 25 && abs(deltaY) < 85) {
// SWIPE RIGHT: Page 1 -> Page 0 (4 Quadrants)
if (fullScreenCell != -1) {
fullScreenCell = -1;

View file

@ -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 < 160) return false;
if (p.z < 60) 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);