Skip to content
Merged
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions opendbc/car/mazda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def __init__(self, CP):
self.lkas_allowed_speed = False

self.distance_button = 0
self.accel_button = 0
self.decel_button = 0

def update(self, can_parsers) -> structs.CarState:
cp = can_parsers[Bus.pt]
Expand All @@ -27,7 +29,11 @@ def update(self, can_parsers) -> structs.CarState:
ret = structs.CarState()

prev_distance_button = self.distance_button
prev_accel_button = self.accel_button
prev_decel_button = self.decel_button
self.distance_button = cp.vl["CRZ_BTNS"]["DISTANCE_LESS"]
self.accel_button = cp.vl["CRZ_BTNS"]["RES"]
self.decel_button = cp.vl["CRZ_BTNS"]["SET_M"]

self.parse_wheel_speeds(ret,
cp.vl["WHEEL_SPEEDS"]["FL"],
Expand Down Expand Up @@ -112,8 +118,12 @@ def update(self, can_parsers) -> structs.CarState:
self.cam_laneinfo = cp_cam.vl["CAM_LANEINFO"]
ret.steerFaultPermanent = cp_cam.vl["CAM_LKAS"]["ERR_BIT_1"] == 1

# TODO: add button types for inc and dec
ret.buttonEvents = create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise})
# cruise control button events: distance, inc, and dec
ret.buttonEvents = [
*create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise}),
*create_button_events(self.accel_button, prev_accel_button, {1: ButtonType.accelCruise}),
*create_button_events(self.decel_button, prev_decel_button, {1: ButtonType.decelCruise}),
]

return ret

Expand Down