Long Timer Never Gets Called
On a Raspberry Pico a timer with a period of 300000 (5 minutes) gets called reliably while another timer with a period of 900000 (15 minutes) never gets called. Changing the period of task3 to 300000 gets it working again.
task1 = Timer()
task2 = Timer()
task3 = Timer()
task1.init(period=60000, mode=Timer.PERIODIC, callback=get_gnss)
task2.init(period=300000, mode=Timer.PERIODIC, callback=get_temperature)
task3.init(period=900000, mode=Timer.PERIODIC, callback=put_data)
Software timer misfiring after gc.collect()
Hi guys
My board is RP-Pico with firmware:
MicroPython v1.19.1 on 2022-10-14; Raspberry Pi Pico with RP2040
Type "help()" for more information.
I found an issue related to garbage collector which break a timer if a timer was created as a local variable.
For example:
def test():
Timer(period=10000, mode=Timer.ONE_SHOT, callback=lambda t: print(t))
>>> test()
>>> Timer(mode=ONE_SHOT, period=268687648, tick_hz=1000000)
>>>
>>> test()
>>> gc.collect()
...
# and after 10secs there is no print message
It's sounds like, garbage collector freed timer, and this should happen because timer was a local variable. But from the other side, it's a mistake due to the timer never fired up.
Is this bug or feature? Which behavior is right?
As for me, more delicate solution will be clearing already finished timers.
If it's a bug, i will try to make some pull request to fix it.