מיקרופייתון – TIME
The equivalents to delay()
and delayMicroseconds()
when using ESP32 with MicroPython are sleep_ms()
or sleep_us()
. In addition, you can use sleep()
which takes seconds as parameter.
millis()
and micros()
are called ticks_ms()
and ticks_us()
in MicroPython. With ticks_diff()
you can determine time spans. Here is a small example:
1 2 3 4 5 6 7 8 9 |
import time start_ms = time.ticks_ms() start_us = time.ticks_us() print("Millisecs: ", start_ms) print("Microsecs: ", start_us) time.sleep(3) delta = time.ticks_diff(time.ticks_ms(), start_ms) print("Delta =", delta) |