by parisse » 10 Jul 2022, 16:22
Ma piste est la suivante: ce serait la routine permettant d'interrompre la VM MicroPython. J'ai mis plus bas mon implementation et celle de Numworks. Dans celle de Numworks, le timer est teste (je pourrais d'ailleurs faire aussi cela, a la place d'attendre 128 appels), et l'ecran est rafraichi. Est-ce que le rafraichissement tous les 100ms environ pourrait expliquer le delai? Ou alors c'est l'appel a chaque fois au timer? Ou le test de la touche d'interruption?
Mon code:
- Code: Select all
int micropython_port_vm_hook_loop() {
/* This function is called very frequently by the MicroPython engine. We grab
* this opportunity to interrupt execution and/or refresh the display on
* platforms that need it. */
/* 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;
if (c & 0x7ff ) {
return 0;
}
// Check if the user asked for an interruption from the keyboard
int g=getkey(mp_interrupt_char | 0x80000000);
if (!g) return 0;
mp_keyboard_interrupt();
return 1;
}
Celui de Epsilon 15.5, inchange dans Epsilon 18:
- Code: Select all
bool micropython_port_vm_hook_loop() {
/* This function is called very frequently by the MicroPython engine. We grab
* this opportunity to interrupt execution and/or refresh the display on
* platforms that need it. */
/* 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 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
return micropython_port_interrupt_if_needed();
}