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.
This commit is contained in:
parent
64f11470be
commit
7d25a19220
|
@ -187,14 +187,14 @@ Functions
|
||||||
# This code snippet is not optimized
|
# This code snippet is not optimized
|
||||||
now = time.ticks_ms()
|
now = time.ticks_ms()
|
||||||
scheduled_time = task.scheduled_time()
|
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")
|
print("Too early, let's nap")
|
||||||
sleep_ms(ticks_diff(now, scheduled_time))
|
sleep_ms(ticks_diff(scheduled_time, now))
|
||||||
task.run()
|
task.run()
|
||||||
elif ticks_diff(now, scheduled_time) == 0:
|
elif ticks_diff(scheduled_time, now) == 0:
|
||||||
print("Right at time!")
|
print("Right at time!")
|
||||||
task.run()
|
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!")
|
print("Oops, running late, tell task to run faster!")
|
||||||
task.run(run_faster=true)
|
task.run(run_faster=true)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue