[python] modkandinsky: fill_rect and draw_string calls might take some

time. As "micropython_port_vm_hook_loop" is not called while we are
executing module code, we add an extra check for user interruption in
module functions.
This commit is contained in:
Émilie Feral
2019-12-03 17:45:48 +01:00
committed by LeaNumworks
parent 0db66f1784
commit 49aa58446b

View File

@@ -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;
}