1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 11:22:24 +01:00

Add support for the XPT2046 touchscreen controller (#1542)

This commit is contained in:
Stanislav Meduna
2021-05-17 03:03:58 +02:00
committed by GitHub
parent 9ecead2645
commit d0eaebe19f
6 changed files with 562 additions and 0 deletions

View File

@@ -100,6 +100,15 @@ binary_sensor:
on_state:
then:
- lambda: 'ESP_LOGI("ar1:", "%d", x);'
- platform: xpt2046
xpt2046_id: touchscreen
id: touch_key0
x_min: 80
x_max: 160
y_min: 106
y_max: 212
on_state:
- lambda: 'ESP_LOGI("main", "key0: %s", (x ? "touch" : "release"));'
climate:
- platform: tuya
@@ -180,3 +189,28 @@ external_components:
components: ["bh1750"]
- source: ../esphome/components
components: ["sntp"]
xpt2046:
id: touchscreen
cs_pin: 17
irq_pin: 16
update_interval: 50ms
report_interval: 1s
threshold: 400
dimension_x: 240
dimension_y: 320
calibration_x_min: 3860
calibration_x_max: 280
calibration_y_min: 340
calibration_y_max: 3860
swap_x_y: False
on_state:
- lambda: |-
ESP_LOGI("main", "args x=%d, y=%d, touched=%s", x, y, (touched ? "touch" : "release"));
ESP_LOGI("main", "member x=%d, y=%d, touched=%d, x_raw=%d, y_raw=%d, z_raw=%d",
id(touchscreen).x,
id(touchscreen).y,
(int) id(touchscreen).touched,
id(touchscreen).x_raw,
id(touchscreen).y_raw,
id(touchscreen).z_raw
);