Mazda: Parse distance button from steering wheel (#31765)

* Mazda: Parse distance button from steering wheel

* Update selfdrive/car/mazda/interface.py

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
pull/31766/head^2
Jason Wen 1 year ago committed by GitHub
parent 32c0bcec3a
commit ab5c0f90b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      selfdrive/car/mazda/carstate.py
  2. 5
      selfdrive/car/mazda/interface.py

@ -18,9 +18,16 @@ class CarState(CarStateBase):
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"],

@ -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
@ -34,6 +34,9 @@ class CarInterface(CarInterfaceBase):
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})
# events
events = self.create_common_events(ret)

Loading…
Cancel
Save