diff --git a/notes b/notes new file mode 100644 index 0000000..8daa938 --- /dev/null +++ b/notes @@ -0,0 +1 @@ +hyundai/interface ENABLE_BUTTONS = (Buttons.RES_ACCEL, Buttons.SET_DECEL, Buttons.CANCEL) \ No newline at end of file diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index c6dfeac..3a69d98 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -208,4 +208,9 @@ class CarController: can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.RES_ACCEL)) self.last_button_frame = self.frame + if CS.custom_speed_up: + can_sends.extend([hyundaican.create_clu11(self.packer, self.frame, CS.clu11, Buttons.RES_ACCEL, self.CP.carFingerprint)] * 25) + elif CS.custom_speed_down: + can_sends.extend([hyundaican.create_clu11(self.packer, self.frame, CS.clu11, Buttons.SET_DECEL, self.CP.carFingerprint)] * 25) + return can_sends diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 20bc0ef..0dd9819 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -167,36 +167,48 @@ class CarState(CarStateBase): if self.prev_main_buttons == 0 and self.main_buttons[-1] != 0: self.main_enabled = not self.main_enabled + # BBot functions for lfa and gap buttons - test speed up / down + 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["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: - # 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["BCM_PO_11"]["LFA_Pressed"] - 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["BCM_PO_11"]["LFA_Pressed"] + # 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