Compare commits
No commits in common. "26b0cd2ab3b8a6d243f0b45167dace0caf4fe67d" and "db38f557a1af4ffb676bbe2f23b6a50eb4a05964" have entirely different histories.
26b0cd2ab3
...
db38f557a1
3 changed files with 18 additions and 50 deletions
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
#include "XPT2046_TouchscreenSOFTSPI.h"
|
#include "XPT2046_TouchscreenSOFTSPI.h"
|
||||||
|
|
||||||
#define Z_THRESHOLD 65
|
#define Z_THRESHOLD 400
|
||||||
#define Z_THRESHOLD_INT 50
|
#define Z_THRESHOLD_INT 75
|
||||||
#define MSEC_THRESHOLD 3
|
#define MSEC_THRESHOLD 3
|
||||||
#define SPI_SETTING SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
#define SPI_SETTING SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -614,42 +614,12 @@ void loop() {
|
||||||
lastTouchX = touchX;
|
lastTouchX = touchX;
|
||||||
lastTouchY = touchY;
|
lastTouchY = touchY;
|
||||||
|
|
||||||
int16_t liveDeltaX = (int16_t)lastTouchX - (int16_t)touchStartX;
|
// Long press check: only trigger if finger was held stationary (displacement < 30px)
|
||||||
int16_t liveDeltaY = (int16_t)lastTouchY - (int16_t)touchStartY;
|
int16_t currentDistX = abs((int16_t)lastTouchX - (int16_t)touchStartX);
|
||||||
|
int16_t currentDistY = abs((int16_t)lastTouchY - (int16_t)touchStartY);
|
||||||
|
|
||||||
// FAST LIVE SWIPE DETECTION:
|
if (!longPressHandled && (millis() - touchStartTime > 1000) && currentDistX < 30 && currentDistY < 30) {
|
||||||
// Trigger immediately as soon as finger moves >= 28px horizontally (no need to lift or press hard)
|
// Long press (> 1s): Open Config Menu immediately!
|
||||||
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;
|
longPressHandled = true;
|
||||||
touchBeep(); // Confirmation chirp
|
touchBeep(); // Confirmation chirp
|
||||||
configMenu();
|
configMenu();
|
||||||
|
|
@ -659,18 +629,16 @@ void loop() {
|
||||||
isTouching = false;
|
isTouching = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Touch / button released
|
// Touch / button released
|
||||||
if (isTouching) {
|
if (isTouching) {
|
||||||
isTouching = false;
|
isTouching = false;
|
||||||
|
|
||||||
if (!longPressHandled) {
|
if (!longPressHandled) {
|
||||||
int16_t deltaX = (int16_t)lastTouchX - (int16_t)touchStartX;
|
int16_t deltaX = (int16_t)lastTouchX - (int16_t)touchStartX;
|
||||||
int16_t deltaY = (int16_t)lastTouchY - (int16_t)touchStartY;
|
int16_t deltaY = (int16_t)lastTouchY - (int16_t)touchStartY;
|
||||||
|
|
||||||
// Quick flick swipe fallback in case finger was lifted very rapidly
|
// Check for horizontal swipe gesture (displacement > 45px, mostly horizontal)
|
||||||
if (deltaX < -25 && abs(deltaY) < 85) {
|
if (deltaX < -45 && abs(deltaY) < 90) {
|
||||||
// SWIPE LEFT: Page 0 -> Page 1 (Tri-Temperature Screen)
|
// SWIPE LEFT: Page 0 -> Page 1 (Tri-Temperature Screen)
|
||||||
if (fullScreenCell != -1) {
|
if (fullScreenCell != -1) {
|
||||||
fullScreenCell = -1;
|
fullScreenCell = -1;
|
||||||
|
|
@ -680,7 +648,7 @@ void loop() {
|
||||||
currentScreenPage = 1;
|
currentScreenPage = 1;
|
||||||
initScreen();
|
initScreen();
|
||||||
}
|
}
|
||||||
} else if (deltaX > 25 && abs(deltaY) < 85) {
|
} else if (deltaX > 45 && abs(deltaY) < 90) {
|
||||||
// SWIPE RIGHT: Page 1 -> Page 0 (4 Quadrants)
|
// SWIPE RIGHT: Page 1 -> Page 0 (4 Quadrants)
|
||||||
if (fullScreenCell != -1) {
|
if (fullScreenCell != -1) {
|
||||||
fullScreenCell = -1;
|
fullScreenCell = -1;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ bool getTouch(uint16_t *x, uint16_t *y) {
|
||||||
TS_Point p = ts.getPoint(tsSoftSpi);
|
TS_Point p = ts.getPoint(tsSoftSpi);
|
||||||
|
|
||||||
// Filter noise: require valid touch pressure and coordinates within active screen
|
// Filter noise: require valid touch pressure and coordinates within active screen
|
||||||
if (p.z < 60) return false;
|
if (p.z < 350) return false;
|
||||||
if (p.x < 150 || p.x > 3850 || p.y < 150 || p.y > 3850) 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);
|
int16_t tx = map(p.x, 200, 3700, 0, 320);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue