[lvgl] Add initial_focus for encoders (#7256)

This commit is contained in:
Clyde Stubbs
2024-08-13 18:06:01 +10:00
committed by GitHub
parent 506e69addf
commit 3598560472
5 changed files with 29 additions and 9 deletions
+8
View File
@@ -8,6 +8,7 @@ from .defines import (
CONF_DEFAULT_GROUP,
CONF_ENCODERS,
CONF_ENTER_BUTTON,
CONF_INITIAL_FOCUS,
CONF_LEFT_BUTTON,
CONF_LONG_PRESS_REPEAT_TIME,
CONF_LONG_PRESS_TIME,
@@ -67,3 +68,10 @@ async def encoders_to_code(var, config):
else:
group = default_group
lv.indev_set_group(lv_expr.indev_drv_register(listener.get_drv()), group)
async def initial_focus_to_code(config):
for enc_conf in config[CONF_ENCODERS]:
if default_focus := enc_conf.get(CONF_INITIAL_FOCUS):
obj = await cg.get_variable(default_focus)
lv.group_focus_obj(obj)