diff --git a/main.py b/main.py index 956baec..4836620 100644 --- a/main.py +++ b/main.py @@ -17,9 +17,14 @@ left_motor = Motor(Ports.PORT2, GearSetting.RATIO_18_1, False) 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) +flip_motor = Motor(Ports.PORT11, GearSetting.RATIO_18_1, False) run_bottom_motor = False run_invert_bottom_motor = False -speed_modifer = 1 +speed_modifer = 1 +flip = False +def run_flip(): + global flip + flip = not flip def intake(): top_motor.spin(FORWARD, 100, PERCENT) # bottom_motor.spin(FORWARD, 100, PERCENT) @@ -40,19 +45,28 @@ def run_run_bottom_motor(): global run_bottom_motor run_bottom_motor = not run_bottom_motor def user_control(): + global run_bottom_motor + global run_invert_bottom_motor + global speed_modifer + global flip brain.screen.clear_screen() brain.screen.print("driver control") controller.buttonA.pressed(run_run_invert_bottom_motor) bottom_motor.spin(FORWARD, 100, PERCENT) controller.buttonY.pressed(run_run_bottom_motor) + controller.buttonUp.pressed(run_flip) # button.pressed(intake) # button.released(intake(False)) # place driver control in this while loop brain.screen.new_line() while True: - if controller.buttonR1.pressing(): + if flip and flip_motor.position() == 90: + flip_motor.spin(FORWARD, 90, DEGREES) + else: + flip_motor.spin(REVERSE, 90, DEGREES) + if controller.buttonR1.pressing() and speed_modifer < 1: speed_modifer = speed_modifer + 0.1 - if controller.buttonR2.pressing(): + if controller.buttonR2.pressing() and speed_modifer > 0: speed_modifer = speed_modifer - 0.1 if controller.buttonB.pressing(): speed_modifer = 1 @@ -62,15 +76,18 @@ 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 + # if run_invert_bottom_motor: + # run_run_invert_bottom_motor() bottom_motor.spin(FORWARD, 100, PERCENT) top_motor.spin(FORWARD, 100 * speed_modifer, PERCENT) elif run_invert_bottom_motor: - if run_bottom_motor: - not run_bottom_motor + # if run_bottom_motor: + # run_run_bottom_motor() bottom_motor.spin(REVERSE, 100, PERCENT) top_motor.spin(REVERSE, 100, PERCENT) + # elif run_invert_bottom_motor: + # if run_bottom_motor: + # run_run_bottom_motor() else: bottom_motor.stop() top_motor.stop()