|
|
|
@ -56,7 +56,7 @@ class VCruiseHelper: |
|
|
|
|
# if stock cruise is completely disabled, then we can use our own set speed logic |
|
|
|
|
self._update_v_cruise_non_pcm(CS, enabled, is_metric) |
|
|
|
|
self.v_cruise_cluster_kph = self.v_cruise_kph |
|
|
|
|
self.update_button_timers(CS) |
|
|
|
|
self.update_button_timers(CS, enabled) |
|
|
|
|
else: |
|
|
|
|
self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH |
|
|
|
|
self.v_cruise_cluster_kph = CS.cruiseState.speedCluster * CV.MS_TO_KPH |
|
|
|
@ -97,6 +97,10 @@ class VCruiseHelper: |
|
|
|
|
if button_type == ButtonType.accelCruise and cruise_standstill: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
# Don't adjust speed if we've enabled since the button was depressed |
|
|
|
|
if not self.button_change_states[button_type]["enabled"]: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
self.v_cruise_kph = CRUISE_NEAREST_FUNC[button_type](self.v_cruise_kph / v_cruise_delta) * v_cruise_delta |
|
|
|
@ -109,7 +113,7 @@ class VCruiseHelper: |
|
|
|
|
|
|
|
|
|
self.v_cruise_kph = clip(round(self.v_cruise_kph, 1), V_CRUISE_MIN, V_CRUISE_MAX) |
|
|
|
|
|
|
|
|
|
def update_button_timers(self, CS): |
|
|
|
|
def update_button_timers(self, CS, enabled): |
|
|
|
|
# increment timer for buttons still pressed |
|
|
|
|
for k in self.button_timers: |
|
|
|
|
if self.button_timers[k] > 0: |
|
|
|
@ -119,7 +123,7 @@ class VCruiseHelper: |
|
|
|
|
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_states[b.type.raw] = {"standstill": CS.cruiseState.standstill} |
|
|
|
|
self.button_change_states[b.type.raw] = {"standstill": CS.cruiseState.standstill, "enabled": enabled} |
|
|
|
|
|
|
|
|
|
def initialize_v_cruise(self, CS): |
|
|
|
|
# initializing is handled by the PCM |
|
|
|
|