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:
@@ -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
|
||||
);
|
||||
|
Reference in New Issue
Block a user