예제 #1
0
# check IDE mode
ide_mode_conf = "/flash/ide_mode.conf"
ide = True
try:
    f = open(ide_mode_conf)
    f.close()
    del f
except Exception:
    ide = False

if ide:
    os.remove(ide_mode_conf)
    from machine import UART
    import lcd
    lcd.init(color=lcd.PINK)
    repl = UART.repl_uart()
    repl.init(1500000, 8, None, 1, read_buf_len=2048, ide=True, from_ide=False)
    sys.exit()
del ide, ide_mode_conf

# detect boot.py
main_py = '''
try:
    import gc, lcd, image, sys, os
    from Maix import GPIO
    from fpioa_manager import fm
    test_pin=16
    fm.fpioa.set_function(test_pin,fm.fpioa.GPIO7)
    test_gpio=GPIO(GPIO.GPIO7,GPIO.IN,GPIO.PULL_UP)
    lcd.init()
    lcd.clear(color=(255,0,0))
예제 #2
0
    pitch = Servo(pitch_pwm, dir=init_pitch)
    roll = Servo(roll_pwm, dir=init_roll)
    pid_pitch = PID(p=pitch_pid[0],
                    i=pitch_pid[1],
                    d=pitch_pid[2],
                    imax=pitch_pid[3])
    pid_roll = PID(p=roll_pid[0],
                   i=roll_pid[1],
                   d=roll_pid[2],
                   imax=roll_pid[3])
    gimbal = Gimbal(pitch, pid_pitch, roll, pid_roll)

    target_pitch = init_pitch
    target_roll = init_roll
    t = time.ticks_ms()
    _dir = 0
    t0 = time.ticks_ms()
    stdin = UART.repl_uart()
    while 1:
        # get target error
        err_pitch, err_roll = target.get_target_err()
        # interval limit to > 10ms
        if time.ticks_ms() - t0 < 10:
            continue
        t0 = time.ticks_ms()
        # run
        gimbal.run(err_pitch,
                   err_roll,
                   pitch_reverse=pitch_reverse,
                   roll_reverse=roll_reverse)