psram: mode: octal speed: 80MHz i2c: sda: 8 scl: 9 # CH422G I/O expander (Waveshare uses it for LCD reset/backlight/touch reset) ch422g: - id: ch422g_hub # --- Backlight control (CH422G IO2 is common for Waveshare LCD BL) --- switch: - platform: gpio name: "LCD Backlight Raw" id: lcd_backlight_raw restore_mode: ALWAYS_ON pin: ch422g: ch422g_hub number: 2 mode: output: true # A nicer HA-exposed control (so you can also automate it from HA) light: - platform: binary name: "HA Remote Backlight" output: lcd_backlight_out id: ha_remote_backlight output: - platform: template id: lcd_backlight_out type: binary write_action: - if: condition: lambda: return state; then: - switch.turn_on: lcd_backlight_raw else: - switch.turn_off: lcd_backlight_raw # --- Inactivity tracking (dim/off + wake on touch) --- globals: - id: last_activity_ms type: uint32_t restore_value: no initial_value: '0' interval: - interval: 1s then: - lambda: |- if (id(last_activity_ms) == 0) id(last_activity_ms) = millis(); # Turn off backlight ONCE at 2 minutes idle. - if: condition: lambda: |- const uint32_t idle_s = (millis() - id(last_activity_ms)) / 1000; return idle_s == 120; then: - light.turn_off: ha_remote_backlight # --- Display --- display: - platform: mipi_rgb model: ESP32-S3-TOUCH-LCD-7-800X480 id: main_display update_interval: never auto_clear_enabled: false reset_pin: ch422g: ch422g_hub number: 3 mode: output: true # --- Touch --- touchscreen: platform: gt911 id: touch_panel update_interval: 120ms reset_pin: ch422g: ch422g_hub number: 1 mode: output: true on_touch: then: - lambda: |- id(last_activity_ms) = millis(); - light.turn_on: ha_remote_backlight # --- LVGL UI --- # Note: On ESP32-S3-Touch-LCD-7, GPIO14 is used by the RGB display bus, # so it cannot be reused as ADC for battery telemetry in this display mode.