Switch personalities via steering wheel / onroad UI
Added toggle to switch between the personalities via the steering wheel or an onroad UI button. Co-Authored-By: henryccy <104284652+henryccy@users.noreply.github.com> Co-Authored-By: Jason Jackrel <23621790+thinkpad4by3@users.noreply.github.com> Co-Authored-By: Eric Brown <13560103+nworb-cire@users.noreply.github.com> Co-Authored-By: Kevin Robert Keegan <3046315+krkeegan@users.noreply.github.com> Co-Authored-By: Jacob Pfeifer <jacob@pfeifer.dev> Co-Authored-By: mike8643 <98910897+mike8643@users.noreply.github.com>
This commit is contained in:
@@ -30,6 +30,11 @@ class CarState(CarStateBase):
|
||||
# FrogPilot variables
|
||||
self.single_pedal_mode = False
|
||||
|
||||
# FrogPilot variables
|
||||
self.display_menu = False
|
||||
|
||||
self.display_timer = 0
|
||||
|
||||
def update(self, pt_cp, cam_cp, loopback_cp, frogpilot_variables):
|
||||
ret = car.CarState.new_message()
|
||||
|
||||
@@ -162,6 +167,45 @@ class CarState(CarStateBase):
|
||||
ret.leftBlindspot = cam_cp.vl["BCMBlindSpotMonitor"]["LeftBSM"] == 1
|
||||
ret.rightBlindspot = cam_cp.vl["BCMBlindSpotMonitor"]["RightBSM"] == 1
|
||||
|
||||
# Driving personalities function - Credit goes to Mangomoose!
|
||||
if frogpilot_variables.personalities_via_wheel and ret.cruiseState.available:
|
||||
# Sync with the onroad UI button
|
||||
if self.fpf.personality_changed_via_ui:
|
||||
self.personality_profile = self.fpf.current_personality
|
||||
self.previous_personality_profile = self.personality_profile
|
||||
self.fpf.reset_personality_changed_param()
|
||||
|
||||
# Check if the car has a camera
|
||||
has_camera = self.CP.networkLocation == NetworkLocation.fwdCamera
|
||||
has_camera &= not self.CP.flags & GMFlags.NO_CAMERA.value
|
||||
has_camera &= not self.CP.carFingerprint in (CC_ONLY_CAR)
|
||||
|
||||
if has_camera:
|
||||
# Need to subtract by 1 to comply with the personality profiles of "0", "1", and "2"
|
||||
self.personality_profile = cam_cp.vl["ASCMActiveCruiseControlStatus"]["ACCGapLevel"] - 1
|
||||
else:
|
||||
if self.CP.carFingerprint in SDGM_CAR:
|
||||
distance_button = cam_cp.vl["ASCMSteeringButton"]["DistanceButton"]
|
||||
else:
|
||||
distance_button = pt_cp.vl["ASCMSteeringButton"]["DistanceButton"]
|
||||
|
||||
if distance_button and not self.distance_previously_pressed:
|
||||
if self.display_menu:
|
||||
self.personality_profile = (self.previous_personality_profile + 2) % 3
|
||||
self.display_timer = 350
|
||||
self.distance_previously_pressed = distance_button
|
||||
|
||||
# Check if the display is open
|
||||
if self.display_timer > 0:
|
||||
self.display_timer -= 1
|
||||
self.display_menu = True
|
||||
else:
|
||||
self.display_menu = False
|
||||
|
||||
if self.personality_profile != self.previous_personality_profile and self.personality_profile >= 0:
|
||||
self.fpf.distance_button_function(self.personality_profile)
|
||||
self.previous_personality_profile = self.personality_profile
|
||||
|
||||
# Toggle Experimental Mode from steering wheel function
|
||||
if frogpilot_variables.experimental_mode_via_lkas and ret.cruiseState.available:
|
||||
if self.CP.carFingerprint in SDGM_CAR:
|
||||
|
||||
Reference in New Issue
Block a user