mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-23 20:52:06 +08:00
check not is ready once
This commit is contained in:
@@ -41,6 +41,7 @@ class CustomStockLongitudinalControllerBase(ABC):
|
||||
self.m_tsc = 0
|
||||
|
||||
self.is_ready = False
|
||||
self.is_ready_prev = False
|
||||
self.cruise_button = None
|
||||
self.speed = 0
|
||||
self.speed_steady = 0
|
||||
@@ -106,6 +107,8 @@ class CustomStockLongitudinalControllerBase(ABC):
|
||||
|
||||
self.cruise_button = self.button_states[self.button_state](self)
|
||||
|
||||
self.is_ready_prev = self.is_ready
|
||||
|
||||
def update(self, CS: car.CarState, CC: car.CarControl) -> list[SendCan]:
|
||||
can_sends = []
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ class ButtonStateBase(ABC):
|
||||
self.timer = INACTIVE_TIMER
|
||||
|
||||
def __call__(self, controller) -> int | None:
|
||||
if not controller.is_ready:
|
||||
self.timer = INACTIVE_TIMER
|
||||
if not controller.is_ready and controller.is_ready_prev:
|
||||
controller.button_state = ButtonControlState.inactive
|
||||
return None
|
||||
|
||||
return self.handle(controller)
|
||||
|
||||
@@ -30,11 +30,12 @@ class InactiveState(ButtonStateBase):
|
||||
def handle(self, controller) -> None:
|
||||
self.button_count = 0
|
||||
|
||||
if controller.is_ready:
|
||||
if self.timer > 0:
|
||||
self.timer -= 1
|
||||
else:
|
||||
controller.button_state = ButtonControlState.loading
|
||||
if not controller.is_ready:
|
||||
self.timer = INACTIVE_TIMER
|
||||
elif self.timer > 0:
|
||||
self.timer -= 1
|
||||
else:
|
||||
controller.button_state = ButtonControlState.loading
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user