mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-05 00:05:57 +08:00
ictoggles for mici
This commit is contained in:
@@ -60,7 +60,7 @@ class ICTogglesLayout(Widget):
|
||||
),
|
||||
"EnableLongComfortMode": (
|
||||
lambda: tr("VW: Longitudinal Comfort Mode"),
|
||||
DESCRIPTIONS["EnableCurvatureController"],
|
||||
DESCRIPTIONS["EnableLongComfortMode"],
|
||||
"chffr_wheel.png",
|
||||
False,
|
||||
),
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import pyray as rl
|
||||
from collections.abc import Callable
|
||||
from cereal import log
|
||||
|
||||
from openpilot.system.ui.widgets.scroller import Scroller
|
||||
from openpilot.selfdrive.ui.mici.widgets.button import BigParamControl, BigMultiParamToggle
|
||||
from openpilot.system.ui.lib.application import gui_app
|
||||
from openpilot.selfdrive.ui.layouts.settings.common import restart_needed_callback
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
|
||||
|
||||
class TogglesLayoutMici(NavWidget):
|
||||
def __init__(self, back_callback: Callable):
|
||||
super().__init__()
|
||||
self.set_back_callback(back_callback)
|
||||
|
||||
enable_curvature_correction = BigParamControl("VW: Lateral Correction (Recommended)", "EnableCurvatureController")
|
||||
enable_long_comfort_mode = BigParamControl("VW: Longitudinal Comfort Mode", "EnableLongComfortMode")
|
||||
enable_sl_control = BigParamControl("VW: Speed Limit Control", "EnableSpeedLimitControl")
|
||||
enable_sl_pred_control = BigParamControl("VW: Predicative Speed Limit (pACC)", "EnableSpeedLimitPredicative")
|
||||
enable_sl_pred_sl = BigParamControl("VW: Predicative - Reaction to Speed Limits", "EnableSLPredReactToSL")
|
||||
enable_sl_pred_curve = BigParamControl("VW: Predicative - Reaction to Curves", "EnableSLPredReactToCurves")
|
||||
force_rhd_bsm = BigParamControl("VW: Force RHD for BSM", "ForceRHDForBSM")
|
||||
enable_dark_mode = BigParamControl("Dark Mode", "DarkMode")
|
||||
enable_onroad_screen_timer = BigParamControl("Onroad Screen Timeout", "DisableScreenTimer")
|
||||
|
||||
|
||||
self._scroller = Scroller([
|
||||
enable_curvature_correction,
|
||||
enable_long_comfort_mode,
|
||||
enable_sl_control,
|
||||
enable_sl_pred_control,
|
||||
enable_sl_pred_sl,
|
||||
enable_sl_pred_curve,
|
||||
force_rhd_bsm,
|
||||
enable_dark_mode,
|
||||
enable_onroad_screen_timer,
|
||||
], snap_items=False)
|
||||
|
||||
# Toggle lists
|
||||
self._refresh_toggles = (
|
||||
("EnableCurvatureController", enable_curvature_correction),
|
||||
("EnableLongComfortMode", enable_long_comfort_mode),
|
||||
("EnableSpeedLimitControl", enable_sl_control),
|
||||
("EnableSpeedLimitPredicative", enable_sl_pred_control),
|
||||
("EnableSLPredReactToSL", enable_sl_pred_sl),
|
||||
("EnableSLPredReactToCurves", enable_sl_pred_curve),
|
||||
("ForceRHDForBSM", force_rhd_bsm),
|
||||
("DarkMode", enable_dark_mode),
|
||||
("DisableScreenTimer", enable_onroad_screen_timer),
|
||||
)
|
||||
|
||||
if ui_state.params.get_bool("ShowDebugInfo"):
|
||||
gui_app.set_show_touches(True)
|
||||
gui_app.set_show_fps(True)
|
||||
|
||||
ui_state.add_engaged_transition_callback(self._update_toggles)
|
||||
|
||||
def _update_state(self):
|
||||
super()._update_state()
|
||||
|
||||
def show_event(self):
|
||||
super().show_event()
|
||||
self._scroller.show_event()
|
||||
self._update_toggles()
|
||||
|
||||
def _update_toggles(self):
|
||||
ui_state.update_params()
|
||||
|
||||
# Refresh toggles from params to mirror external changes
|
||||
for key, item in self._refresh_toggles:
|
||||
item.set_checked(ui_state.params.get_bool(key))
|
||||
|
||||
def _render(self, rect: rl.Rectangle):
|
||||
self._scroller.render(rect)
|
||||
@@ -7,6 +7,7 @@ from openpilot.common.params import Params
|
||||
from openpilot.system.ui.widgets.scroller import Scroller
|
||||
from openpilot.selfdrive.ui.mici.widgets.button import BigButton
|
||||
from openpilot.selfdrive.ui.mici.layouts.settings.toggles import TogglesLayoutMici
|
||||
from openpilot.selfdrive.ui.mici.layouts.settings.ictoggles import ICTogglesLayoutMici
|
||||
from openpilot.selfdrive.ui.mici.layouts.settings.network import NetworkLayoutMici
|
||||
from openpilot.selfdrive.ui.mici.layouts.settings.device import DeviceLayoutMici, PairBigButton
|
||||
from openpilot.selfdrive.ui.mici.layouts.settings.developer import DeveloperLayoutMici
|
||||
@@ -22,6 +23,7 @@ class PanelType(IntEnum):
|
||||
DEVELOPER = 3
|
||||
USER_MANUAL = 4
|
||||
FIREHOSE = 5
|
||||
ICTOGGLES = 6
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -38,6 +40,8 @@ class SettingsLayout(NavWidget):
|
||||
|
||||
toggles_btn = BigButton("toggles", "", "icons_mici/settings/toggles_icon.png")
|
||||
toggles_btn.set_click_callback(lambda: self._set_current_panel(PanelType.TOGGLES))
|
||||
ictoggles_btn = BigButton("ictoggles", "", "icons_mici/settings/toggles_icon.png")
|
||||
ictoggles_btn.set_click_callback(lambda: self._set_current_panel(PanelType.ICTOGGLES))
|
||||
network_btn = BigButton("network", "", "icons_mici/settings/network/wifi_strength_full.png")
|
||||
network_btn.set_click_callback(lambda: self._set_current_panel(PanelType.NETWORK))
|
||||
device_btn = BigButton("device", "", "icons_mici/settings/device_icon.png")
|
||||
@@ -50,6 +54,7 @@ class SettingsLayout(NavWidget):
|
||||
|
||||
self._scroller = Scroller([
|
||||
toggles_btn,
|
||||
ictoggles_btn,
|
||||
network_btn,
|
||||
device_btn,
|
||||
PairBigButton(),
|
||||
@@ -64,6 +69,7 @@ class SettingsLayout(NavWidget):
|
||||
|
||||
self._panels = {
|
||||
PanelType.TOGGLES: PanelInfo("Toggles", TogglesLayoutMici(back_callback=lambda: self._set_current_panel(None))),
|
||||
PanelType.ICTOGGLES: PanelInfo("infiniteCable", ICTogglesLayoutMici(back_callback=lambda: self._set_current_panel(None))),
|
||||
PanelType.NETWORK: PanelInfo("Network", NetworkLayoutMici(back_callback=lambda: self._set_current_panel(None))),
|
||||
PanelType.DEVICE: PanelInfo("Device", DeviceLayoutMici(back_callback=lambda: self._set_current_panel(None))),
|
||||
PanelType.DEVELOPER: PanelInfo("Developer", DeveloperLayoutMici(back_callback=lambda: self._set_current_panel(None))),
|
||||
|
||||
Reference in New Issue
Block a user