From e2c609d6a7f55812782a68f9c335def4507f1678 Mon Sep 17 00:00:00 2001 From: Harry Esses Date: Fri, 24 Apr 2026 18:51:34 +0000 Subject: [PATCH] add reverse intake control Signed-off-by: Harry Esses --- main.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 03b0c7b..99a4102 100644 --- a/main.py +++ b/main.py @@ -18,6 +18,7 @@ right_motor = Motor(Ports.PORT9, GearSetting.RATIO_18_1, True) top_motor = Motor(Ports.PORT8, GearSetting.RATIO_18_1, False) bottom_motor = Motor(Ports.PORT3, GearSetting.RATIO_18_1, True) run_bottom_motor = False +run_invert_bottom_motor = False def intake(): top_motor.spin(FORWARD, 100, PERCENT) # bottom_motor.spin(FORWARD, 100, PERCENT) @@ -31,15 +32,18 @@ def autonomous(): # button.pressed(intake(True)) # button.released(intake(False)) -def invert_bottom_motor(): +def run_run_invert_bottom_motor(): + global run_invert_bottom_motor + run_invert_bottom_motor = not run_invert_bottom_motor +def run_run_bottom_motor(): global run_bottom_motor run_bottom_motor = not run_bottom_motor def user_control(): brain.screen.clear_screen() brain.screen.print("driver control") - controller.buttonA.pressed(lambda: controller.rumble("..")) + controller.buttonA.pressed(run_run_invert_bottom_motor) bottom_motor.spin(FORWARD, 100, PERCENT) - controller.buttonY.pressed(invert_bottom_motor) + controller.buttonY.pressed(run_run_bottom_motor) # button.pressed(intake) # button.released(intake(False)) # place driver control in this while loop @@ -51,11 +55,26 @@ def user_control(): brain.sdcard.savefile("motors/left_motor/efficiency.txt", bytearray(str(left_motor.efficiency()))) brain.sdcard.savefile("motors/left_motor/temperature.txt", bytearray(str(left_motor.temperature()))) if run_bottom_motor: + if run_invert_bottom_motor: + not run_invert_bottom_motor bottom_motor.spin(FORWARD, 100, PERCENT) top_motor.spin(FORWARD, 100, PERCENT) + elif run_invert_bottom_motor: + if run_bottom_motor: + not run_bottom_motor + bottom_motor.spin(REVERSE, 100, PERCENT) + top_motor.spin(REVERSE, 100, PERCENT) else: bottom_motor.stop() top_motor.stop() + # if run_invert_bottom_motor: + # if run_bottom_motor: + # not run_bottom_motor + # bottom_motor.spin(REVERSE, 100, PERCENT) + # top_motor.spin(REVERSE, 100, PERCENT) + # else: + # bottom_motor.stop() + # top_motor.stop() print(button.pressing()) brain.screen.clear_screen() # controller.screen.print("controller code")