Skip to content

Commit efc904c

Browse files
committed
docs/pyboard/quickref: Add section on "delay and timing" for utime mod.
And remove reference to deprecated pyb.delay() and pyb.millis().
1 parent 5c3a2f1 commit efc904c

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

docs/pyboard/quickref.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,25 @@ See :mod:`pyb`. ::
2020

2121
import pyb
2222

23-
pyb.delay(50) # wait 50 milliseconds
24-
pyb.millis() # number of milliseconds since bootup
2523
pyb.repl_uart(pyb.UART(1, 9600)) # duplicate REPL on UART(1)
2624
pyb.wfi() # pause CPU, waiting for interrupt
2725
pyb.freq() # get CPU and bus frequencies
2826
pyb.freq(60000000) # set CPU freq to 60MHz
2927
pyb.stop() # stop CPU, waiting for external interrupt
3028

29+
Delay and timing
30+
----------------
31+
32+
Use the :mod:`time <utime>` module::
33+
34+
import time
35+
36+
time.sleep(1) # sleep for 1 second
37+
time.sleep_ms(500) # sleep for 500 milliseconds
38+
time.sleep_us(10) # sleep for 10 microseconds
39+
start = time.ticks_ms() # get value of millisecond counter
40+
delta = time.ticks_diff(start, time.ticks_ms()) # compute time difference
41+
3142
LEDs
3243
----
3344

0 commit comments

Comments
 (0)