[python] Rename micropython_port_should_interrupt to micropython_port_vm_hook_loop

This commit is contained in:
Romain Goyet
2018-11-08 13:29:49 +01:00
committed by LeaNumworks
parent 9825c73238
commit 5dfefb477a
4 changed files with 14 additions and 8 deletions

View File

@@ -4,15 +4,23 @@ extern "C" {
#include "mphalport.h"
}
void micropython_port_should_interrupt() {
void 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%20000 != 0) {
if (c % 20000 != 0) {
return;
}
c = 0;
/* Check if the user asked for an interruption from the keyboard */
Ion::Keyboard::State scan = Ion::Keyboard::scan();
if (scan.keyDown((Ion::Keyboard::Key)mp_interrupt_char)) {
if (scan.keyDown(static_cast<Ion::Keyboard::Key>(mp_interrupt_char))) {
mp_keyboard_interrupt();
}
}

View File

@@ -5,9 +5,7 @@
extern "C" {
#endif
/* should_interrupt effectively does something once every 20000 calls. It checks
* if a key is down to raise an interruption flag. */
void micropython_port_should_interrupt();
void micropython_port_vm_hook_loop();
#ifdef __cplusplus
}

View File

@@ -90,7 +90,7 @@
// (This scheme won't work if we want to mix Thumb and normal ARM code.)
#define MICROPY_MAKE_POINTER_CALLABLE(p) (p)
#define MICROPY_VM_HOOK_LOOP micropython_port_should_interrupt();
#define MICROPY_VM_HOOK_LOOP micropython_port_vm_hook_loop();
typedef intptr_t mp_int_t; // must be pointer size
typedef uintptr_t mp_uint_t; // must be pointer size