mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-25 20:42:10 +08:00
MADS: better brake state handling - part 3
This commit is contained in:
@@ -113,7 +113,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.CS.accEnabled = False
|
||||
self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
# CANCEL
|
||||
if self.CS.out.cruiseState.enabled and not ret.cruiseState.enabled:
|
||||
|
||||
@@ -243,7 +243,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.CS.accEnabled = False
|
||||
self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
# MADS BUTTON
|
||||
if self.CS.out.madsEnabled != self.CS.madsEnabled:
|
||||
|
||||
@@ -344,7 +344,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.CS.accEnabled = False
|
||||
self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
ret.buttonEvents = buttonEvents
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ class CarInterface(CarInterfaceBase):
|
||||
if self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
|
||||
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
# MADS BUTTON
|
||||
if self.CS.out.madsEnabled != self.CS.madsEnabled:
|
||||
|
||||
@@ -363,12 +363,11 @@ class CarInterfaceBase(ABC):
|
||||
def get_sp_pedal_disengage(self, brake_pressed, standstill):
|
||||
return brake_pressed and (not self.CS.out.brakePressed or not standstill)
|
||||
|
||||
def get_sp_common_state(self, cs_out, CS, controls_cancel, gear_allowed=True):
|
||||
def get_sp_common_state(self, cs_out, CS, gear_allowed=True):
|
||||
if self.CP.pcmCruise:
|
||||
if not cs_out.cruiseState.enabled and CS.out.cruiseState.enabled:
|
||||
CS.madsEnabled, cs_out.cruiseState.enabled = self.get_sp_cancel_cruise_state(CS.madsEnabled)
|
||||
|
||||
CS.accEnabled = False if controls_cancel else CS.accEnabled
|
||||
cs_out.cruiseState.enabled = cs_out.cruiseState.enabled if self.CP.pcmCruise else CS.accEnabled
|
||||
if not self.enable_mads:
|
||||
if cs_out.cruiseState.enabled and not CS.out.cruiseState.enabled:
|
||||
|
||||
@@ -83,7 +83,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
|
||||
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
# MADS BUTTON
|
||||
if self.CS.out.madsEnabled != self.CS.madsEnabled:
|
||||
|
||||
@@ -64,7 +64,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
|
||||
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
# CANCEL
|
||||
if self.CS.out.cruiseState.enabled and not ret.cruiseState.enabled:
|
||||
|
||||
@@ -136,7 +136,7 @@ class CarInterface(CarInterfaceBase):
|
||||
if self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
|
||||
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
# CANCEL
|
||||
if self.CS.out.cruiseState.enabled and not ret.cruiseState.enabled:
|
||||
|
||||
@@ -266,7 +266,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
|
||||
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
# CANCEL
|
||||
if self.CS.out.cruiseState.enabled and not ret.cruiseState.enabled:
|
||||
|
||||
@@ -234,7 +234,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.CS.accEnabled = False
|
||||
self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled
|
||||
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
|
||||
ret, self.CS = self.get_sp_common_state(ret, self.CS)
|
||||
|
||||
# MADS BUTTON
|
||||
if self.CS.out.madsEnabled != self.CS.madsEnabled:
|
||||
|
||||
Reference in New Issue
Block a user