[lvgl] Ensure images are configured before using them. (Bugfix) (#7721)

This commit is contained in:
Clyde Stubbs 2024-11-05 11:32:18 +11:00 committed by GitHub
parent 01497c891d
commit 2dca3d79e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -60,9 +60,10 @@ class AnimimgType(WidgetType):
lvgl_components_required.add(CONF_IMAGE)
lvgl_components_required.add(CONF_ANIMIMG)
if CONF_SRC in config:
for x in config[CONF_SRC]:
await cg.get_variable(x)
srcs = [await lv_image.process(x) for x in config[CONF_SRC]]
srcs = [
await lv_image.process(await cg.get_variable(x))
for x in config[CONF_SRC]
]
src_id = cg.static_const_array(config[CONF_SRC_LIST_ID], srcs)
count = len(config[CONF_SRC])
lv.animimg_set_src(w.obj, src_id, count)

View File

@ -1,3 +1,4 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.const import CONF_ANGLE, CONF_MODE
@ -64,6 +65,7 @@ class ImgType(WidgetType):
async def to_code(self, w: Widget, config):
if src := config.get(CONF_SRC):
src = await cg.get_variable(src)
lv.img_set_src(w.obj, await lv_image.process(src))
if (cf_angle := config.get(CONF_ANGLE)) is not None:
pivot_x = config[CONF_PIVOT_X]