add ui_update callback

This commit is contained in:
nayan
2025-11-19 23:03:56 -05:00
parent 4820265268
commit 4da32cc009

View File

@@ -1,3 +1,5 @@
from collections.abc import Callable
from openpilot.selfdrive.ui.ui_state import UIState
from cereal import messaging
from openpilot.common.params import Params
@@ -17,8 +19,16 @@ class UIStateSP(UIState):
]
self.sm = messaging.SubMaster(op_services + sp_services)
# Callbacks
self._ui_update_callbacks: list[Callable[[], None]] = []
def add_ui_update_callback(self, callback: Callable[[], None]):
self._ui_update_callbacks.append(callback)
def update(self) -> None:
UIState.update(self)
for callback in self._ui_update_callbacks:
callback()
def _update_status(self) -> None:
UIState._update_status(self)