Add support for millisecond delays within a macro sequence

This commit is contained in:
Josh Klar
2018-09-30 21:34:16 -07:00
parent 2c05efa805
commit fde9b7e274
4 changed files with 28 additions and 1 deletions

View File

@@ -29,3 +29,16 @@ def reset_bootloader():
import microcontroller
microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER)
microcontroller.reset()
def sleep_ms(ms):
'''
Tries to sleep for a number of milliseconds in a cross-implementation
way. Will raise an ImportError if time is not available on the platform.
'''
try:
import time
time.sleep_ms(ms)
except AttributeError:
import time
time.sleep(ms / 1000)