mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-22 22:42:05 +08:00
controlsd: resume does not increment speed while cruise standstill (#25470)
* fix runaway set speed for GM * fix runaway set speed for GM * Handle resuming to exit standstill generically * clean that up * ugh i want to fix all the formatting * class that manages v_cruise * better name * move around * add depressed_state * fine to update on pressed change, better name * cmt * we need to check CS. button_change_state only works if we exit standstill on rising edge not falling edge * no defaultdict
This commit is contained in:
@@ -211,13 +211,7 @@ class CarInterface(CarInterfaceBase):
|
||||
ret = self.CS.update(self.cp, self.cp_cam, self.cp_loopback)
|
||||
|
||||
if self.CS.cruise_buttons != self.CS.prev_cruise_buttons and self.CS.prev_cruise_buttons != CruiseButtons.INIT:
|
||||
be = create_button_event(self.CS.cruise_buttons, self.CS.prev_cruise_buttons, BUTTONS_DICT, CruiseButtons.UNPRESS)
|
||||
|
||||
# Suppress resume button if we're resuming from stop so we don't adjust speed.
|
||||
if be.type == ButtonType.accelCruise and (ret.cruiseState.enabled and ret.standstill):
|
||||
be.type = ButtonType.unknown
|
||||
|
||||
ret.buttonEvents = [be]
|
||||
ret.buttonEvents = [create_button_event(self.CS.cruise_buttons, self.CS.prev_cruise_buttons, BUTTONS_DICT, CruiseButtons.UNPRESS)]
|
||||
|
||||
events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low,
|
||||
GearShifter.eco, GearShifter.manumatic],
|
||||
|
||||
@@ -42,6 +42,7 @@ class VCruiseHelper:
|
||||
self.v_cruise_cluster_kph = V_CRUISE_INITIAL
|
||||
self.v_cruise_kph_last = 0
|
||||
self.button_timers = {ButtonType.decelCruise: 0, ButtonType.accelCruise: 0}
|
||||
self.button_change_state = {btn: {"standstill": False} for btn in self.button_timers}
|
||||
|
||||
@property
|
||||
def v_cruise_initialized(self):
|
||||
@@ -88,6 +89,11 @@ class VCruiseHelper:
|
||||
long_press = True
|
||||
break
|
||||
|
||||
# Don't adjust speed when pressing resume to exit standstill
|
||||
cruise_standstill = self.button_change_state[button_type]["standstill"] or CS.cruiseState.standstill
|
||||
if button_type == ButtonType.accelCruise and cruise_standstill:
|
||||
button_type = None
|
||||
|
||||
if button_type:
|
||||
v_cruise_delta = v_cruise_delta * (5 if long_press else 1)
|
||||
if long_press and self.v_cruise_kph % v_cruise_delta != 0: # partial interval
|
||||
@@ -109,7 +115,9 @@ class VCruiseHelper:
|
||||
|
||||
for b in CS.buttonEvents:
|
||||
if b.type.raw in self.button_timers:
|
||||
# Start/end timer and store current state on change of button pressed
|
||||
self.button_timers[b.type.raw] = 1 if b.pressed else 0
|
||||
self.button_change_state[b.type.raw].update({"standstill": CS.cruiseState.standstill})
|
||||
|
||||
def initialize_v_cruise(self, CS):
|
||||
# initializing is handled by the PCM
|
||||
|
||||
Reference in New Issue
Block a user