diff --git a/python/port/mod/kandinsky/modkandinsky.cpp b/python/port/mod/kandinsky/modkandinsky.cpp index eacc184ae..408292db5 100644 --- a/python/port/mod/kandinsky/modkandinsky.cpp +++ b/python/port/mod/kandinsky/modkandinsky.cpp @@ -70,6 +70,10 @@ mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t * args) { KDColor backgroundColor = (n_args >= 5) ? ColorForTuple(args[4]) : KDColorWhite; MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox(); KDIonContext::sharedContext()->drawString(text, point, KDFont::LargeFont, textColor, backgroundColor); + /* drawString function might take some time to execute so we add an extra check + * for user interruption (to avoid freezing in an infinite loop calling + * 'drawString' for instance). */ + micropython_port_interrupt_if_needed(); return mp_const_none; } @@ -83,5 +87,9 @@ mp_obj_t modkandinsky_fill_rect(size_t n_args, const mp_obj_t * args) { KDColor color = ColorForTuple(args[4]); MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox(); KDIonContext::sharedContext()->fillRect(rect, color); + /* fillRect function might take some time to execute so we add an extra check + * for user interruption (to avoid freezing in an infinite loop calling + * 'fillRect' for instance). */ + micropython_port_interrupt_if_needed(); return mp_const_none; }