Skip to content

Commit 47425f2

Browse files
authored
Handle a sleep exit with ctrl-c
1 parent 6fd2472 commit 47425f2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

shared-module/time/__init__.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "py/mphal.h"
2828
#include "supervisor/port.h"
2929
#include "supervisor/shared/tick.h"
30+
#include "py/obj.h"
31+
#include "py/mpstate.h"
3032

3133
uint64_t common_hal_time_monotonic(void) {
3234
return supervisor_ticks_ms64();
@@ -42,4 +44,9 @@ uint64_t common_hal_time_monotonic_ns(void) {
4244

4345
void common_hal_time_delay_ms(uint32_t delay) {
4446
mp_hal_delay_ms(delay);
47+
// if the delay was cut short by a CTRL-C then clear the keyboard exception
48+
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)))
49+
{
50+
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
51+
}
4552
}

0 commit comments

Comments
 (0)