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

Mazda: Parse distance button from steering wheel #31765

Merged
merged 2 commits into from
Mar 12, 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
7 changes: 7 additions & 0 deletions selfdrive/car/mazda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ def __init__(self, CP):
self.lkas_allowed_speed = False
self.lkas_disabled = False

self.prev_distance_button = 0
self.distance_button = 0

def update(self, cp, cp_cam):

ret = car.CarState.new_message()

self.prev_distance_button = self.distance_button
self.distance_button = cp.vl["CRZ_BTNS"]["DISTANCE_LESS"]

ret.wheelSpeeds = self.get_wheel_speeds(
cp.vl["WHEEL_SPEEDS"]["FL"],
cp.vl["WHEEL_SPEEDS"]["FR"],
Expand Down
5 changes: 4 additions & 1 deletion selfdrive/car/mazda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from cereal import car
from openpilot.common.conversions import Conversions as CV
from openpilot.selfdrive.car.mazda.values import CAR, LKAS_LIMITS
from openpilot.selfdrive.car import get_safety_config
from openpilot.selfdrive.car import create_button_events, get_safety_config
from openpilot.selfdrive.car.interfaces import CarInterfaceBase

ButtonType = car.CarState.ButtonEvent.Type
Expand Down Expand Up @@ -34,6 +34,9 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
def _update(self, c):
ret = self.CS.update(self.cp, self.cp_cam)

# TODO: add button types for inc and dec
ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})
sshane marked this conversation as resolved.
Show resolved Hide resolved

# events
events = self.create_common_events(ret)

Expand Down
Loading