mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-22 07:10:40 +01:00
[code] time module
This commit is contained in:
@@ -24,6 +24,16 @@ Q(draw_string)
|
||||
Q(get_pixel)
|
||||
Q(set_pixel)
|
||||
|
||||
// utime QSTRs
|
||||
Q(time)
|
||||
Q(sleep)
|
||||
Q(sleep_ms)
|
||||
Q(sleep_us)
|
||||
Q(ticks_ms)
|
||||
Q(ticks_us)
|
||||
Q(ticks_add)
|
||||
Q(ticks_diff)
|
||||
|
||||
// MicroPython QSTRs
|
||||
Q()
|
||||
Q(*)
|
||||
|
||||
@@ -4,16 +4,17 @@ extern "C" {
|
||||
#include "mphalport.h"
|
||||
}
|
||||
|
||||
void micropython_port_should_interrupt() {
|
||||
bool micropython_port_should_interrupt() {
|
||||
static int c = 0;
|
||||
c++;
|
||||
if (c%20000 != 0) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
c = 0;
|
||||
Ion::Keyboard::State scan = Ion::Keyboard::scan();
|
||||
if (scan.keyDown((Ion::Keyboard::Key)mp_interrupt_char)) {
|
||||
mp_keyboard_interrupt();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
|
||||
/* 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();
|
||||
bool micropython_port_should_interrupt();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -107,6 +107,8 @@ typedef long mp_off_t;
|
||||
#define MP_STATE_PORT MP_STATE_VM
|
||||
|
||||
extern const struct _mp_obj_module_t kandinsky_module;
|
||||
extern const struct _mp_obj_module_t mp_module_utime;
|
||||
|
||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||
{ MP_ROM_QSTR(MP_QSTR_kandinsky), MP_ROM_PTR(&kandinsky_module) }
|
||||
{ MP_ROM_QSTR(MP_QSTR_kandinsky), MP_ROM_PTR(&kandinsky_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&mp_module_utime) },
|
||||
|
||||
Reference in New Issue
Block a user