Add host simulator scaffolding, examples, and docs so led-driver main can run end-to-end with MicroPython module stubs. Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
410 B
Python
23 lines
410 B
Python
"""CPython stub for MicroPython `utime` (led-simulator)."""
|
|
|
|
import time
|
|
|
|
_MS_MASK = (1 << 30) - 1
|
|
|
|
|
|
def sleep_ms(ms):
|
|
time.sleep(max(0, ms) / 1000.0)
|
|
|
|
|
|
def sleep(s):
|
|
time.sleep(s)
|
|
|
|
|
|
def ticks_ms():
|
|
return int(time.monotonic() * 1000) & _MS_MASK
|
|
|
|
|
|
def ticks_diff(t1, t0):
|
|
"""Approximate MicroPython ticks_diff for host monotonic ms."""
|
|
return ((t1 - t0 + (1 << 29)) & _MS_MASK) - (1 << 29)
|