diff options
| author | Michael Buesch <m@bues.ch> | 2020-08-31 17:58:51 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-11-30 22:29:03 +1100 |
| commit | 68d1245f423bc98fb7accb86deab10acacd6a9d8 (patch) | |
| tree | 5650b978c55915709acac654e3dfd34db53b60d7 | |
| parent | 1e7c8f2b0bdc7095f28ffda7fbb3c7f23d38b397 (diff) | |
docs/library/machine.Timer.rst: Document `period` and `callback` args.
Signed-off-by: Michael Buesch <m@bues.ch>
| -rw-r--r-- | docs/library/machine.Timer.rst | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/docs/library/machine.Timer.rst b/docs/library/machine.Timer.rst index d1709a818..424a49bcb 100644 --- a/docs/library/machine.Timer.rst +++ b/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. |
