Enhance touchscreen handling: Add threshold for touch sensitivity and filter out phantom touches to improve accuracy
This commit is contained in:
@@ -132,17 +132,26 @@ touchscreen:
|
|||||||
spi_id: tft_spi
|
spi_id: tft_spi
|
||||||
cs_pin: GPIO33
|
cs_pin: GPIO33
|
||||||
interrupt_pin: GPIO36
|
interrupt_pin: GPIO36
|
||||||
|
threshold: 400
|
||||||
calibration:
|
calibration:
|
||||||
x_min: 280
|
x_min: 280
|
||||||
x_max: 3850
|
x_max: 3850
|
||||||
y_min: 340
|
y_min: 340
|
||||||
y_max: 3860
|
y_max: 3860
|
||||||
on_touch:
|
on_release:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
|
// Ignore touches at edges (phantom touches usually report at extremes)
|
||||||
int touch_x = touch.x;
|
int touch_x = touch.x;
|
||||||
int touch_y = touch.y;
|
int touch_y = touch.y;
|
||||||
|
|
||||||
|
// Filter out phantom touches (typically at corners/edges)
|
||||||
|
if (touch_x < 10 || touch_x > 230 || touch_y < 10 || touch_y > 310) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ESP_LOGI("touch", "Valid touch at x=%d, y=%d", touch_x, touch_y);
|
||||||
|
|
||||||
// Penelope button bounds: x=30-210, y=60-140
|
// Penelope button bounds: x=30-210, y=60-140
|
||||||
if (touch_x >= 30 && touch_x <= 210 && touch_y >= 60 && touch_y <= 140) {
|
if (touch_x >= 30 && touch_x <= 210 && touch_y >= 60 && touch_y <= 140) {
|
||||||
id(penelope_medicated).toggle();
|
id(penelope_medicated).toggle();
|
||||||
|
|||||||
Reference in New Issue
Block a user