summaryrefslogtreecommitdiffstatshomepage
path: root/docs
diff options
context:
space:
mode:
authorLiaoJingyi_winY7kp <924765359@qq.com>2022-10-23 20:47:14 +0300
committerDamien George <damien@micropython.org>2023-01-19 15:47:45 +1100
commit7f6345a9734f5772b2b579d2ac915cdeb1fcbed1 (patch)
treefd70de6bff3ad53a205667ae903c93da65c0f438 /docs
parent720f2cfba9532879625d5418b04ae21424cb3639 (diff)
downloadmicropython-7f6345a9734f5772b2b579d2ac915cdeb1fcbed1.tar.gz
micropython-7f6345a9734f5772b2b579d2ac915cdeb1fcbed1.zip
docs/library/machine.Timer: Add freq argument to machine.Timer.
Based on and tested on the rp2 port. Signed-off-by: Liao Jingyi <liaojingyi2@gmail> Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'docs')
-rw-r--r--docs/library/machine.Timer.rst10
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/library/machine.Timer.rst b/docs/library/machine.Timer.rst
index 424a49bcba..48c023a11c 100644
--- a/docs/library/machine.Timer.rst
+++ b/docs/library/machine.Timer.rst
@@ -38,13 +38,16 @@ Constructors
Methods
-------
-.. method:: Timer.init(*, mode=Timer.PERIODIC, period=-1, callback=None)
+.. method:: Timer.init(*, mode=Timer.PERIODIC, freq=-1, period=-1, callback=None)
Initialise the timer. Example::
def mycallback(t):
pass
+ # periodic at 1kHz
+ tim.init(mode=Timer.PERIODIC, freq=1000, callback=mycallback)
+
# periodic with 100ms period
tim.init(period=100, callback=mycallback)
@@ -60,6 +63,11 @@ Methods
- ``Timer.PERIODIC`` - The timer runs periodically at the configured
frequency of the channel.
+ - ``freq`` - The timer frequency, in units of Hz. The upper bound of
+ the frequency is dependent on the port. When both the ``freq`` and
+ ``period`` arguments are given, ``freq`` has a higher priority and
+ ``period`` is ignored.
+
- ``period`` - The timer period, in milliseconds.
- ``callback`` - The callable to call upon expiration of the timer period.