import supply_voltage #导入它，开启电量指示呼吸灯功能
import motor
import controller
import time
import buzzer

sudu = None


左轮 = motor.smart_motor(1, direction=True)
左轮.set_soft_break(True)
右轮 = motor.smart_motor(2, direction=False)
右轮.set_soft_break(True)
sudu = 0
while True:
    左轮.openloop_turn((controller.get_axis(controller.LEFT_Y) * (sudu / 100)))
    右轮.openloop_turn((controller.get_axis(controller.RIGHT_Y) * (sudu / 100)))
    if controller.get_button(controller.A):
        sudu = 30
    elif controller.get_button(controller.M):
        sudu = 60
    elif controller.get_button(controller.ROCKET):
        sudu = 100
    elif controller.get_button(controller.P):
        sudu = 0
    if controller.get_button(controller.L1):
        time.sleep(0.5)
        if controller.get_button(controller.L1) == True:
            while not controller.get_button(controller.L1) == False:
                buzzer.play_tone(440, 50)
            buzzer.stop()
        else:
            buzzer.play_tone(440, 50)
            time.sleep(0.2)
            buzzer.stop()
