Browse Source

docs/library/machine.Timer.rst: Document `period` and `callback` args.

Signed-off-by: Michael Buesch <m@bues.ch>
pull/8055/head
Michael Buesch 4 years ago
committed by Damien George
parent
commit
68d1245f42
  1. 18
      docs/library/machine.Timer.rst

18
docs/library/machine.Timer.rst

@ -42,8 +42,14 @@ Methods
Initialise the timer. Example::
tim.init(period=100) # periodic with 100ms period
tim.init(mode=Timer.ONE_SHOT, period=1000) # one shot firing after 1000ms
def mycallback(t):
pass
# periodic with 100ms period
tim.init(period=100, callback=mycallback)
# one shot firing after 1000ms
tim.init(mode=Timer.ONE_SHOT, period=1000, callback=mycallback)
Keyword arguments:
@ -54,6 +60,14 @@ Methods
- ``Timer.PERIODIC`` - The timer runs periodically at the configured
frequency of the channel.
- ``period`` - The timer period, in milliseconds.
- ``callback`` - The callable to call upon expiration of the timer period.
The callback must take one argument, which is passed the Timer object.
The ``callback`` argument shall be specified. Otherwise an exception
will occurr upon timer expiration:
``TypeError: 'NoneType' object isn't callable``
.. method:: Timer.deinit()
Deinitialises the timer. Stops the timer, and disables the timer peripheral.

Loading…
Cancel
Save