From 34ca49517fd3242fef7f0ebdf977cf880a97fa85 Mon Sep 17 00:00:00 2001 From: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Date: Mon, 27 Jul 2026 16:03:27 -0400 Subject: [PATCH] Param Wrapper --- .../layouts/settings/starpilot/main_panel.py | 4 +- .../ui/layouts/settings/starpilot/panel.py | 37 +++---------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/selfdrive/ui/layouts/settings/starpilot/main_panel.py b/selfdrive/ui/layouts/settings/starpilot/main_panel.py index b234871cb..03759d7fa 100644 --- a/selfdrive/ui/layouts/settings/starpilot/main_panel.py +++ b/selfdrive/ui/layouts/settings/starpilot/main_panel.py @@ -7,7 +7,7 @@ from openpilot.system.ui.widgets import Widget from openpilot.system.ui.lib.multilang import tr, tr_noop from openpilot.system.ui.lib.application import MousePos, gui_app, FontWeight -from openpilot.selfdrive.ui.layouts.settings.starpilot.panel import StarPilotPanelType, StarPilotPanelInfo, FrameCachedParams +from openpilot.selfdrive.ui.layouts.settings.starpilot.panel import StarPilotPanelType, StarPilotPanelInfo, SettingsParamsWrapper from openpilot.selfdrive.ui.layouts.settings.starpilot.sounds import StarPilotSoundsLayout from openpilot.selfdrive.ui.layouts.settings.starpilot.driving_model import StarPilotDrivingModelLayout from openpilot.selfdrive.ui.layouts.settings.starpilot.longitudinal import StarPilotLongitudinalLayout @@ -55,7 +55,7 @@ class StarPilotLayout(Widget): def __init__(self): super().__init__() - self._params = FrameCachedParams() + self._params = SettingsParamsWrapper() self._current_panel = StarPilotPanelType.MAIN self._current_category_idx: int | None = None diff --git a/selfdrive/ui/layouts/settings/starpilot/panel.py b/selfdrive/ui/layouts/settings/starpilot/panel.py index 6a7728ea8..4804b4b6e 100644 --- a/selfdrive/ui/layouts/settings/starpilot/panel.py +++ b/selfdrive/ui/layouts/settings/starpilot/panel.py @@ -16,48 +16,23 @@ from openpilot.selfdrive.ui.layouts.settings.starpilot.sectioned_panel import Se import time -class FrameCachedParams: +class SettingsParamsWrapper: def __init__(self): self._params = ui_state.params - self._cache = {} - self._last_frame_time = 0.0 - - def _check_clear_cache(self): - now = time.monotonic() - if now != self._last_frame_time: - self._cache.clear() - self._last_frame_time = now def get(self, key, **kwargs): - self._check_clear_cache() - cache_key = (key, "get", tuple(kwargs.items())) - if cache_key not in self._cache: - self._cache[cache_key] = self._params.get(key, **kwargs) - return self._cache[cache_key] + return self._params.get(key, **kwargs) def get_bool(self, key, **kwargs): - self._check_clear_cache() - cache_key = (key, "get_bool", tuple(kwargs.items())) - if cache_key not in self._cache: - self._cache[cache_key] = self._params.get_bool(key, **kwargs) - return self._cache[cache_key] + return self._params.get_bool(key, **kwargs) def get_int(self, key, **kwargs): - self._check_clear_cache() - cache_key = (key, "get_int", tuple(kwargs.items())) - if cache_key not in self._cache: - self._cache[cache_key] = self._params.get_int(key, **kwargs) - return self._cache[cache_key] + return self._params.get_int(key, **kwargs) def get_float(self, key, **kwargs): - self._check_clear_cache() - cache_key = (key, "get_float", tuple(kwargs.items())) - if cache_key not in self._cache: - self._cache[cache_key] = self._params.get_float(key, **kwargs) - return self._cache[cache_key] + return self._params.get_float(key, **kwargs) def _notify_changed(self): - self._cache.clear() update_starpilot_toggles() def put(self, key, val, **kwargs): @@ -108,7 +83,7 @@ class StarPilotPanel(Widget): def __init__(self): super().__init__() self._params_memory = ui_state.params_memory - self._params = FrameCachedParams() + self._params = SettingsParamsWrapper() self._navigate_callback: Callable | None = None self._back_callback: Callable | None = None self._current_sub_panel = ""