Handle a sleep exit with ctrl-c

This commit is contained in:
DavePutz 2020-06-16 15:10:23 -05:00 committed by GitHub
parent 6fd24725b8
commit 47425f21cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,8 @@
#include "py/mphal.h"
#include "supervisor/port.h"
#include "supervisor/shared/tick.h"
#include "py/obj.h"
#include "py/mpstate.h"
uint64_t common_hal_time_monotonic(void) {
return supervisor_ticks_ms64();
@ -42,4 +44,9 @@ uint64_t common_hal_time_monotonic_ns(void) {
void common_hal_time_delay_ms(uint32_t delay) {
mp_hal_delay_ms(delay);
// if the delay was cut short by a CTRL-C then clear the keyboard exception
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)))
{
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
}
}