Code: Select all
>>> tim = Timer(1, mode=Timer.PERIODIC)
>>> def tick(timer): print(timer.counter())
...
>>> tim.callback(tick)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: no such attribute
>>>
Code: Select all
from machine import Pin
from machine import Timer
tim = Timer(1, mode=Timer.PERIODIC)
tim_a = tim.channel(Timer.A, period=10000)
tim_a.time()
p_out = Pin('GP10', mode=Pin.OUT)
def tick():
print(tim_a.time())
p_out.toggle()
tim_a.callback(handler=tick)
So, ideas?
Yet another discrepancy between the documentation and implementation or?!?