View shared configuration
# Tessera Override YAML: Waveshare ESP32-S3-Touch-LCD-4 (WITHOUT "B"), board revision V4.0
# Built on top of the Waveshare 4B profile (packages/waveshare4b.yaml), app 0.4.90, firmware 0.57.0.
# Sources: Waveshare BSP esp32_s3_touch_lcd_4, ESPHome model WAVESHARE-4-480X480,
# github.com/PedanticAvenger/Waveshare_ESP32-S3-TOUCH-LCD-4 (rev 4.0) and the V4.0 schematic.
# Native USB for the log (this board has no USB-UART chip; UART0 goes to the RS485 transceiver)
logger:
hardware_uart: USB_SERIAL_JTAG
# I2C: GT911, CH32V003 expander and RTC on GPIO15/GPIO7
i2c:
id: touch_bus
sda: GPIO15
scl: GPIO7
# IO expander: CH32V003 at 0x24 instead of the 4B's TCA9554
pca9554: !remove
waveshare_io_ch32v003:
- id: expander
i2c_id: touch_bus
# Panel setup over plain GPIOs (CS GPIO42 comes from the display model)
spi:
id: lcd
interface: any
clk_pin: GPIO2
mosi_pin: GPIO1
output:
# Remove the 4B parts: backlight on GPIO4 and the parked setup lines on the TCA9554
- id: !remove gpio_backlight_pwm
- id: !remove lcd_select_idle
- id: !remove lcd_data_idle
- id: !remove lcd_clock_idle
# Backlight: CH32V003 PWM, inverted (low = bright); ESPHome's default safe levels (1..247)
- platform: waveshare_io_ch32v003
id: gpio_backlight_pwm
waveshare_io_ch32v003_id: expander
inverted: true
safe_pwm_levels:
min_value: 1
max_value: 247
switch:
# EXIO5 = SYS_EN: Waveshare's BSP drives it high at start
- platform: gpio
id: board_sys_enable
internal: true
restore_mode: ALWAYS_ON
pin:
waveshare_io_ch32v003: expander
number: 5
mode:
output: true
# EXIO6 = buzzer enable: the expander starts with every line high, so keep it off
- platform: gpio
id: board_buzzer
internal: true
restore_mode: ALWAYS_OFF
pin:
waveshare_io_ch32v003: expander
number: 6
mode:
output: true
# The 4B dims an analog input (gamma 1.0); the CH32V003 PWM takes ESPHome's default gamma
light:
- id: !extend back_light
gamma_correct: 2.8
# Touch: GT911 (schematic V4.0: TP_RST on EXIO1, TP_INT on EXIO2).
# No reset_pin/interrupt_pin: with them, ESPHome's GT911 driver resets the chip through the expander and
# probes it 56 ms later, which failed here every time ("Calibration error"). Without them the expander's
# start (every line high) releases the reset, the display setup takes >150 ms, and only then the driver
# probes 0x5D / 0x14. setup_priority 500 = after the display (600), before LVGL (400).
touchscreen:
- id: !extend ts_touch
setup_priority: 500
substitutions:
# After boot, release TP_INT (input) so the expander does not drive against the GT911
BOOT_BOARD_SETTINGS: |-
id(expander)->pin_mode(2, gpio::FLAG_INPUT);
# Display: ST7701S 480x480 over RGB, reset on EXIO3
display:
- id: !remove my_display
- platform: mipi_rgb
model: WAVESHARE-4-480X480
id: my_display
spi_id: lcd
reset_pin:
waveshare_io_ch32v003: expander
number: 3
mode:
output: true
update_interval: never
auto_clear_enabled: false
# Init sequence from Waveshare's BSP (esp32_s3_touch_lcd_4.c), as in the rev 4.0 community config
init_sequence:
- [0x11, 0x00]
- [0xFF, 0x77, 0x01, 0x00, 0x00, 0x10]
- [0xC0, 0x3B, 0x00]
- [0xC1, 0x0D, 0x02]
- [0xC2, 0x21, 0x08]
- [0xCD, 0x08]
- [0xB0, 0x00, 0x11, 0x18, 0x0E, 0x11, 0x06, 0x07, 0x08, 0x07, 0x22, 0x04, 0x12, 0x0F, 0xAA, 0x31, 0x18]
- [0xB1, 0x00, 0x11, 0x19, 0x0E, 0x12, 0x07, 0x08, 0x08, 0x08, 0x22, 0x04, 0x11, 0x11, 0xA9, 0x32, 0x18]
- [0xFF, 0x77, 0x01, 0x00, 0x00, 0x11]
- [0xB0, 0x60]
- [0xB1, 0x30]
- [0xB2, 0x87]
- [0xB3, 0x80]
- [0xB5, 0x49]
- [0xB7, 0x85]
- [0xB8, 0x21]
- [0xC1, 0x78]
- [0xC2, 0x78]
- delay 20ms
- [0xE0, 0x00, 0x1B, 0x02]
- [0xE1, 0x08, 0xA0, 0x00, 0x00, 0x07, 0xA0, 0x00, 0x00, 0x00, 0x44, 0x44]
- [0xE2, 0x11, 0x11, 0x44, 0x44, 0xED, 0xA0, 0x00, 0x00, 0xEC, 0xA0, 0x00, 0x00]
- [0xE3, 0x00, 0x00, 0x11, 0x11]
- [0xE4, 0x44, 0x44]
- [0xE5, 0x0A, 0xE9, 0xD8, 0xA0, 0x0C, 0xEB, 0xD8, 0xA0, 0x0E, 0xED, 0xD8, 0xA0, 0x10, 0xEF, 0xD8, 0xA0]
- [0xE6, 0x00, 0x00, 0x11, 0x11]
- [0xE7, 0x44, 0x44]
- [0xE8, 0x09, 0xE8, 0xD8, 0xA0, 0x0B, 0xEA, 0xD8, 0xA0, 0x0D, 0xEC, 0xD8, 0xA0, 0x0F, 0xEE, 0xD8, 0xA0]
- [0xEB, 0x02, 0x00, 0xE4, 0xE4, 0x88, 0x00, 0x40]
- [0xEC, 0x3C, 0x00]
- [0xED, 0xAB, 0x89, 0x76, 0x54, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x45, 0x67, 0x98, 0xBA]
- [0xFF, 0x77, 0x01, 0x00, 0x00, 0x00]
Discussion 0
Add a commentStart the conversation
Share an example, ask a question or explain how you would use this.