From 47425f21cc73c8038f79231521bd60c163092211 Mon Sep 17 00:00:00 2001 From: DavePutz Date: Tue, 16 Jun 2020 15:10:23 -0500 Subject: [PATCH] Handle a sleep exit with ctrl-c --- shared-module/time/__init__.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shared-module/time/__init__.c b/shared-module/time/__init__.c index 347e68ae02..fad72c4b26 100644 --- a/shared-module/time/__init__.c +++ b/shared-module/time/__init__.c @@ -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; + } }