Code: Select all
pulses = pyb.Timer(2, freq=1000)
pulses.channel(3, pyb.Timer.PWM, pin=pyb.Pin.board.PA2, pulse_width_percent=100)
pulses.channel(4, pyb.Timer.PWM, pin=pyb.Pin.board.PA3, pulse_width_percent=100)
def speed_adj(R_mot_percent,L_mot_percent):
pulses.channel(3, pyb.Timer.PWM, pin=pyb.Pin.board.PA2, pulse_width_percent=R_mot_percent)
pulses.channel(4, pyb.Timer.PWM, pin=pyb.Pin.board.PA3, pulse_width_percent=L_mot_percent)
MemoryError: memory allocation failed, heap is locked
p.ex. when i send the "2" command from bluetooth, will get error at speed_adj(50,50):
Code: Select all
def speed_test():
speed_adj(50,50)
commands = [idle,manual,speed_test]
def command(id):
commands[id]()
def BTread(BTcheck):
if BT.any() == True:
command(BT.readchar())
BTcheck = pyb.Timer(1)
BTcheck.init(freq=100)
BTcheck.callback(BTread)