mirror of https://github.com/1okko/openpilot.git
MADS: Map cruise main and lateral buttons to button events (#373)
* MADS: Map cruise main and lateral buttons to button events
* MADS: Map cruise main and lateral buttons to button events
* different style
* nah
(cherry picked from commit 4d7afe3a7b
)
* reimplement
This commit is contained in:
parent
fa3a0ba747
commit
54d5281064
|
@ -93,7 +93,11 @@ class CarInterface(CarInterfaceBase):
|
|||
ret = self.CS.update(self.cp, self.cp_cam)
|
||||
self.sp_update_params()
|
||||
|
||||
self.CS.button_events.extend(create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}))
|
||||
self.CS.button_events = [
|
||||
*self.CS.button_events,
|
||||
*create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}),
|
||||
*create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}),
|
||||
]
|
||||
|
||||
self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)
|
||||
|
||||
|
@ -108,7 +112,7 @@ class CarInterface(CarInterfaceBase):
|
|||
if self.enable_mads:
|
||||
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
|
||||
self.CS.madsEnabled = True
|
||||
if self.CS.prev_lkas_enabled != 1 and self.CS.lkas_enabled == 1:
|
||||
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
|
||||
self.CS.madsEnabled = not self.CS.madsEnabled
|
||||
self.CS.lkas_disabled = not self.CS.lkas_disabled
|
||||
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
|
||||
|
|
|
@ -74,7 +74,11 @@ class CarInterface(CarInterfaceBase):
|
|||
ret = self.CS.update(self.cp, self.cp_cam)
|
||||
self.sp_update_params()
|
||||
|
||||
self.CS.button_events.extend(create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}))
|
||||
self.CS.button_events = [
|
||||
*self.CS.button_events,
|
||||
*create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}),
|
||||
*create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}),
|
||||
]
|
||||
|
||||
self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)
|
||||
|
||||
|
@ -85,7 +89,7 @@ class CarInterface(CarInterfaceBase):
|
|||
if self.enable_mads:
|
||||
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
|
||||
self.CS.madsEnabled = True
|
||||
if not self.CS.prev_lkas_enabled and self.CS.lkas_enabled:
|
||||
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
|
||||
self.CS.madsEnabled = not self.CS.madsEnabled
|
||||
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
|
||||
else:
|
||||
|
|
|
@ -218,6 +218,11 @@ class CarInterface(CarInterfaceBase):
|
|||
]
|
||||
distance_button = self.CS.distance_button
|
||||
|
||||
self.CS.button_events = [
|
||||
*self.CS.button_events,
|
||||
*create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}),
|
||||
]
|
||||
|
||||
self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)
|
||||
|
||||
if not self.CP.pcmCruise:
|
||||
|
@ -231,7 +236,7 @@ class CarInterface(CarInterfaceBase):
|
|||
if self.enable_mads:
|
||||
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
|
||||
self.CS.madsEnabled = True
|
||||
if self.CS.prev_lkas_enabled != 1 and self.CS.lkas_enabled == 1:
|
||||
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
|
||||
self.CS.madsEnabled = not self.CS.madsEnabled
|
||||
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
|
||||
else:
|
||||
|
|
|
@ -282,7 +282,7 @@ class CarInterface(CarInterfaceBase):
|
|||
if self.enable_mads:
|
||||
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
|
||||
self.CS.madsEnabled = True
|
||||
if self.CS.prev_cruise_setting != 1 and self.CS.cruise_setting == 1:
|
||||
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
|
||||
self.CS.madsEnabled = not self.CS.madsEnabled
|
||||
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
|
||||
else:
|
||||
|
|
|
@ -205,7 +205,11 @@ class CarInterface(CarInterfaceBase):
|
|||
ret = self.CS.update(self.cp, self.cp_cam)
|
||||
self.sp_update_params()
|
||||
|
||||
self.CS.button_events = create_button_events(self.CS.cruise_buttons[-1], self.CS.prev_cruise_buttons, BUTTONS_DICT)
|
||||
self.CS.button_events = [
|
||||
*create_button_events(self.CS.cruise_buttons[-1], self.CS.prev_cruise_buttons, BUTTONS_DICT),
|
||||
*create_button_events(self.CS.lfa_enabled, self.CS.prev_lfa_enabled, {1: ButtonType.altButton1}),
|
||||
*create_button_events(self.CS.main_buttons[-1], self.CS.prev_main_buttons, {1: ButtonType.altButton3}),
|
||||
]
|
||||
|
||||
self.CS.accEnabled = self.get_sp_v_cruise_non_pcm_state(ret, self.CS.accEnabled,
|
||||
self.CS.button_events, c.vCruise)
|
||||
|
@ -214,16 +218,12 @@ class CarInterface(CarInterfaceBase):
|
|||
|
||||
if ret.cruiseState.available:
|
||||
if not self.CP.pcmCruiseSpeed:
|
||||
if self.CS.prev_main_buttons == 1:
|
||||
if self.CS.main_buttons[-1] != 1:
|
||||
self.CS.accEnabled = True
|
||||
elif self.CS.prev_cruise_buttons == 4:
|
||||
if self.CS.cruise_buttons[-1] != 4:
|
||||
self.accEnabled = True
|
||||
if any(b.type in (ButtonType.altButton3, ButtonType.cancel) and not b.pressed for b in self.CS.button_events):
|
||||
self.CS.accEnabled = True
|
||||
if self.enable_mads:
|
||||
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
|
||||
self.CS.madsEnabled = True
|
||||
if self.CS.prev_lfa_enabled != 1 and self.CS.lfa_enabled == 1:
|
||||
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
|
||||
self.CS.madsEnabled = not self.CS.madsEnabled
|
||||
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
|
||||
else:
|
||||
|
|
|
@ -42,7 +42,8 @@ class CarInterface(CarInterfaceBase):
|
|||
# TODO: add button types for inc and dec
|
||||
self.CS.button_events = [
|
||||
*self.CS.button_events,
|
||||
*create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})
|
||||
*create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}),
|
||||
*create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}),
|
||||
]
|
||||
|
||||
self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)
|
||||
|
@ -54,7 +55,7 @@ class CarInterface(CarInterfaceBase):
|
|||
if self.enable_mads:
|
||||
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
|
||||
self.CS.madsEnabled = True
|
||||
if self.CS.prev_lkas_enabled != self.CS.lkas_enabled:
|
||||
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
|
||||
self.CS.madsEnabled = not self.CS.madsEnabled
|
||||
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue