chore: move led-simulator in from its submodule
Merges led-simulator (sim-bridge, 4d8aeb5) under led-simulator/ with its history,
in place of the submodule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
698c1463c0
41 files changed
+4369
-4
No files matched your search
@@ -0,0 +1,49 @@
|
||||
"""CPython stub for MicroPython ``utime`` (led-simulator)."""
|
||||
|
||||
import time as _time
|
||||
|
||||
_MS_PERIOD = 1 << 30
|
||||
_MS_MASK = _MS_PERIOD - 1
|
||||
_HALF = _MS_PERIOD // 2
|
||||
_T0 = _time.monotonic()
|
||||
|
||||
|
||||
def sleep_ms(ms):
|
||||
_time.sleep(max(0, ms) / 1000.0)
|
||||
|
||||
|
||||
def sleep_us(us):
|
||||
_time.sleep(max(0, us) / 1000000.0)
|
||||
|
||||
|
||||
def sleep(s):
|
||||
_time.sleep(s)
|
||||
|
||||
|
||||
def ticks_ms():
|
||||
return int((_time.monotonic() - _T0) * 1000) & _MS_MASK
|
||||
|
||||
|
||||
def ticks_us():
|
||||
return int((_time.monotonic() - _T0) * 1000000) & _MS_MASK
|
||||
|
||||
|
||||
ticks_cpu = ticks_us
|
||||
|
||||
|
||||
def ticks_add(ticks, delta):
|
||||
return (int(ticks) + int(delta)) & _MS_MASK
|
||||
|
||||
|
||||
def ticks_diff(t1, t0):
|
||||
"""Signed difference with wrap-around, like MicroPython."""
|
||||
return ((int(t1) - int(t0) + _HALF) & _MS_MASK) - _HALF
|
||||
|
||||
|
||||
def time():
|
||||
"""Whole seconds, like MicroPython."""
|
||||
return int(_time.time())
|
||||
|
||||
|
||||
def time_ns():
|
||||
return _time.time_ns()
|
||||
Reference in new issue
Block a user