1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 13:22:19 +01:00

[lvgl] Add lvgl.widget.focus action and related triggers. (#7315)

This commit is contained in:
Clyde Stubbs
2024-08-28 14:29:41 +10:00
committed by GitHub
parent 458a8970b6
commit d6df466237
13 changed files with 253 additions and 27 deletions

View File

@@ -20,7 +20,7 @@ from . import defines as df, lv_validation as lvalid
from .defines import CONF_TIME_FORMAT
from .helpers import add_lv_use, requires_component, validate_printf
from .lv_validation import lv_color, lv_font, lv_image
from .lvcode import LvglComponent
from .lvcode import LvglComponent, lv_event_t_ptr
from .types import (
LVEncoderListener,
LvType,
@@ -215,14 +215,12 @@ def automation_schema(typ: LvType):
events = df.LV_EVENT_TRIGGERS + (CONF_ON_VALUE,)
else:
events = df.LV_EVENT_TRIGGERS
if isinstance(typ, LvType):
template = Trigger.template(typ.get_arg_type())
else:
template = Trigger.template()
args = [typ.get_arg_type()] if isinstance(typ, LvType) else []
args.append(lv_event_t_ptr)
return {
cv.Optional(event): validate_automation(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(template),
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(Trigger.template(*args)),
}
)
for event in events