[lvgl] option to enable LVGL's built-in dark theme (#15389)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.14) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.14) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.14) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run CodSpeed benchmarks (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Stale / stale (push) Has been cancelled
Lock closed issues and PRs / lock (push) Has been cancelled
Publish Release / Initialize build (push) Has been cancelled
Publish Release / Build and publish to PyPi (push) Has been cancelled
Publish Release / Build ESPHome amd64 (push) Has been cancelled
Publish Release / Build ESPHome arm64 (push) Has been cancelled
Publish Release / Publish ESPHome docker to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome docker to ghcr (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to ghcr (push) Has been cancelled
Publish Release / deploy-ha-addon-repo (push) Has been cancelled
Publish Release / deploy-esphome-schema (push) Has been cancelled
Publish Release / version-notifier (push) Has been cancelled
Synchronise Device Classes from Home Assistant / Sync Device Classes (push) Has been cancelled

This commit is contained in:
Andrew Rankin
2026-04-05 19:07:42 -04:00
committed by GitHub
parent c7a163441e
commit f23843130e
5 changed files with 13 additions and 5 deletions
+6
View File
@@ -392,6 +392,9 @@ async def to_code(configs):
} & styles_used: } & styles_used:
df.add_define("LV_COLOR_SCREEN_TRANSP", "1") df.add_define("LV_COLOR_SCREEN_TRANSP", "1")
if configs[0].get(df.CONF_THEME, {}).get(df.CONF_DARK_MODE):
df.add_define("LV_THEME_DEFAULT_DARK", "1")
# Currently always need RGB565 for the display buffer, and ARGB8888 is used for layer blending # Currently always need RGB565 for the display buffer, and ARGB8888 is used for layer blending
lv_image_formats = {"RGB565", "ARGB8888"} lv_image_formats = {"RGB565", "ARGB8888"}
if { if {
@@ -459,8 +462,11 @@ def add_hello_world(config):
def _theme_schema(value): def _theme_schema(value):
return cv.Schema( return cv.Schema(
{ {
cv.Optional(df.CONF_DARK_MODE, default=False): cv.boolean,
**{
cv.Optional(name): obj_schema(w).extend(FULL_STYLE_SCHEMA) cv.Optional(name): obj_schema(w).extend(FULL_STYLE_SCHEMA)
for name, w in WIDGET_TYPES.items() for name, w in WIDGET_TYPES.items()
},
} }
)(value) )(value)
+1
View File
@@ -598,6 +598,7 @@ CONF_FLEX_ALIGN_CROSS = "flex_align_cross"
CONF_FLEX_ALIGN_TRACK = "flex_align_track" CONF_FLEX_ALIGN_TRACK = "flex_align_track"
CONF_FLEX_GROW = "flex_grow" CONF_FLEX_GROW = "flex_grow"
CONF_FREEZE = "freeze" CONF_FREEZE = "freeze"
CONF_DARK_MODE = "dark_mode"
CONF_FULL_REFRESH = "full_refresh" CONF_FULL_REFRESH = "full_refresh"
CONF_GRADIENTS = "gradients" CONF_GRADIENTS = "gradients"
CONF_GRID_CELL_ROW_POS = "grid_cell_row_pos" CONF_GRID_CELL_ROW_POS = "grid_cell_row_pos"
+1 -1
View File
@@ -3,7 +3,7 @@
- obj: - obj:
id: hello_world_card_ id: hello_world_card_
pad_all: 12 pad_all: 12
bg_color: white bg_opa: cover
height: 100% height: 100%
width: 100% width: 100%
scrollable: false scrollable: false
+2 -2
View File
@@ -7,7 +7,7 @@ from esphome.core import ID
from .defines import CONF_STYLE_DEFINITIONS, CONF_THEME, LValidator, literal from .defines import CONF_STYLE_DEFINITIONS, CONF_THEME, LValidator, literal
from .helpers import add_lv_use from .helpers import add_lv_use
from .lvcode import LambdaContext, lv from .lvcode import LambdaContext, lv
from .schemas import ALL_STYLES, FULL_STYLE_SCHEMA, remap_property from .schemas import ALL_STYLES, FULL_STYLE_SCHEMA, WIDGET_TYPES, remap_property
from .types import ObjUpdateAction, lv_style_t from .types import ObjUpdateAction, lv_style_t
from .widgets import collect_parts, theme_widget_map, wait_for_widgets from .widgets import collect_parts, theme_widget_map, wait_for_widgets
@@ -85,7 +85,7 @@ async def style_update_to_code(config, action_id, template_arg, args):
async def theme_to_code(config): async def theme_to_code(config):
if theme := config.get(CONF_THEME): if theme := config.get(CONF_THEME):
add_lv_use(CONF_THEME) add_lv_use(CONF_THEME)
for w_name, style in theme.items(): for w_name, style in ((k, v) for k, v in theme.items() if k in WIDGET_TYPES):
# Work around Python 3.10 bug with nested async comprehensions # Work around Python 3.10 bug with nested async comprehensions
# With Python 3.11 this could be simplified # With Python 3.11 this could be simplified
# TODO: Now that we require Python 3.11+, this can be updated to use nested comprehensions # TODO: Now that we require Python 3.11+, this can be updated to use nested comprehensions
+1
View File
@@ -49,6 +49,7 @@ lvgl:
bg_color: 0x000000 bg_color: 0x000000
bg_opa: cover bg_opa: cover
theme: theme:
dark_mode: true
obj: obj:
border_width: 1 border_width: 1