Generalise image requirements

This commit is contained in:
clydebarrow 2024-11-23 18:20:07 +11:00
parent b829d9082c
commit 991700af2a
2 changed files with 3 additions and 7 deletions

View file

@ -30,7 +30,7 @@ from .defines import (
call_lambda, call_lambda,
literal, literal,
) )
from .helpers import esphome_fonts_used, lv_fonts_used, requires_component from .helpers import add_lv_use, esphome_fonts_used, lv_fonts_used, requires_component
from .types import lv_font_t, lv_gradient_t, lv_img_t from .types import lv_font_t, lv_gradient_t, lv_img_t
opacity_consts = LvConstant("LV_OPA_", "TRANSP", "COVER") opacity_consts = LvConstant("LV_OPA_", "TRANSP", "COVER")
@ -326,6 +326,7 @@ def image_validator(value):
value = requires_component("image")(value) value = requires_component("image")(value)
value = cv.use_id(Image_)(value) value = cv.use_id(Image_)(value)
lv_images_used.add(value) lv_images_used.add(value)
add_lv_use("img", "label")
return value return value

View file

@ -342,14 +342,9 @@ FLEX_OBJ_SCHEMA = {
} }
def bg_image_validator(value):
add_lv_use("img", "label")
return lv_image(value)
DISP_BG_SCHEMA = cv.Schema( DISP_BG_SCHEMA = cv.Schema(
{ {
cv.Optional(df.CONF_DISP_BG_IMAGE): bg_image_validator, cv.Optional(df.CONF_DISP_BG_IMAGE): lv_image,
cv.Optional(df.CONF_DISP_BG_COLOR): lv_color, cv.Optional(df.CONF_DISP_BG_COLOR): lv_color,
} }
) )