Merge remote-tracking branch 'upstream/master' into omega-dev

This commit is contained in:
Quentin Guidée
2019-12-15 14:18:36 +01:00
8 changed files with 125 additions and 44 deletions

View File

@@ -74,9 +74,15 @@ 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). */
/* Before and after execution of "modkandinsky_draw_string",
* "micropython_port_vm_hook_loop" is called by "mp_execute_bytecode" and will
* call "micropython_port_interrupt_if_needed" every 20000 calls.
* However, "drawString" function might take some time to execute leading to
* drastically decrease the frequency of calls to
* "micropython_port_vm_hook_loop" and thus to
* "micropython_port_interrupt_if_needed". So we add an extra
* check for user interruption here. This way the user can still interrupt an
* infinite loop calling 'drawString' for instance. */
micropython_port_interrupt_if_needed();
return mp_const_none;
}
@@ -91,9 +97,7 @@ 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). */
// Cf comment on modkandinsky_draw_string
micropython_port_interrupt_if_needed();
return mp_const_none;
}