Yes, you can either create a timer and then set it running later, or create a timer and set it running simultaneously.Yeah, the documentation is just unclear as it only says the constructor takes the same arguments as init() but doesn't mention that providing them starts the timer immediately. Behind the scenes, if those arguments are given, MP calls init() as part of timer creation.
The bigger problem with -
Code:
Timer(period=100, mode=Timer.PERIODIC, callback=acc_decc)
Code:
myTimer = Timer(period=100, mode=Timer.PERIODIC, callback=acc_decc)
And this is also the case if 'myTimer = Timer(....)' appears in a function because 'myTimer' disappears into the garbage when that function exits. One needs to make 'myTimer' a global to avoid that.
Code:
Timer(period=100, mode=Timer.PERIODIC, callback=acc_decc)
And we are trying to second-guess what it is the OP wants to achieve.
Statistics: Posted by hippy — Tue Jan 16, 2024 1:57 pm