diff --git a/esphome/esp-bedside-panel.yaml b/esphome/esp-bedside-panel.yaml index 28d93c1..0069c11 100644 --- a/esphome/esp-bedside-panel.yaml +++ b/esphome/esp-bedside-panel.yaml @@ -6,6 +6,7 @@ # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-bedside-panel.yaml #:########################################################################################:# # VERSIONS: +# V0.7 2026-07-14 Added first landscape LVGL page and Home Assistant test button # V0.6 2026-07-14 Added GT911 touchscreen and touch-coordinate logging # V0.5 2026-07-14 Added corrected JC1060P470 MIPI display configuration and text test # V0.4 2026-07-14 Removed MIPI display test after setup watchdog boot loop; retained backlight-only test @@ -24,7 +25,7 @@ # - Dual USB-C ports # - Camera, speaker connector, microSD and RTC features present on board # -# Confirmed / referenced hardware details: +# Confirmed hardware details: # - Display model: JC1060P470 # - Display interface: MIPI-DSI # - Display reset: GPIO5 @@ -38,29 +39,30 @@ #:########################################################################################:# # OPERATION NOTES: # - Flash this to the ESP32-P4 side of the board. -# - This version is intended to confirm: -# - MIPI-DSI display remains stable -# - Display test text is rendered -# - Backlight brightness remains adjustable from Home Assistant -# - GT911 touchscreen initialises -# - Touch coordinates appear in ESPHome logs -# - Display remains in native landscape orientation for this test. -# - Touch the screen at several locations and inspect the logs. -# - Expected coordinate range is approximately: -# - X: 0 to 1023 -# - Y: 0 to 599 -# - Portrait rotation and LVGL will be added after touch is confirmed. +# - This version introduces LVGL while retaining landscape orientation. +# - The screen displays: +# - A title +# - A connection/status message +# - One large test button +# - Pressing the test button calls Home Assistant to toggle: +# input_boolean.test_touchscreen_button +# - Home Assistant action calls must be enabled for this ESPHome device. +# - Backlight brightness remains adjustable from Home Assistant. +# - Touch coordinates continue to be logged for initial testing. # - This version intentionally does not yet configure: # - Ethernet -# - LVGL +# - Multiple LVGL pages +# - Bedside clock +# - Automatic brightness # - Ambient light sensor # - RTC # - Camera #:########################################################################################:# # OFFLINE NOTES: -# - Display rendering and touch detection operate locally. -# - Home Assistant is not required for the display or touchscreen to work. -# - Backlight state is restored locally after restart. +# - LVGL, display rendering, touch and backlight operate locally. +# - The test button remains visible while Home Assistant is offline. +# - Pressing the button while the API is disconnected will not toggle the +# Home Assistant helper. #:########################################################################################:# #:########################################################################################:# @@ -72,25 +74,24 @@ substitutions: # Device Naming device_name: "esp-bedside-panel" friendly_name: "ESP Bedside Panel" - description_comment: "Guition JC1060P470C_I_W_Y ESP32-P4 7 inch bedside control panel. Display and GT911 touchscreen test. (Layout V1.1)" + description_comment: "Guition JC1060P470C_I_W_Y ESP32-P4 7 inch bedside control panel. First landscape LVGL button test. (Layout V1.1)" device_area: "Bedroom" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. # Project Naming project_name: "Guition.JC1060P470C_I_W_Y" # Project Details - project_version: "v0.6" # Project V denotes release of yaml file, allowing checking of deployed vs latest version + project_version: "v0.7" # Project V denotes release of yaml file, allowing checking of deployed vs latest version # Passwords & Secrets api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names # Device Settings - log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE + log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG, VERBOSE, VERY_VERBOSE update_interval: "60s" # update time for general sensors etc # Display Settings backlight_pin: "GPIO23" backlight_frequency: "1220Hz" - display_update_interval: "5s" # Touchscreen Settings touch_sda_pin: "GPIO7" @@ -98,6 +99,9 @@ substitutions: touch_interrupt_pin: "GPIO21" touch_reset_pin: "GPIO22" + # Home Assistant Test Entity + test_helper_entity: "input_boolean.test_touchscreen_button" + #:########################################################################################:# # PACKAGES: # Included Common Packages @@ -224,12 +228,22 @@ api: level: INFO format: "API connected: ESP Bedside Panel is online" + - lvgl.label.update: + id: connection_status_label + text: "Connected to Home Assistant" + text_color: 0x65D483 + on_client_disconnected: then: - logger.log: level: WARN format: "API disconnected: ESP Bedside Panel is offline from Home Assistant" + - lvgl.label.update: + id: connection_status_label + text: "Home Assistant disconnected" + text_color: 0xF0A45D + #:########################################################################################:# # OTA: # https://esphome.io/components/ota/esphome.html @@ -292,48 +306,9 @@ display: color_order: RGB reset_pin: number: GPIO5 - rotation: 0 hsync_pulse_width: 20 - update_interval: "${display_update_interval}" - auto_clear_enabled: true - lambda: |- - it.fill(Color(8, 12, 18)); - - it.printf( - 512, - 185, - id(font_heading), - Color::WHITE, - TextAlign::CENTER, - "ESPHome Display OK" - ); - - it.printf( - 512, - 270, - id(font_normal), - Color(0, 190, 255), - TextAlign::CENTER, - "Touchscreen Test" - ); - - it.printf( - 512, - 335, - id(font_small), - Color(180, 180, 180), - TextAlign::CENTER, - "Touch the screen and check the ESPHome logs" - ); - - it.printf( - 512, - 390, - id(font_small), - Color(180, 180, 180), - TextAlign::CENTER, - "Expected range: X 0-1023 / Y 0-599" - ); + update_interval: never + auto_clear_enabled: false #:########################################################################################:# # TOUCHSCREEN: @@ -345,18 +320,21 @@ touchscreen: display: main_display i2c_id: touch_i2c address: 0x5D + interrupt_pin: number: "${touch_interrupt_pin}" mode: input: true + reset_pin: number: "${touch_reset_pin}" mode: output: true + on_touch: then: - lambda: |- - ESP_LOGI( + ESP_LOGD( "touch", "Touch detected: x=%d, y=%d, x_raw=%d, y_raw=%d", touch.x, @@ -368,7 +346,7 @@ touchscreen: on_release: then: - logger.log: - level: INFO + level: DEBUG format: "Touch released" #:########################################################################################:# @@ -378,15 +356,147 @@ touchscreen: font: - file: "gfonts://Roboto" id: font_heading - size: 64 + size: 54 + glyphs: + - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + - "abcdefghijklmnopqrstuvwxyz" + - "0123456789" + - " .:-" - file: "gfonts://Roboto" id: font_normal - size: 34 + size: 32 + glyphs: + - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + - "abcdefghijklmnopqrstuvwxyz" + - "0123456789" + - " .:-" - file: "gfonts://Roboto" - id: font_small - size: 24 + id: font_button + size: 42 + glyphs: + - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + - "abcdefghijklmnopqrstuvwxyz" + - "0123456789" + - " .:-" + +#:########################################################################################:# +# LVGL: +# https://esphome.io/components/lvgl/ +#:########################################################################################:# +lvgl: + id: panel_lvgl + + displays: + - main_display + + touchscreens: + - touchscreen_id: main_touchscreen + long_press_time: 500ms + long_press_repeat_time: 200ms + + # Retain the native 1024x600 landscape orientation. + rotation: 0 + + # A partial buffer gives good performance while reducing memory use. + buffer_size: 12% + + log_level: WARN + default_font: font_normal + + theme: + dark_mode: true + + pages: + - id: test_page + bg_color: 0x10151D + bg_opa: COVER + + widgets: + - label: + id: page_title_label + align: TOP_MID + y: 55 + text: "ESPHome LVGL Test" + text_font: font_heading + text_color: 0xFFFFFF + + - label: + id: connection_status_label + align: TOP_MID + y: 135 + text: "Waiting for Home Assistant" + text_font: font_normal + text_color: 0xF0A45D + + - button: + id: ha_test_button + align: CENTER + y: 45 + width: 620 + height: 210 + + bg_color: 0x2678C9 + bg_opa: COVER + border_width: 3 + border_color: 0x70B7F3 + radius: 24 + shadow_width: 18 + shadow_opa: 35% + shadow_spread: 2 + + pressed: + bg_color: 0x185991 + border_color: 0xFFFFFF + transform_width: -8 + transform_height: -8 + + widgets: + - label: + id: ha_test_button_label + align: CENTER + text: "Toggle HA Test Helper" + text_font: font_button + text_color: 0xFFFFFF + + on_click: + then: + - if: + condition: + api.connected: + then: + - homeassistant.action: + action: input_boolean.toggle + data: + entity_id: "${test_helper_entity}" + + - lvgl.label.update: + id: action_result_label + text: "Command sent to Home Assistant" + text_color: 0x65D483 + + - logger.log: + level: INFO + format: "LVGL test button pressed: toggled ${test_helper_entity}" + + else: + - lvgl.label.update: + id: action_result_label + text: "Cannot send: Home Assistant offline" + text_color: 0xEF6A6A + + - logger.log: + level: WARN + format: "LVGL test button pressed while API disconnected" + + - label: + id: action_result_label + align: BOTTOM_MID + y: -70 + text: "Press the button to test LVGL touch" + text_font: font_normal + text_color: 0xAAB5C2 #:########################################################################################:# # SENSORS: @@ -415,9 +525,12 @@ text_sensor: - platform: wifi_info ip_address: name: "${friendly_name} IP Address" + ssid: name: "${friendly_name} Connected SSID" + bssid: name: "${friendly_name} Connected BSSID" + mac_address: name: "${friendly_name} MAC Address" \ No newline at end of file