[python] Clean the time module

- Export micropython_port_should_interrupt and
micropython_port_interruptible_msleep in Emscripten
- Make micropython_port_interruptible_msleep available in a helper
This commit is contained in:
Romain Goyet
2018-11-15 23:27:13 +01:00
committed by Ecco
parent 74efb3edeb
commit 253c183963
4 changed files with 18 additions and 14 deletions

View File

@@ -29,3 +29,10 @@ bool micropython_port_should_interrupt() {
Ion::Keyboard::Key interruptKey = static_cast<Ion::Keyboard::Key>(mp_interrupt_char);
return scan.keyDown(interruptKey);
}
void micropython_port_interruptible_msleep(uint32_t delay) {
uint32_t start = Ion::Timing::millis();
while (Ion::Timing::millis() - start < delay && !micropython_port_should_interrupt()) {
Ion::Timing::msleep(1);
}
}