This commit is contained in:
Your Name
2024-02-05 01:15:52 -06:00
parent 072ed7e50f
commit a81f6285c1
5 changed files with 62 additions and 47 deletions

View File

@@ -171,13 +171,13 @@ class CarState(CarStateBase):
self.custom_speed_up = False
self.custom_speed_down = False
if self.cruise_buttons[-1] == Buttons.GAP_DIST and self.prev_cruise_buttons == 0:
self.custom_speed_down = True
# if self.cruise_buttons[-1] == Buttons.GAP_DIST and self.prev_cruise_buttons == 0:
# self.custom_speed_down = True
lkas_pressed = cp.vl["BCM_PO_11"]["LFA_Pressed"]
if lkas_pressed and not self.lkas_previously_pressed:
self.custom_speed_up = True
self.lkas_previously_pressed = lkas_pressed
# lkas_pressed = cp.vl["BCM_PO_11"]["LFA_Pressed"]
# if lkas_pressed and not self.lkas_previously_pressed:
# self.custom_speed_up = True
# self.lkas_previously_pressed = lkas_pressed
# Driving personalities function
# if self.personalities_via_wheel and ret.cruiseState.available:
@@ -295,36 +295,48 @@ class CarState(CarStateBase):
self.hda2_lfa_block_msg = copy.copy(cp_cam.vl["CAM_0x362"] if self.CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING
else cp_cam.vl["CAM_0x2a4"])
self.custom_speed_up = False
self.custom_speed_down = False
if self.cruise_buttons[-1] == Buttons.GAP_DIST and self.prev_cruise_buttons == 0:
self.custom_speed_down = True
lkas_pressed = cp.vl[self.cruise_btns_msg_canfd]["LKAS_BTN"]
if lkas_pressed and not self.lkas_previously_pressed:
self.custom_speed_up = True
self.lkas_previously_pressed = lkas_pressed
# Driving personalities function
if self.personalities_via_wheel and ret.cruiseState.available:
# Sync with the onroad UI button
if self.param_memory.get_bool("PersonalityChangedViaUI"):
self.personality_profile = self.param.get_int("LongitudinalPersonality")
self.param_memory.put_bool("PersonalityChangedViaUI", False)
# if self.personalities_via_wheel and ret.cruiseState.available:
# # Sync with the onroad UI button
# if self.param_memory.get_bool("PersonalityChangedViaUI"):
# self.personality_profile = self.param.get_int("LongitudinalPersonality")
# self.param_memory.put_bool("PersonalityChangedViaUI", False)
# Change personality upon steering wheel button press
if self.cruise_buttons[-1] == Buttons.GAP_DIST and self.prev_cruise_buttons == 0:
self.param_memory.put_bool("PersonalityChangedViaWheel", True)
self.personality_profile = (self.previous_personality_profile + 2) % 3
# # Change personality upon steering wheel button press
# if self.cruise_buttons[-1] == Buttons.GAP_DIST and self.prev_cruise_buttons == 0:
# self.param_memory.put_bool("PersonalityChangedViaWheel", True)
# self.personality_profile = (self.previous_personality_profile + 2) % 3
if self.personality_profile != self.previous_personality_profile and self.personality_profile >= 0:
self.param.put_int("LongitudinalPersonality", self.personality_profile)
self.previous_personality_profile = self.personality_profile
# if self.personality_profile != self.previous_personality_profile and self.personality_profile >= 0:
# self.param.put_int("LongitudinalPersonality", self.personality_profile)
# self.previous_personality_profile = self.personality_profile
# Toggle Experimental Mode from steering wheel function
if self.experimental_mode_via_lkas and ret.cruiseState.available:
lkas_pressed = cp.vl[self.cruise_btns_msg_canfd]["LKAS_BTN"]
if lkas_pressed and not self.lkas_previously_pressed:
if self.conditional_experimental_mode:
# Set "CEStatus" to work with "Conditional Experimental Mode"
conditional_status = self.param_memory.get_int("CEStatus")
override_value = 0 if conditional_status in (1, 2, 3, 4) else 1 if conditional_status >= 5 else 2
self.param_memory.put_int("CEStatus", override_value)
else:
experimental_mode = self.param.get_bool("ExperimentalMode")
# Invert the value of "ExperimentalMode"
put_bool_nonblocking("ExperimentalMode", not experimental_mode)
self.lkas_previously_pressed = lkas_pressed
# # Toggle Experimental Mode from steering wheel function
# if self.experimental_mode_via_lkas and ret.cruiseState.available:
# lkas_pressed = cp.vl[self.cruise_btns_msg_canfd]["LKAS_BTN"]
# if lkas_pressed and not self.lkas_previously_pressed:
# if self.conditional_experimental_mode:
# # Set "CEStatus" to work with "Conditional Experimental Mode"
# conditional_status = self.param_memory.get_int("CEStatus")
# override_value = 0 if conditional_status in (1, 2, 3, 4) else 1 if conditional_status >= 5 else 2
# self.param_memory.put_int("CEStatus", override_value)
# else:
# experimental_mode = self.param.get_bool("ExperimentalMode")
# # Invert the value of "ExperimentalMode"
# put_bool_nonblocking("ExperimentalMode", not experimental_mode)
# self.lkas_previously_pressed = lkas_pressed
return ret