I recently purchased a cheap yellow display. Yesterday I was able to connect it to HA with a very basic program to toggle some switches. I updated esphome (it was maybe two months out of date) and now my code does not work. I am in a circle of errors that seem to do with my configuration. Chatgpt cant get me out of the issue.
My hardware is esp32 2432s028 https://www.aliexpress.com/item/1005005616073472.html
My code that worked was:
font:
- file: 'fonts/Arimo-Regular.ttf'
id: arimo96
size: 96
glyphs: "ABKL"
# Create a Home Assistant blue color
color:
- id: ha_blue
hex: 51c0f2
# ============================================================
# Home Assistant related setup
#
light:
- platform: monochromatic
output: backlight_pwm
name: Display Backlight
id: backlight
restore_mode: ALWAYS_ON
# Setup two binary sensors for the two areas for touch
binary_sensor:
- platform: touchscreen
name: "Button A" # This is what Home Assistant sees
x_min: 20
x_max: 140
y_min: 60
y_max: 180
id: button_a
on_press:
- logger.log: "Button A pressed"
- platform: touchscreen
name: "Button B"
x_min: 180
x_max: 300
y_min: 60
y_max: 180
id: button_b
on_press:
- logger.log: "Button B pressed"
# ============================================================
# Hardware related setup
#
# Setup SPI for the display. The ESP32-2432S028R uses separate SPI buses for display and touch
spi:
- id: tft
clk_pin: GPIO14
mosi_pin: GPIO13
miso_pin: GPIO12
- id: touch
clk_pin: GPIO25
mosi_pin: GPIO32
miso_pin: GPIO39
# Setup a pin to control the backlight
output:
- platform: ledc
pin: GPIO21
id: backlight_pwm
display:
- platform: ili9xxx
model: ili9342
spi_id: tft
cs_pin: GPIO15
dc_pin: GPIO2
invert_colors: true
#rotation: 90
lambda: |-
it.fill(id(Color::BLACK));
it.filled_rectangle(20, 60, 120, 120, id(ha_blue));
it.filled_rectangle(180, 60, 120, 120, id(ha_blue));
it.print(80, 120, id(arimo96), TextAlign::CENTER, "K");
it.print(240, 120, id(arimo96), TextAlign::CENTER, "L");
touchscreen:
platform: xpt2046
spi_id: touch
cs_pin: GPIO33
interrupt_pin: GPIO36
update_interval: 50ms
threshold: 400
calibration:
x_min: 3860 # Flip X by swapping min and max
x_max: 340 # Flip X by swapping min and max
y_min: 3860 # Flip Y by swapping min and max
y_max: 280 # Flip Y by swapping min and max
transform:
swap_xy: true # Keep this to account for the original 90° rotation
The error I get is “x_min must be smaller than x_max. To mirror the direction use the ‘transform’ options.” But this code worked yesterday and when I fix this line it just seems to lead to another issue with my settings and on and on.
Any suggestions?
I cant get anything to work now with this display. I have tried doing very simple hello world code and I get endless complaints about my settings.