mirror of
https://github.com/esphome/esphome.git
synced 2024-12-21 16:27:44 +01:00
[lvgl] Ensure images are configured before using them. (Bugfix) (#7721)
This commit is contained in:
parent
01497c891d
commit
2dca3d79e4
@ -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)
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user