mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-21 16:33:43 +08:00
comma four: warning for enabling alpha long (#37959)
* warning for alpha long on mici * copy * don't show green until done * lambda * helper * fix
This commit is contained in:
@@ -1,13 +1,34 @@
|
||||
from collections.abc import Callable
|
||||
from openpilot.common.time_helpers import system_time_valid
|
||||
from openpilot.system.ui.widgets.scroller import NavScroller
|
||||
from openpilot.selfdrive.ui.mici.widgets.button import BigButton, BigToggle, BigParamControl, BigCircleParamControl
|
||||
from openpilot.selfdrive.ui.mici.widgets.dialog import BigDialog, BigInputDialog
|
||||
from openpilot.selfdrive.ui.mici.widgets.button import BigButton, BigToggle, BigParamControl, BigCircleParamControl, GreyBigButton
|
||||
from openpilot.selfdrive.ui.mici.widgets.dialog import BigDialog, BigInputDialog, BigConfirmationCircleButton
|
||||
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
|
||||
from openpilot.selfdrive.ui.widgets.ssh_key import SshKeyFetcher
|
||||
|
||||
|
||||
class AlphaLongConfirmPage(NavScroller):
|
||||
def __init__(self, on_confirm: Callable[[], None]):
|
||||
super().__init__()
|
||||
|
||||
accept = BigConfirmationCircleButton("enable alpha\nlongitudinal",
|
||||
gui_app.texture("icons_mici/setup/driver_monitoring/dm_check.png", 64, 64),
|
||||
lambda: self.dismiss(on_confirm))
|
||||
|
||||
self._scroller.add_widgets([
|
||||
GreyBigButton("enabling alpha longitudinal", "scroll to continue",
|
||||
gui_app.texture("icons_mici/setup/warning.png", 64, 64)),
|
||||
GreyBigButton("", "WARNING: alpha longitudinal control will disable Automatic Emergency Braking (AEB)"),
|
||||
GreyBigButton("", "On this car, openpilot defaults to the stock system's built-in ACC."),
|
||||
GreyBigButton("", "Enabling this will switch to openpilot longitudinal control."),
|
||||
GreyBigButton("", "Using Experimental mode is recommended with openpilot longitudinal control alpha."),
|
||||
GreyBigButton("", "Changing this setting will restart openpilot if the car is powered on."),
|
||||
accept,
|
||||
])
|
||||
|
||||
|
||||
class DeveloperLayoutMici(NavScroller):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -165,7 +186,14 @@ class DeveloperLayoutMici(NavScroller):
|
||||
restart_needed_callback(state)
|
||||
|
||||
def _on_alpha_long_enabled(self, state: bool):
|
||||
# TODO: show confirmation dialog before enabling
|
||||
ui_state.params.put_bool("AlphaLongitudinalEnabled", state)
|
||||
restart_needed_callback(state)
|
||||
self._update_toggles()
|
||||
def do_toggle(_state: bool):
|
||||
ui_state.params.put_bool("AlphaLongitudinalEnabled", _state)
|
||||
restart_needed_callback(True)
|
||||
self._update_toggles()
|
||||
|
||||
if state:
|
||||
# Don't show enabled state until confirm
|
||||
self._alpha_long_toggle.set_checked(False)
|
||||
gui_app.push_widget(AlphaLongConfirmPage(lambda: do_toggle(True)))
|
||||
else:
|
||||
do_toggle(False)
|
||||
|
||||
Reference in New Issue
Block a user