diff --git a/maix/__init__.py b/maix/__init__.py index bce94e77..a6d1114e 100644 --- a/maix/__init__.py +++ b/maix/__init__.py @@ -4,8 +4,11 @@ from ._maix.peripheral.key import add_default_listener from .__signal_handle__ import register_signal_handle from ._maix.util import register_atexit +from . import __maix_time__ from . import _maix +del __maix_time__ # update time module then delete + register_signal_handle() del register_signal_handle diff --git a/maix/__maix_time__.py b/maix/__maix_time__.py new file mode 100644 index 00000000..5dfdea5c --- /dev/null +++ b/maix/__maix_time__.py @@ -0,0 +1,12 @@ +from . import _maix +import time + +def sleep_ms(ms : int): + time.sleep(ms * 0.001) + +def sleep_us(us: int): + time.sleep(us * 0.000001) + +_maix.time.sleep = time.sleep +_maix.time.sleep_ms = sleep_ms +_maix.time.sleep_us = sleep_us