From 6aaba7bda4e9ecd016839e3f69953e54545315c7 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 14 Sep 2024 21:18:54 -0400 Subject: [PATCH] make sure to immediately apply state change --- .../lib/custom_stock_longitudinal_controller/states.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sunnypilot/controls/lib/custom_stock_longitudinal_controller/states.py b/sunnypilot/controls/lib/custom_stock_longitudinal_controller/states.py index 3a16562853..6caef9556d 100644 --- a/sunnypilot/controls/lib/custom_stock_longitudinal_controller/states.py +++ b/sunnypilot/controls/lib/custom_stock_longitudinal_controller/states.py @@ -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