diff --git a/esphome/cat-medication-tracker.yaml b/esphome/cat-medication-tracker.yaml index 1451298..607fc70 100644 --- a/esphome/cat-medication-tracker.yaml +++ b/esphome/cat-medication-tracker.yaml @@ -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();