Files
sunnypilot-byd/opendbc_repo/opendbc/sunnypilot/car/mazda/icbm.py
T
github-actions[bot] de77c89cf6 sunnypilot v2026.002.000
version: sunnypilot v2026.002.000 (staging)
date: 2026-07-21T07:44:02
master commit: 2c334ede443d7391d27575af8c854a095ba702a8
2026-07-21 07:44:02 +00:00

45 lines
1.7 KiB
Python

"""
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 opendbc.car import structs, DT_CTRL
from opendbc.car.can_definitions import CanData
from opendbc.car.mazda import mazdacan
from opendbc.car.mazda.values import Buttons
from opendbc.sunnypilot.car.intelligent_cruise_button_management_interface_base import IntelligentCruiseButtonManagementInterfaceBase
ButtonType = structs.CarState.ButtonEvent.Type
SendButtonState = structs.IntelligentCruiseButtonManagement.SendButtonState
BUTTONS = {
SendButtonState.increase: Buttons.SET_PLUS,
SendButtonState.decrease: Buttons.SET_MINUS,
}
class IntelligentCruiseButtonManagementInterface(IntelligentCruiseButtonManagementInterfaceBase):
def __init__(self, CP, CP_SP):
super().__init__(CP, CP_SP)
def update(self, CC_SP, CS, packer, frame, last_button_frame) -> list[CanData]:
can_sends = []
self.CC_SP = CC_SP
self.ICBM = CC_SP.intelligentCruiseButtonManagement
self.frame = frame
self.last_button_frame = last_button_frame
if self.ICBM.sendButton != SendButtonState.none:
send_button = BUTTONS[self.ICBM.sendButton]
if (self.frame - self.last_button_frame) * DT_CTRL > 0.2:
self.button_frame += 1
button_counter_offset = [1, 1, 0, None][self.button_frame % 4]
if button_counter_offset is not None:
can_sends.append(mazdacan.create_button_cmd(packer, self.CP, CS.crz_btns_counter + button_counter_offset, send_button))
self.last_button_frame = self.frame
return can_sends