From 37ffa5ed21cfaa2c6a73b844bb1b19cca77aabc6 Mon Sep 17 00:00:00 2001 From: James Vecellio Date: Fri, 5 Dec 2025 19:43:36 -0800 Subject: [PATCH] layout --- common/param_watcher.py | 22 ++++++++++++---------- selfdrive/ui/sunnypilot/ui_state.py | 6 ------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/common/param_watcher.py b/common/param_watcher.py index a572636a90..551dd77efb 100644 --- a/common/param_watcher.py +++ b/common/param_watcher.py @@ -21,22 +21,24 @@ IN_CLOSE_WRITE = 0x00000008 def sync_layout_params(layout, param_name, params): - for item in getattr(layout, 'items', []): + items = getattr(layout, 'items', []) or getattr(getattr(layout, '_scroller', None), '_items', []) + for item in items: if not (action := getattr(item, 'action_item', None)): continue - toggle_key = getattr(getattr(action, 'toggle', None), 'param_key', None) - action_key = getattr(action, 'param_key', None) + toggle = getattr(getattr(action, 'toggle', None), 'param_key', None) + param_key = toggle or getattr(action, 'param_key', None) - if param_name is None or toggle_key == param_name or action_key == param_name: - if toggle_key: - action.set_state(params.get_bool(toggle_key)) - elif action_key: - value = int(params.get(action_key, return_default=True)) + if param_key and (param_name is None or param_key == param_name): + if toggle: + action.set_state(params.get_bool(param_key)) + elif hasattr(action, 'set_value'): + action.set_value(params.get(param_key, return_default=True)) + else: + param_value = int(params.get(param_key, return_default=True)) for attribute in ['selected_button', 'current_value']: if hasattr(action, attribute): - setattr(action, attribute, value) - + setattr(action, attribute, param_value) class ParamWatcher(Params): def __init__(self): diff --git a/selfdrive/ui/sunnypilot/ui_state.py b/selfdrive/ui/sunnypilot/ui_state.py index 34b0af510e..c47d5e857d 100644 --- a/selfdrive/ui/sunnypilot/ui_state.py +++ b/selfdrive/ui/sunnypilot/ui_state.py @@ -44,12 +44,6 @@ class UIStateSP: if self.active_layout: sync_layout_params(self.active_layout, None, self.params) - if self.active_layout: - for method in ['update_settings', '_update_state', '_update_toggles']: - if function := getattr(self.active_layout, method, None): - function() - break - def update_params(self) -> None: CP_SP_bytes = self.params.get("CarParamsSPPersistent") if CP_SP_bytes is not None: