Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 7d25a19

Browse files
pcarverdpgeorge
authored andcommitted
docs/library/utime: Fix incorrect example with ticks_diff args order.
The parameter order in the example for ticks_diff was incorrect. If it's "too early" that means that scheduled time is greater than current time and if it's "running late" then scheduled time would be less than current time.
1 parent 64f1147 commit 7d25a19

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/library/utime.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,14 @@ Functions
187187
# This code snippet is not optimized
188188
now = time.ticks_ms()
189189
scheduled_time = task.scheduled_time()
190-
if ticks_diff(now, scheduled_time) > 0:
190+
if ticks_diff(scheduled_time, now) > 0:
191191
print("Too early, let's nap")
192-
sleep_ms(ticks_diff(now, scheduled_time))
192+
sleep_ms(ticks_diff(scheduled_time, now))
193193
task.run()
194-
elif ticks_diff(now, scheduled_time) == 0:
194+
elif ticks_diff(scheduled_time, now) == 0:
195195
print("Right at time!")
196196
task.run()
197-
elif ticks_diff(now, scheduled_time) < 0:
197+
elif ticks_diff(scheduled_time, now) < 0:
198198
print("Oops, running late, tell task to run faster!")
199199
task.run(run_faster=true)
200200

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy