Files
StarPilot/frogpilot/controls/frogpilot_card.py
T
2026-02-13 00:21:29 -07:00

26 lines
1.0 KiB
Python

#!/usr/bin/env python3
from openpilot.common.params import Params
from openpilot.selfdrive.car.cruise import ButtonType
class FrogPilotCard:
def __init__(self, CP, FPCP):
self.CP = CP
self.params = Params(return_defaults=True)
self.params_memory = Params(memory=True)
self.accel_pressed = False
self.decel_pressed = False
def update(self, carState, frogpilotCarState, sm, frogpilot_toggles):
if sm.updated["frogpilotPlan"] or any(be.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for be in carState.buttonEvents):
self.accel_pressed = any(be.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for be in carState.buttonEvents)
if sm.updated["frogpilotPlan"] or any(be.type == ButtonType.decelCruise for be in carState.buttonEvents):
self.decel_pressed = any(be.type == ButtonType.decelCruise for be in carState.buttonEvents)
frogpilotCarState.accelPressed = self.accel_pressed
frogpilotCarState.decelPressed = self.decel_pressed
return frogpilotCarState