I came across a DFU issue in my project. Basic information:
- two buttons are connected to the pyboard 1.1's digital inputs, the user can move a stepper motor manually by pressing them. This code is located in main.py
- user can also provide a PWM frequency and time delay and pyboard will move the motor according to that. This piece of code runs on PC:
Code: Select all
import pyboard
def serial(f1, t1):
t_ser = str(int(t1))
f_ser = str(f1)
pyb = pyboard.Pyboard('com7')
pyb.enter_raw_repl()
pyb.exec('from pyb import Pin, Timer')
pyb.exec("import time")
pyb.exec("import machine")
pyb.exec("step = Pin('X1')")
pyb.exec("direction = Pin('X2', Pin.OUT_PP)")
pyb.exec("direction.low()")
pyb.exec("tim = Timer(2, freq=" + f_ser + ")")
pyb.exec("ch = tim.channel(1, Timer.PWM, pin=step)")
pyb.exec("ch.pulse_width_percent(50)")
pyb.exec("pyb.delay("+ t_ser + ")")
pyb.exec("tim.deinit()")
pyb.exec("machine.reset()")
pyb.exit_raw_repl()
pyb.close()