diff options
| author | Paul Carver <pcarver@att.com> | 2017-11-26 11:29:55 -0500 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2017-11-30 14:56:08 +1100 |
| commit | 7d25a192206f7effa47c24a52607f00efe86e2ef (patch) | |
| tree | 5fdf128cb2721f09d73676e8ab2364e66c685244 /docs | |
| parent | 64f11470bec3c4ce9122593d3dd968e4127eb545 (diff) | |
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.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/library/utime.rst | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/library/utime.rst b/docs/library/utime.rst index a39f5ee73..7fe83f5ab 100644 --- a/docs/library/utime.rst +++ b/docs/library/utime.rst @@ -187,14 +187,14 @@ Functions # This code snippet is not optimized now = time.ticks_ms() scheduled_time = task.scheduled_time() - if ticks_diff(now, scheduled_time) > 0: + if ticks_diff(scheduled_time, now) > 0: print("Too early, let's nap") - sleep_ms(ticks_diff(now, scheduled_time)) + sleep_ms(ticks_diff(scheduled_time, now)) task.run() - elif ticks_diff(now, scheduled_time) == 0: + elif ticks_diff(scheduled_time, now) == 0: print("Right at time!") task.run() - elif ticks_diff(now, scheduled_time) < 0: + elif ticks_diff(scheduled_time, now) < 0: print("Oops, running late, tell task to run faster!") task.run(run_faster=true) |
