add reverse intake control

Signed-off-by: Harry Esses <gitea@local.domain>
This commit is contained in:
Harry Esses
2026-04-24 18:51:34 +00:00
parent 1d97d3ac29
commit e2c609d6a7

25
main.py
View File

@@ -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")