--- # Hardware: Sunton ESP32-8048S043 (CYD 4.3", 800x480, capacitive touch) # Pinout: # # Display # R0 GND # R1 GND # R2 GND # R3 45 # R4 48 # R5 47 # R6 21 # R7 14 # G0 GND # G1 GND # G2 5 # G3 6 # G4 7 # G5 15 # G6 16 # G7 4 # B0 GND # B1 GND # B2 GND # B3 8 # B4 3 # B5 46 # B6 9 # B7 1 # DCLK 42 # HSYNC 39 # VSYNC 41 # DE 40 # BL 2 # # Capacitive Touch # TP_INT # TP_RST 38 # TP_SDA 19 # TP_SCL 20 # # SDCARD # TF_CS 10 # SPI_MOSI 11 # SPI_CLK 12 # SPI_MISO 13 # # SPI Conector (HC1.25-4) # SPI_CS 19 # SPI_MOSI 11 # SPI_CLK 12 # SPI_MISO 13 # # UART1 (SH1.0-4) # 1 GND # 2 3V3-ESP # 3 17 # 4 18 # # UART1, USB Connector (Resistive) / I2C (Capacitive) (HC1.25-4) # 1 17 # 2 18 # 3 19 TP_SDA # 4 20 TP_SCL # Used: # GPIO1 main_display (display mipi_rgb data_pins.blue) # GPIO2 gpio_backlight_pwm (output ledc) # GPIO3 main_display (display mipi_rgb data_pins.blue) # GPIO4 main_display (display mipi_rgb data_pins.green) # GPIO5 main_display (display mipi_rgb data_pins.green) # GPIO6 main_display (display mipi_rgb data_pins.green) # GPIO7 main_display (display mipi_rgb data_pins.green) # GPIO8 main_display (display mipi_rgb data_pins.blue) # GPIO9 main_display (display mipi_rgb data_pins.blue) # GPIO14 main_display (display mipi_rgb data_pins.red) # GPIO15 main_display (display mipi_rgb data_pins.green) # GPIO16 main_display (display mipi_rgb data_pins.green) # GPIO19 i2c_main (i2c sda) # GPIO20 i2c_main (i2c scl) # GPIO21 main_display (display mipi_rgb data_pins.red) # GPIO38 main_touch (touchscreen gt911 reset_pin) # GPIO39 main_display (display mipi_rgb hsync_pin) # GPIO40 main_display (display mipi_rgb de_pin) # GPIO41 main_display (display mipi_rgb vsync_pin) # GPIO42 main_display (display mipi_rgb pclk_pin) # GPIO45 main_display (display mipi_rgb data_pins.red) # GPIO46 main_display (display mipi_rgb data_pins.blue) # GPIO47 main_display (display mipi_rgb data_pins.red) # GPIO48 main_display (display mipi_rgb data_pins.red) # I2C: # 0x5D main_touch (touchscreen gt911) substitutions: device: lvgl name: LVGL area: DEV comment: LVGL esphome: name: mcu-${device} friendly_name: ${name} area: ${area} comment: ${comment} on_boot: - priority: -100 then: - lvgl.page.show: status_page esp32: variant: esp32s3 flash_size: 16MB toolchain: esp-idf framework: advanced: flash_chip: gd type: esp-idf # PSRAM bandwidth for the RGB panel (not set by ESPHome); without it the # image shifts during flash/WiFi activity sdkconfig_options: CONFIG_ESP32S3_DATA_CACHE_64KB: y CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y CONFIG_SPIRAM_RODATA: y psram: mode: octal speed: 80MHz packages: common: !include common/common.yaml ipv6_only: !include common/ipv6_only.yaml api: # status page until Home Assistant connects (log viewers don't subscribe to states) on_client_connected: - delay: 2s - if: condition: api.connected: state_subscription_only: true then: - lvgl.page.show: main_page on_client_disconnected: - if: condition: not: api.connected: state_subscription_only: true then: - lvgl.page.show: status_page i2c: - id: i2c_main sda: 19 scl: 20 scan: true # same pins and timing as the 5" Sunton board, pclk lowered for the 4.3" panel display: - platform: mipi_rgb model: ESP32-8048S050 id: main_display color_order: RGB invert_colors: true pclk_frequency: 12.5MHz update_interval: never auto_clear_enabled: false # takes 2.8 seconds to clear the display touchscreen: - platform: gt911 id: main_touch display: main_display i2c_id: i2c_main reset_pin: 38 output: - platform: ledc id: gpio_backlight_pwm pin: 2 frequency: 1220 light: - platform: monochromatic id: back_light name: Backlight output: gpio_backlight_pwm restore_mode: ALWAYS_ON script: - id: update_status then: - lambda: |- // same colors as the other status screens: ok green, waiting orange, details gray static const uint32_t OK = 0x4DD966, WAIT = 0xFFB300; auto set = [](lv_obj_t *label, const std::string &text, uint32_t color) { lv_label_set_text(label, text.c_str()); lv_obj_set_style_text_color(label, lv_color_hex(color), LV_PART_MAIN); }; const bool wifi_ok = wifi::global_wifi_component->is_connected(); set(id(status_wifi), wifi_ok ? str_sprintf("WiFi: connected (%d dBm)", wifi::global_wifi_component->wifi_rssi()) : std::string("WiFi: connecting..."), wifi_ok ? OK : WAIT); // IPv6 first (skip link-local), then IPv4 std::string ips; if (wifi_ok) { char buf[network::IP_ADDRESS_BUFFER_SIZE]; for (bool v6 : {true, false}) { for (auto &ip : wifi::global_wifi_component->get_ip_addresses()) { if (!ip.is_set() || ip.is_ip6() != v6) continue; ip.str_to(buf); if (v6 && strncmp(buf, "fe80", 4) == 0) continue; if (!ips.empty()) ips += "\n"; ips += buf; } } } lv_label_set_text(id(status_ips), ips.c_str()); if (ips.empty()) lv_obj_add_flag(id(status_ips), LV_OBJ_FLAG_HIDDEN); else lv_obj_remove_flag(id(status_ips), LV_OBJ_FLAG_HIDDEN); const bool api_ok = api::global_api_server->is_connected(); set(id(status_ha), api_ok ? "Home Assistant: connected" : "Home Assistant: waiting...", api_ok ? OK : WAIT); const uint32_t up = millis() / 1000; lv_label_set_text(id(status_footer), str_sprintf("ESPHome %s · up %ud %02u:%02u:%02u", ESPHOME_VERSION, up / 86400, (up / 3600) % 24, (up / 60) % 60, up % 60).c_str()); interval: - interval: 1s then: - lvgl.label.update: id: clock_label text: !lambda |- auto now = id(ha_time).now(); if (!now.is_valid()) return std::string("--:--"); return now.strftime("%H:%M"); - if: condition: lvgl.page.is_showing: status_page then: - script.execute: update_status image: - platform: file file: assets/images/made-for-esphome-white-on-black.svg id: esphome_logo resize: 400x118 type: RGB565 transparency: alpha_channel font: - file: "gfonts://Roboto@500" id: font_clock size: 200 glyphs: "0123456789:-" - file: "gfonts://Roboto" id: font_title size: 40 - file: "gfonts://Roboto" id: font_status size: 26 glyphs: "·" glyphsets: [GF_Latin_Kernel] lvgl: log_level: WARN color_depth: 16 bg_color: 0x000000 text_color: 0xFFFFFF theme: buttonmatrix: bg_opa: TRANSP border_width: 0 items: bg_color: 0x2B2F36 text_color: 0xFFFFFF radius: 12 checked: bg_color: 0xE08A00 top_layer: widgets: # same navigation bar as on mcu-lvgl-trainer - buttonmatrix: id: nav_bar align: bottom_mid width: 100% height: 64 pad_all: 4 pad_column: 6 items: text_font: montserrat_28 rows: - buttons: - id: page_prev text: "\uF053" on_press: then: lvgl.page.previous: - id: page_home text: "\uF015" on_press: then: lvgl.page.show: main_page - id: page_next text: "\uF054" on_press: then: lvgl.page.next: pages: # 1: clock - id: main_page widgets: - label: id: clock_label align: CENTER y: -32 text_font: font_clock text: "--:--" # 2: status (shown until Home Assistant connects) - id: status_page on_load: - script.execute: update_status widgets: - image: src: esphome_logo align: TOP_MID y: 16 - label: align: TOP_MID y: 140 text_font: font_title text: "${name}" - obj: id: status_lines x: 60 y: 196 width: 700 height: SIZE_CONTENT bg_opa: TRANSP border_width: 0 pad_all: 0 scrollbar_mode: "OFF" layout: type: flex flex_flow: column pad_row: 8 widgets: - label: id: status_wifi text_font: font_status text: "" - label: id: status_ips text_font: font_status text_color: 0x8C8C8C pad_left: 30 text: "" - label: id: status_ha text_font: font_status text: "" - label: id: status_footer text_font: font_status text_color: 0x8C8C8C text: ""