Skip to content

Commit

Permalink
alka main button states for hyundai
Browse files Browse the repository at this point in the history
  • Loading branch information
eFiniLan committed Jun 27, 2024
1 parent bc6d974 commit 39525c1
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def __init__(self, CP):

self.params = CarControllerParams(CP)

# dp - alka
self._main_on = False

def update(self, cp, cp_cam):
if self.CP.carFingerprint in CANFD_CAR:
return self.update_canfd(cp, cp_cam)
Expand Down Expand Up @@ -102,7 +105,9 @@ def update(self, cp, cp_cam):
# cruise state
if self.CP.openpilotLongitudinalControl:
# These are not used for engage/disengage since openpilot keeps track of state using the buttons
ret.cruiseState.available = cp.vl["TCS13"]["ACCEnable"] == 0
# dp - alka
# ret.cruiseState.available = cp.vl["TCS13"]["ACCEnable"] == 0
ret.cruiseState.available = self._main_on
ret.cruiseState.enabled = cp.vl["TCS13"]["ACC_REQ"] == 1
ret.cruiseState.standstill = False
ret.cruiseState.nonAdaptive = False
Expand Down Expand Up @@ -164,8 +169,15 @@ def update(self, cp, cp_cam):
self.steer_state = cp.vl["MDPS12"]["CF_Mdps_ToiActive"] # 0 NOT ACTIVE, 1 ACTIVE
self.prev_cruise_buttons = self.cruise_buttons[-1]
self.cruise_buttons.extend(cp.vl_all["CLU11"]["CF_Clu_CruiseSwState"])
# dp - alka
main_btn_prev = self.main_buttons[-1]

self.main_buttons.extend(cp.vl_all["CLU11"]["CF_Clu_CruiseSwMain"])

# dp - alka
if main_btn_prev != self.main_buttons[-1]:
self._main_on = not self._main_on

return ret

def update_canfd(self, cp, cp_cam):
Expand Down Expand Up @@ -219,7 +231,9 @@ def update_canfd(self, cp, cp_cam):

# cruise state
# CAN FD cars enable on main button press, set available if no TCS faults preventing engagement
ret.cruiseState.available = cp.vl["TCS"]["ACCEnable"] == 0
# dp - alka
# ret.cruiseState.available = cp.vl["TCS"]["ACCEnable"] == 0
ret.cruiseState.available = self._main_on
if self.CP.openpilotLongitudinalControl:
# These are not used for engage/disengage since openpilot keeps track of state using the buttons
ret.cruiseState.enabled = cp.vl["TCS"]["ACC_REQ"] == 1
Expand All @@ -240,7 +254,14 @@ def update_canfd(self, cp, cp_cam):

self.prev_cruise_buttons = self.cruise_buttons[-1]
self.cruise_buttons.extend(cp.vl_all[self.cruise_btns_msg_canfd]["CRUISE_BUTTONS"])
# dp - alka
main_btn_prev = self.main_buttons[-1]

self.main_buttons.extend(cp.vl_all[self.cruise_btns_msg_canfd]["ADAPTIVE_CRUISE_MAIN_BTN"])

# dp - alka
if main_btn_prev != self.main_buttons[-1]:
self._main_on = not self._main_on
self.buttons_counter = cp.vl[self.cruise_btns_msg_canfd]["COUNTER"]
ret.accFaulted = cp.vl["TCS"]["ACCEnable"] != 0 # 0 ACC CONTROL ENABLED, 1-3 ACC CONTROL DISABLED

Expand Down

0 comments on commit 39525c1

Please sign in to comment.