Skip to content

Commit

Permalink
optimize sleep func fix error in thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Jun 7, 2024
1 parent 36f1790 commit 4330fe1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions maix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions maix/__maix_time__.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4330fe1

Please sign in to comment.