diff --git a/selfdrive/car/__init__.py b/selfdrive/car/__init__.py index 16e082e756..e52f15ecb8 100644 --- a/selfdrive/car/__init__.py +++ b/selfdrive/car/__init__.py @@ -21,18 +21,18 @@ def apply_hysteresis(val: float, val_steady: float, hyst_gap: float) -> float: return val_steady -def create_button_events(cur_button: int, prev_button: int, buttons_dict: Dict[int, capnp.lib.capnp._EnumModule], - unpressed: int = 0, init: Optional[int] = None) -> List[capnp.lib.capnp._DynamicStructBuilder]: +def create_button_events(cur_btn: int, prev_btn: int, buttons_dict: Dict[int, capnp.lib.capnp._EnumModule], + unpressed_btn: int = 0, init: Optional[int] = None) -> List[capnp.lib.capnp._DynamicStructBuilder]: events = [] - # Initialized to unpressed, don't add any events - if cur_button == unpressed and prev_button == init: + # Initialized to unpressed_btn, don't add any events + if cur_btn == unpressed_btn and prev_btn == init: return events - # Add events for button presses, handling when a button switches without going to unpressed - if cur_button != prev_button: - for pressed, btn in ((False, prev_button), (True, cur_button)): - if btn == unpressed: + # Add events for button presses, handling when a button switches without going to unpressed_btn + if cur_btn != prev_btn: + for pressed, btn in ((False, prev_btn), (True, cur_btn)): + if btn == unpressed_btn: continue be = car.CarState.ButtonEvent(pressed=pressed) diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 86c955f3df..31ca5867c1 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -212,7 +212,7 @@ class CarInterface(CarInterfaceBase): button_events = [] for be in create_button_events(self.CS.cruise_buttons, self.CS.prev_cruise_buttons, BUTTONS_DICT, - unpressed=CruiseButtons.UNPRESS, init=CruiseButtons.INIT): + unpressed_btn=CruiseButtons.UNPRESS, init_btn=CruiseButtons.INIT): # 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