Hello,
juist want to sum up my struggles getting the combination of an AZ-Touch Mod (version 01-03) and an ESP32 (model AZ-Delivery Dev Kit C) to work with ESPHOME 2022.11 (with the updated touchscreen platfrom).
Using the device in landscape mode with the USB-connector sticking out to the right when viewed from the front (display is thus 270° rotated).
I could not get the touchscreen interrupt to work at all so the touchdevice is polled.
Hope this helps anyone else with the beautiful device. I will put it next to my air-conditioner, modified with an IR-blaster and a temp/hum sensor.
/Mattias
UPDATE: Make sure the ESP32-board is securely installed to the AZ-Touch board! Press down real good to get a good connection. The pins on the ESP32-board are almost too short so any wiggle on the USB-cable is likely cause issues. A sure sign is that screen goes completely white.
esphome:
name: esphome-vp-display
esp32:
board: az-delivery-devkit-v4
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "84338517934eeb7c7de7d33c1f9f9dbe"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Vp-Display"
password: "FiecN2HdFTT0"
captive_portal:
spi:
clk_pin: 18
mosi_pin: 23
miso_pin: 19
id: bus_spi
touchscreen:
platform: xpt2046
id: my_touchscreen
cs_pin: GPIO14
# interrupt_pin: GPIO27
update_interval: 20ms
report_interval: never
threshold: 400
# Using display in landscape mode
# positions go in wrong direction
swap_x_y: false
calibration_x_max: 3848
calibration_x_min: 281
calibration_y_max: 347
calibration_y_min: 3878
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
);
display:
- platform: ili9341
model: TFT 2.4
cs_pin: GPIO5
dc_pin: GPIO4
reset_pin: GPIO22
led_pin: 15
rotation: 270
id: tft_ha
lambda: |-
it.fill(Color::BLACK);
it.print(0, 0, id(my_font), id(my_red), TextAlign::TOP_LEFT, "TOP LEFT");
it.print(320, 0, id(my_font), id(my_red), TextAlign::TOP_RIGHT, "TOP RIGHT");
it.print(0, 240, id(my_font), id(my_red), TextAlign::BOTTOM_LEFT, "BOT LEFT");
it.print(320, 240, id(my_font), id(my_red), TextAlign::BOTTOM_RIGHT, "BOT RIGHT");
it.line( 0, 80, 320, 80);
it.line(0, 160, 320,160);
it.line(80, 0, 80, 240);
it.line(160, 0, 160, 240);
it.line(240, 0, 240, 240);
if (id(my_touchscreen).touched)
it.filled_circle(id(my_touchscreen).x, id(my_touchscreen).y, 10, id(my_red));
color:
- id: my_red
red: 100%
green: 3%
blue: 5%
font:
- file: "arial.ttf"
id: my_font
size: 20
output:
# backlight
- platform: ledc
pin: 15
id: gpio_15_backlight_pwm
inverted: true
light:
# backlight for HA
- platform: monochromatic
output: gpio_15_backlight_pwm
name: "ILI9341 Display Backlight"
id: back_light
restore_mode: ALWAYS_ON