Hi all,
I am running a ili9341 2.8" TFT display on an ESP32 with ESPHome.
TFT and Touchscreen is working well.
The touch event is also captured. At the moment I am writing to the log and I can see it when I connect to the ESP log file.
But how can I send an event to Home Assistant when the TFT is touched? Maybe sending the X/Y values would be also good.
I don’t want to paste my full code here, but this is the part related to the touchscreen:
touchscreen:
platform: xpt2046
id: my_touchscreen
cs_pin: 14
interrupt_pin: 2
update_interval: 50ms
report_interval: 1s
threshold: 400
calibration_x_min: 324
calibration_x_max: 3759
calibration_y_min: 3885
calibration_y_max: 404
swap_x_y: false
on_touch:
- lambda: |-
ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
id(my_touchscreen).x,
id(my_touchscreen).y,
id(my_touchscreen).x_raw,
id(my_touchscreen).y_raw
);
Br Christian