mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Merge branch 'omega-hotfix' into omega-dev
This commit is contained in:
@@ -12,12 +12,15 @@ bool micropython_port_vm_hook_loop() {
|
||||
|
||||
/* Doing too many things here slows down Python execution quite a lot. So we
|
||||
* only do things once in a while and return as soon as possible otherwise. */
|
||||
static int c = 0;
|
||||
|
||||
c = (c + 1) % 20000;
|
||||
if (c != 0) {
|
||||
static uint64_t t = Ion::Timing::millis();
|
||||
static constexpr uint64_t delay = 100;
|
||||
|
||||
uint64_t t2 = Ion::Timing::millis();
|
||||
if (t2 - t < delay) {
|
||||
return false;
|
||||
}
|
||||
t = t2;
|
||||
|
||||
micropython_port_vm_hook_refresh_print();
|
||||
// Check if the user asked for an interruption from the keyboard
|
||||
|
||||
@@ -63,16 +63,6 @@ mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t * args) {
|
||||
KDColor backgroundColor = (n_args >= 5) ? MicroPython::Color::Parse(args[4]) : KDColorWhite;
|
||||
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox();
|
||||
KDIonContext::sharedContext()->drawString(text, point, KDFont::LargeFont, textColor, backgroundColor);
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -93,8 +83,6 @@ mp_obj_t modkandinsky_fill_rect(size_t n_args, const mp_obj_t * args) {
|
||||
KDColor color = MicroPython::Color::Parse(args[4]);
|
||||
MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox();
|
||||
KDIonContext::sharedContext()->fillRect(rect, color);
|
||||
// Cf comment on modkandinsky_draw_string
|
||||
micropython_port_interrupt_if_needed();
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,8 @@ KDColor MicroPython::Color::Parse(mp_obj_t input, Mode mode){
|
||||
NamedColor("orange", Palette::Orange),
|
||||
NamedColor("purple", Palette::Purple),
|
||||
NamedColor("grey", Palette::GreyDark),
|
||||
NamedColor("cyan", Palette::Cyan)
|
||||
NamedColor("cyan", Palette::Cyan),
|
||||
NamedColor("magenta", Palette::Magenta)
|
||||
};
|
||||
for (NamedColor p : pairs) {
|
||||
if (strcmp(p.name(), color) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user