mirror of
https://github.com/esphome/esphome.git
synced 2025-01-18 12:05:41 +00:00
[lgvl] disp_bg_image and disp_bg_opa changes (#8025)
This commit is contained in:
parent
8a98b69a57
commit
0df6a913b3
@ -10,13 +10,14 @@ from esphome.cpp_types import nullptr
|
|||||||
from .defines import (
|
from .defines import (
|
||||||
CONF_DISP_BG_COLOR,
|
CONF_DISP_BG_COLOR,
|
||||||
CONF_DISP_BG_IMAGE,
|
CONF_DISP_BG_IMAGE,
|
||||||
|
CONF_DISP_BG_OPA,
|
||||||
CONF_EDITING,
|
CONF_EDITING,
|
||||||
CONF_FREEZE,
|
CONF_FREEZE,
|
||||||
CONF_LVGL_ID,
|
CONF_LVGL_ID,
|
||||||
CONF_SHOW_SNOW,
|
CONF_SHOW_SNOW,
|
||||||
literal,
|
literal,
|
||||||
)
|
)
|
||||||
from .lv_validation import lv_bool, lv_color, lv_image
|
from .lv_validation import lv_bool, lv_color, lv_image, opacity
|
||||||
from .lvcode import (
|
from .lvcode import (
|
||||||
LVGL_COMP_ARG,
|
LVGL_COMP_ARG,
|
||||||
UPDATE_EVENT,
|
UPDATE_EVENT,
|
||||||
@ -119,13 +120,22 @@ async def lvgl_is_idle(config, condition_id, template_arg, args):
|
|||||||
|
|
||||||
|
|
||||||
async def disp_update(disp, config: dict):
|
async def disp_update(disp, config: dict):
|
||||||
if CONF_DISP_BG_COLOR not in config and CONF_DISP_BG_IMAGE not in config:
|
if (
|
||||||
|
CONF_DISP_BG_COLOR not in config
|
||||||
|
and CONF_DISP_BG_IMAGE not in config
|
||||||
|
and CONF_DISP_BG_OPA not in config
|
||||||
|
):
|
||||||
return
|
return
|
||||||
with LocalVariable("lv_disp_tmp", lv_disp_t, disp) as disp_temp:
|
with LocalVariable("lv_disp_tmp", lv_disp_t, disp) as disp_temp:
|
||||||
if (bg_color := config.get(CONF_DISP_BG_COLOR)) is not None:
|
if (bg_color := config.get(CONF_DISP_BG_COLOR)) is not None:
|
||||||
lv.disp_set_bg_color(disp_temp, await lv_color.process(bg_color))
|
lv.disp_set_bg_color(disp_temp, await lv_color.process(bg_color))
|
||||||
if bg_image := config.get(CONF_DISP_BG_IMAGE):
|
if bg_image := config.get(CONF_DISP_BG_IMAGE):
|
||||||
lv.disp_set_bg_image(disp_temp, await lv_image.process(bg_image))
|
if bg_image == "none":
|
||||||
|
lv.disp_set_bg_image(disp_temp, static_cast("void *", "nullptr"))
|
||||||
|
else:
|
||||||
|
lv.disp_set_bg_image(disp_temp, await lv_image.process(bg_image))
|
||||||
|
if (bg_opa := config.get(CONF_DISP_BG_OPA)) is not None:
|
||||||
|
lv.disp_set_bg_opa(disp_temp, await opacity.process(bg_opa))
|
||||||
|
|
||||||
|
|
||||||
@automation.register_action(
|
@automation.register_action(
|
||||||
|
@ -403,6 +403,7 @@ CONF_COLUMN = "column"
|
|||||||
CONF_DIGITS = "digits"
|
CONF_DIGITS = "digits"
|
||||||
CONF_DISP_BG_COLOR = "disp_bg_color"
|
CONF_DISP_BG_COLOR = "disp_bg_color"
|
||||||
CONF_DISP_BG_IMAGE = "disp_bg_image"
|
CONF_DISP_BG_IMAGE = "disp_bg_image"
|
||||||
|
CONF_DISP_BG_OPA = "disp_bg_opa"
|
||||||
CONF_BODY = "body"
|
CONF_BODY = "body"
|
||||||
CONF_BUTTONS = "buttons"
|
CONF_BUTTONS = "buttons"
|
||||||
CONF_BYTE_ORDER = "byte_order"
|
CONF_BYTE_ORDER = "byte_order"
|
||||||
|
@ -19,7 +19,7 @@ from esphome.schema_extractors import SCHEMA_EXTRACT
|
|||||||
from . import defines as df, lv_validation as lvalid
|
from . import defines as df, lv_validation as lvalid
|
||||||
from .defines import CONF_TIME_FORMAT, LV_GRAD_DIR
|
from .defines import CONF_TIME_FORMAT, LV_GRAD_DIR
|
||||||
from .helpers import add_lv_use, requires_component, validate_printf
|
from .helpers import add_lv_use, requires_component, validate_printf
|
||||||
from .lv_validation import lv_color, lv_font, lv_gradient, lv_image
|
from .lv_validation import lv_color, lv_font, lv_gradient, lv_image, opacity
|
||||||
from .lvcode import LvglComponent, lv_event_t_ptr
|
from .lvcode import LvglComponent, lv_event_t_ptr
|
||||||
from .types import (
|
from .types import (
|
||||||
LVEncoderListener,
|
LVEncoderListener,
|
||||||
@ -344,8 +344,11 @@ FLEX_OBJ_SCHEMA = {
|
|||||||
|
|
||||||
DISP_BG_SCHEMA = cv.Schema(
|
DISP_BG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.Optional(df.CONF_DISP_BG_IMAGE): lv_image,
|
cv.Optional(df.CONF_DISP_BG_IMAGE): cv.Any(
|
||||||
|
cv.one_of("none", lower=True), lv_image
|
||||||
|
),
|
||||||
cv.Optional(df.CONF_DISP_BG_COLOR): lv_color,
|
cv.Optional(df.CONF_DISP_BG_COLOR): lv_color,
|
||||||
|
cv.Optional(df.CONF_DISP_BG_OPA): opacity,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ lvgl:
|
|||||||
bg_color: light_blue
|
bg_color: light_blue
|
||||||
disp_bg_color: color_id
|
disp_bg_color: color_id
|
||||||
disp_bg_image: cat_image
|
disp_bg_image: cat_image
|
||||||
|
disp_bg_opa: cover
|
||||||
theme:
|
theme:
|
||||||
obj:
|
obj:
|
||||||
border_width: 1
|
border_width: 1
|
||||||
@ -207,7 +208,7 @@ lvgl:
|
|||||||
- lvgl.animimg.stop: anim_img
|
- lvgl.animimg.stop: anim_img
|
||||||
- lvgl.update:
|
- lvgl.update:
|
||||||
disp_bg_color: 0xffff00
|
disp_bg_color: 0xffff00
|
||||||
disp_bg_image: cat_image
|
disp_bg_image: none
|
||||||
- lvgl.widget.show: message_box
|
- lvgl.widget.show: message_box
|
||||||
- label:
|
- label:
|
||||||
text: "Hello shiny day"
|
text: "Hello shiny day"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user