Enhance touchscreen handling: Add threshold for touch sensitivity and filter out phantom touches to improve accuracy

This commit is contained in:
Joshua King
2026-03-04 17:16:44 -05:00
parent 72f03f9045
commit 4aecb61673

View File

@@ -132,17 +132,26 @@ touchscreen:
spi_id: tft_spi
cs_pin: GPIO33
interrupt_pin: GPIO36
threshold: 400
calibration:
x_min: 280
x_max: 3850
y_min: 340
y_max: 3860
on_touch:
on_release:
then:
- lambda: |-
// Ignore touches at edges (phantom touches usually report at extremes)
int touch_x = touch.x;
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
if (touch_x >= 30 && touch_x <= 210 && touch_y >= 60 && touch_y <= 140) {
id(penelope_medicated).toggle();