mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-25 20:32:07 +08:00
make sure to immediately apply state change
This commit is contained in:
@@ -50,20 +50,22 @@ class LoadingState(ButtonStateBase):
|
||||
|
||||
|
||||
class AcceleratingState(ButtonStateBase):
|
||||
def handle(self, controller) -> int:
|
||||
def handle(self, controller) -> int | None:
|
||||
self.button_count += 1
|
||||
if controller.target_speed <= controller.v_cruise or self.button_count > RESET_COUNT:
|
||||
self.button_count = 0
|
||||
controller.button_state = ButtonControlState.holding
|
||||
return None
|
||||
return controller.accel_button
|
||||
|
||||
|
||||
class DeceleratingState(ButtonStateBase):
|
||||
def handle(self, controller) -> int:
|
||||
def handle(self, controller) -> int | None:
|
||||
self.button_count += 1
|
||||
if controller.target_speed >= controller.v_cruise or controller.v_cruise <= controller.v_cruise_min or self.button_count > RESET_COUNT:
|
||||
self.button_count = 0
|
||||
controller.button_state = ButtonControlState.holding
|
||||
return None
|
||||
return controller.decel_button
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user