IQ.Pilot Release Commit @ dab4674
This commit is contained in:
@@ -3,13 +3,11 @@ Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed
|
||||
"""
|
||||
|
||||
from iqpilot.selfdrive.ui.mici.widgets.stock_button import BigButton, BigParamControl
|
||||
from iqpilot.selfdrive.ui.mici.layouts.settings.iq_widgets import MappedParamToggle, IQModeSelector, SafeParamControl
|
||||
from iqpilot.selfdrive.ui.mici.layouts.settings.iq_widgets import FollowDistanceSelector, MappedParamToggle, IQModeSelector, SafeParamControl
|
||||
from iqpilot.system.ui.lib.application import gui_app
|
||||
from iqpilot.system.ui.widgets.scroller import NavScroller
|
||||
from iqpilot.system.ui.lib.multilang import tr
|
||||
|
||||
FOLLOW_DISTANCE_VALUES = [0, 1, 2, 3]
|
||||
|
||||
MS_TO_MPH = 2.23694
|
||||
_SPEED_MPH = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]
|
||||
_SPEED_OPTIONS = [f"{s} mph" for s in _SPEED_MPH]
|
||||
@@ -77,12 +75,11 @@ class CruiseLayoutMici(NavScroller):
|
||||
self._dynamic_panel = DynamicSettingsPanel()
|
||||
self._slc_panel = SlcSettingsPanel()
|
||||
|
||||
self._mode = IQModeSelector()
|
||||
self._follow_dist = FollowDistanceSelector()
|
||||
self._mode = IQModeSelector(self._follow_dist.refresh)
|
||||
self._dynamic_settings = BigButton(tr("iq.dynamic settings"))
|
||||
self._dynamic_settings.set_click_callback(lambda: gui_app.push_widget(self._dynamic_panel))
|
||||
self._dynamic_settings.set_visible(self._mode.is_dynamic)
|
||||
self._follow_dist = MappedParamToggle(tr("Follow Distance"), "LongitudinalPersonality",
|
||||
[tr("aggressive"), tr("standard"), tr("relaxed"), tr("stock")], FOLLOW_DISTANCE_VALUES)
|
||||
self._speed_limit = MappedParamToggle(tr("Speed Limit"), "IQSpeedAssistMode",
|
||||
[tr("off"), tr("info"), tr("warning"), tr("control")])
|
||||
self._slc_settings = BigButton(tr("speed limit settings"))
|
||||
|
||||
@@ -3,6 +3,15 @@ Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed
|
||||
"""
|
||||
|
||||
from iqpilot.common.params import Params, UnknownKeyName
|
||||
from iqpilot.selfdrive.longitudinal_settings import (
|
||||
LONGITUDINAL_MODE_DYNAMIC,
|
||||
LONGITUDINAL_MODE_PILOT,
|
||||
PERSONALITY_VALUES,
|
||||
apply_longitudinal_mode,
|
||||
get_follow_distance_state,
|
||||
get_longitudinal_mode,
|
||||
set_valid_personality,
|
||||
)
|
||||
from iqpilot.selfdrive.ui.mici.widgets.stock_button import BigButton, BigMultiToggle, BigToggle, BigParamControl
|
||||
from iqpilot.system.ui.lib.multilang import tr
|
||||
|
||||
@@ -90,27 +99,49 @@ class MappedParamToggle(BigMultiToggle):
|
||||
pass
|
||||
|
||||
|
||||
class FollowDistanceSelector(BigMultiToggle):
|
||||
OPTIONS = ["aggressive", "standard", "relaxed", "stock"]
|
||||
|
||||
def __init__(self):
|
||||
self._display_options = [tr(option) for option in self.OPTIONS]
|
||||
super().__init__(tr("Follow Distance"), self._display_options)
|
||||
self._params = Params()
|
||||
self.refresh()
|
||||
|
||||
def refresh(self):
|
||||
selection, enabled = get_follow_distance_state(self._params)
|
||||
self.set_value(self._display_options[3 if selection is None else selection])
|
||||
self.set_enabled(enabled)
|
||||
|
||||
def _handle_mouse_release(self, mouse_pos):
|
||||
if get_longitudinal_mode(self._params) not in (LONGITUDINAL_MODE_DYNAMIC, LONGITUDINAL_MODE_PILOT):
|
||||
return
|
||||
BigButton._handle_mouse_release(self, mouse_pos)
|
||||
selection, _ = get_follow_distance_state(self._params)
|
||||
if selection is None:
|
||||
self.refresh()
|
||||
return
|
||||
next_selection = PERSONALITY_VALUES[(PERSONALITY_VALUES.index(selection) + 1) % len(PERSONALITY_VALUES)]
|
||||
set_valid_personality(self._params, next_selection)
|
||||
self.set_value(self._display_options[next_selection])
|
||||
|
||||
|
||||
class IQModeSelector(BigMultiToggle):
|
||||
"""Longitudinal mode selector: Stock ACC / IQ.Chill / IQ.Dynamic / IQ.Pilot.
|
||||
|
||||
A single tap cycles to the next mode and applies the matching param combo immediately.
|
||||
"""
|
||||
OPTIONS = ["Stock ACC", "IQ.Chill", "IQ.Dynamic", "IQ.Pilot"]
|
||||
PERSONALITY_RELAXED = 2
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, mode_callback=None):
|
||||
self._display_options = [tr(option) for option in self.OPTIONS]
|
||||
super().__init__(tr("IQ Mode"), self._display_options)
|
||||
self._params = Params()
|
||||
self._mode_callback = mode_callback
|
||||
self.refresh()
|
||||
|
||||
def _index(self) -> int:
|
||||
p = self._params
|
||||
if not p.get_bool("AlphaLongitudinalEnabled"):
|
||||
return 0
|
||||
if not p.get_bool("ExperimentalMode"):
|
||||
return 1
|
||||
return 2 if p.get_bool("IQDynamicMode") else 3
|
||||
return get_longitudinal_mode(self._params)
|
||||
|
||||
def is_dynamic(self) -> bool:
|
||||
return self._index() == 2
|
||||
@@ -119,27 +150,12 @@ class IQModeSelector(BigMultiToggle):
|
||||
self.set_value(self._display_options[self._index()])
|
||||
|
||||
def _apply(self, idx: int):
|
||||
p = self._params
|
||||
if idx == 0:
|
||||
p.put_bool("AlphaLongitudinalEnabled", False)
|
||||
p.put_bool("ExperimentalMode", False)
|
||||
p.put_bool("IQDynamicMode", False)
|
||||
elif idx == 1:
|
||||
p.put_bool("AlphaLongitudinalEnabled", True)
|
||||
p.put_bool("ExperimentalMode", False)
|
||||
p.put_bool("IQDynamicMode", False)
|
||||
p.put("LongitudinalPersonality", self.PERSONALITY_RELAXED)
|
||||
elif idx == 2:
|
||||
p.put_bool("AlphaLongitudinalEnabled", True)
|
||||
p.put_bool("ExperimentalMode", True)
|
||||
p.put_bool("IQDynamicMode", True)
|
||||
else:
|
||||
p.put_bool("AlphaLongitudinalEnabled", True)
|
||||
p.put_bool("ExperimentalMode", True)
|
||||
p.put_bool("IQDynamicMode", False)
|
||||
p.put_bool("OnroadCycleRequested", True)
|
||||
apply_longitudinal_mode(self._params, idx)
|
||||
self._params.put_bool("OnroadCycleRequested", True)
|
||||
|
||||
def _handle_mouse_release(self, mouse_pos):
|
||||
nxt = (self._index() + 1) % len(self.OPTIONS)
|
||||
self._apply(nxt)
|
||||
self.set_value(self._display_options[nxt])
|
||||
if self._mode_callback:
|
||||
self._mode_callback()
|
||||
|
||||
@@ -78,8 +78,10 @@ class LaneChangePanel(NavScroller):
|
||||
[tr("off"), tr("nudge"), tr("no nudge"), "0.5 s", "1 s", "2 s", "3 s"],
|
||||
[-1, 0, 1, 2, 3, 4, 5])
|
||||
self._bsm_delay = BigParamControl(tr("Delay with Blind Spot"), "IQLaneChangeBsmDelay")
|
||||
self._edge_guard = BigParamControl(tr("Lane Edge Guard"), "IQEdgeGuard")
|
||||
self._edge_guard.set_value(tr("Blocks lane changes when a road edge is detected on the target side."))
|
||||
self._continuous = BigParamControl(tr("Continuous Changes"), "LaneChangeContinuous")
|
||||
self._scroller.add_widgets([self._timer, self._bsm_delay, self._continuous])
|
||||
self._scroller.add_widgets([self._timer, self._bsm_delay, self._edge_guard, self._continuous])
|
||||
|
||||
def show_event(self):
|
||||
super().show_event()
|
||||
@@ -91,6 +93,7 @@ class LaneChangePanel(NavScroller):
|
||||
self._bsm_delay.set_enabled(
|
||||
enable_bsm and int(ui_state.params.get("IQLaneChangeTimer", return_default=True)) > AutoLaneChangeMode.NUDGE
|
||||
)
|
||||
self._edge_guard.refresh()
|
||||
self._continuous.refresh()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user