OK, after some trial and error I finally got the native ESPHome’s st7789v
component to work with LilyGO’s T-Embed. Turns out, sending the SLPOUT
command is required, but should be done as early as possible:
on_boot:
priority: 800
then:
- lambda: |-
id(disp).enable();
id(disp).transfer_byte(0x11);
id(disp).disable();
For the display itself, custom config for the st7789v
can be used:
display:
- platform: st7789v
model: CUSTOM
eightbitcolor: False
rotation: 270
width: 170
height: 320
offset_width: 0
offset_height: 35
backlight_pin: GPIO15
cs_pin: GPIO10
dc_pin: GPIO13
reset_pin: GPIO9
id: disp
lambda: |-
it.strftime(10, 20, id(roboto), "%H:%M", id(home_time).now());
Note how it’s not a 320x170
display, but a rotated 170x320
Here’s the full config, for future reference
esphome:
name: <project-name>
platformio_options:
# build_flags: |-
# -DARDUINO_USB_CDC_ON_BOOT=1 -DLV_CONF_INCLUDE_SIMPLE
board_build.mcu: esp32s3
board_build.name: "LilyGO T-Embed ESP32-S3"
board_build.upload.flash_size: "16MB"
board_build.upload.maximum_size: 16777216
board_build.vendor: "LilyGO"
on_boot:
priority: 800
then:
- lambda: |-
id(disp).enable();
id(disp).transfer_byte(0x11);
id(disp).disable();
- switch.turn_on: power_on
esp32:
board: esp32-s3-devkitc-1
variant: esp32s3
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
spi:
clk_pin: GPIO12
mosi_pin: GPIO11
switch:
- platform: gpio
pin:
number: GPIO46
mode:
output: True
name: "Power On"
id: power_on
- platform: gpio
pin:
number: GPIO15
mode:
output: True
name: "Display Backlight"
id: backlight
time:
- platform: homeassistant
id: home_time
font:
- file: "gfonts://Roboto"
id: roboto
size: 96
display:
- platform: st7789v
model: CUSTOM
eightbitcolor: False
rotation: 270
width: 170
height: 320
offset_width: 0
offset_height: 35
backlight_pin: GPIO15
cs_pin: GPIO10
dc_pin: GPIO13
reset_pin: GPIO9
id: disp
lambda: |-
it.strftime(10, 20, id(roboto), "%H:%M", id(home_time).now());
sensor:
- platform: rotary_encoder
internal: True
name: "Rotary Encoder"
pin_a: GPIO02
pin_b: GPIO01
binary_sensor:
- platform: gpio
pin:
number: GPIO00
inverted: True
name: "Rotary Button"
internal: True