Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ford: parse distance button #31733

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Ford: parse ACC gap toggle button
Use the ACC gap toggle button signal from the SCCM. There are two other
signals for "increase" and "decrease" gap buttons, but no supported car
has these buttons.
  • Loading branch information
incognitojam committed Mar 6, 2024
commit a8bc77457d757176a12385b9b588d506fac3f5ee
5 changes: 5 additions & 0 deletions selfdrive/car/ford/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def __init__(self, CP):

self.vehicle_sensors_valid = False

self.prev_distance_button = 0
self.distance_button = 0

def update(self, cp, cp_cam):
ret = car.CarState.new_message()

Expand Down Expand Up @@ -83,6 +86,8 @@ def update(self, cp, cp_cam):
ret.rightBlinker = cp.vl["Steering_Data_FD1"]["TurnLghtSwtch_D_Stat"] == 2
# TODO: block this going to the camera otherwise it will enable stock TJA
ret.genericToggle = bool(cp.vl["Steering_Data_FD1"]["TjaButtnOnOffPress"])
self.prev_distance_button = self.distance_button
self.distance_button = cp.vl["Steering_Data_FD1"]["AccButtnGapTogglePress"]

# lock info
ret.doorOpen = any([cp.vl["BodyInfo_3_FD1"]["DrStatDrv_B_Actl"], cp.vl["BodyInfo_3_FD1"]["DrStatPsngr_B_Actl"],
Expand Down
5 changes: 4 additions & 1 deletion selfdrive/car/ford/interface.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from cereal import car
from panda import Panda
from openpilot.common.conversions import Conversions as CV
from openpilot.selfdrive.car import get_safety_config
from openpilot.selfdrive.car import create_button_events, get_safety_config
from openpilot.selfdrive.car.ford.fordcan import CanBus
from openpilot.selfdrive.car.ford.values import Ecu, FordFlags
from openpilot.selfdrive.car.interfaces import CarInterfaceBase

ButtonType = car.CarState.ButtonEvent.Type
TransmissionType = car.CarParams.TransmissionType
GearShifter = car.CarState.GearShifter

Expand Down Expand Up @@ -61,6 +62,8 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
def _update(self, c):
ret = self.CS.update(self.cp, self.cp_cam)

ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})

events = self.create_common_events(ret, extra_gears=[GearShifter.manumatic])
if not self.CS.vehicle_sensors_valid:
events.add(car.CarEvent.EventName.vehicleSensorsInvalid)
Expand Down
Loading