mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[lvgl] Fix initial focus on roller (#8547)
This commit is contained in:
		
				
					committed by
					
						 Jesse Hills
						Jesse Hills
					
				
			
			
				
	
			
			
			
						parent
						
							fe51ee6257
						
					
				
				
					commit
					566968b6be
				
			| @@ -18,6 +18,7 @@ from .helpers import lvgl_components_required, requires_component | ||||
| from .lvcode import lv, lv_add, lv_assign, lv_expr, lv_Pvariable | ||||
| from .schemas import ENCODER_SCHEMA | ||||
| from .types import lv_group_t, lv_indev_type_t, lv_key_t | ||||
| from .widgets import get_widgets | ||||
|  | ||||
| ENCODERS_CONFIG = cv.ensure_list( | ||||
|     ENCODER_SCHEMA.extend( | ||||
| @@ -76,5 +77,5 @@ async def encoders_to_code(var, config, default_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) | ||||
|             widget = await get_widgets(default_focus) | ||||
|             lv.group_focus_obj(widget[0].obj) | ||||
|   | ||||
| @@ -81,7 +81,9 @@ ENCODER_SCHEMA = cv.Schema( | ||||
|             cv.declare_id(LVEncoderListener), requires_component("binary_sensor") | ||||
|         ), | ||||
|         cv.Optional(CONF_GROUP): cv.declare_id(lv_group_t), | ||||
|         cv.Optional(df.CONF_INITIAL_FOCUS): cv.use_id(lv_obj_t), | ||||
|         cv.Optional(df.CONF_INITIAL_FOCUS): cv.All( | ||||
|             LIST_ACTION_SCHEMA, cv.Length(min=1, max=1) | ||||
|         ), | ||||
|         cv.Optional(df.CONF_LONG_PRESS_TIME, default="400ms"): PRESS_TIME, | ||||
|         cv.Optional(df.CONF_LONG_PRESS_REPEAT_TIME, default="100ms"): PRESS_TIME, | ||||
|     } | ||||
|   | ||||
| @@ -71,5 +71,6 @@ lvgl: | ||||
|     sensor: encoder | ||||
|     enter_button: pushbutton | ||||
|     group: general | ||||
|     initial_focus: lv_roller | ||||
|  | ||||
| <<: !include common.yaml | ||||
|   | ||||
		Reference in New Issue
	
	Block a user