Another noob question from me I guess..
I am wanting to use micropython.schedule for two timer callbacks, to avoid random memory allocation errors when the callback triggers.
A single instance works fine, but a second instance doesn't seem to trigger the 2nd callback from the following.
Code: Select all
# After startup create 1 and 5 second HB timers
timHB_1 = Timer(13, freq=1, callback=micropython.schedule(hb1_CB(1),None))
timHB_1.init(freq=1)
time.sleep(0.1)
# Brief sleep not necessary if not 'scheduling' next timer? but doesn't allow the two scheduled callbacks to work
# timHB_5 = Timer(14, freq=0.2, callback=micropython.schedule(hb5_CB(1),None))
# Don't seem to be able to use multiple instances of .schedule?
timHB_5 = Timer(14, freq=0.2, callback=hb5_CB)
timHB_5.init(freq=0.2)
I only get the memory allocation if the first timer callback (1 second) is called directly. As written above, the second callback (5 seconds) works fine as long as the first one is scheduled callback. I haven't found a detailed explanation of micropython.scheduleso I am not sure if I can even use multiple schedule items but the text indicates there is a 'list' of scheduled calls. Do I have to number the schedule calls?