Revert "Mazda: Parse cruise control buttons (#307)"

This reverts commit 153d90c2e5.
This commit is contained in:
Jason Wen
2026-02-02 22:18:34 -05:00
parent a653199681
commit 4d4b8b08da
4 changed files with 3 additions and 67 deletions

View File

@@ -4,15 +4,12 @@ from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.interfaces import CarStateBase
from opendbc.car.mazda.values import DBC, LKAS_LIMITS
from opendbc.sunnypilot.car.mazda.carstate_ext import CarStateExt
ButtonType = structs.CarState.ButtonEvent.Type
class CarState(CarStateBase, CarStateExt):
class CarState(CarStateBase):
def __init__(self, CP, CP_SP):
CarStateBase.__init__(self, CP, CP_SP)
CarStateExt.__init__(self, CP, CP_SP)
super().__init__(CP, CP_SP)
can_define = CANDefine(DBC[CP.carFingerprint][Bus.pt])
self.shifter_values = can_define.dv["GEAR"]["GEAR"]
@@ -116,13 +113,8 @@ class CarState(CarStateBase, CarStateExt):
self.cam_laneinfo = cp_cam.vl["CAM_LANEINFO"]
ret.steerFaultPermanent = cp_cam.vl["CAM_LKAS"]["ERR_BIT_1"] == 1
CarStateExt.update(self, ret, ret_sp, can_parsers)
# TODO: add button types for inc and dec
ret.buttonEvents = [
*create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise}),
*self.button_events,
]
ret.buttonEvents = create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise})
return ret, ret_sp

View File

@@ -1,36 +0,0 @@
"""
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
from enum import StrEnum
from opendbc.car import Bus, structs
from opendbc.can.parser import CANParser
from opendbc.sunnypilot.car.mazda.values import BUTTONS
class CarStateExt:
def __init__(self, CP, CP_SP):
self.CP = CP
self.CP_SP = CP_SP
self.button_events = []
self.button_states = {button.event_type: False for button in BUTTONS}
def update(self, ret: structs.CarState, ret_sp: structs.CarStateSP, can_parsers: dict[StrEnum, CANParser]):
cp = can_parsers[Bus.pt]
button_events = []
for button in BUTTONS:
state = (cp.vl[button.can_addr][button.can_msg] in button.values)
if self.button_states[button.event_type] != state:
event = structs.CarState.ButtonEvent.new_message()
event.type = button.event_type
event.pressed = state
button_events.append(event)
self.button_states[button.event_type] = state
self.button_events = button_events

View File

@@ -1,20 +0,0 @@
"""
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
from collections import namedtuple
from opendbc.car import structs
ButtonType = structs.CarState.ButtonEvent.Type
Button = namedtuple('Button', ['event_type', 'can_addr', 'can_msg', 'values'])
BUTTONS = [
Button(ButtonType.accelCruise, "CRZ_BTNS", "SET_P", [1]),
Button(ButtonType.decelCruise, "CRZ_BTNS", "SET_M", [1]),
Button(ButtonType.cancel, "CRZ_BTNS", "CAN_OFF", [1]),
Button(ButtonType.resumeCruise, "CRZ_BTNS", "RES", [1]),
]