Files
Upsilon/python/port/mod/ion/modion.cpp
FaustinM cf9142b5a2 Add "ion.battery()" for obtain the current voltage of the battery
Ion.battery() return a float with the current battery voltage

TODO : Update the translation of the toolbox (only FR and EN currently)
2021-06-23 16:57:42 +02:00

18 lines
480 B
C++

extern "C" {
#include "modion.h"
#include <py/objtuple.h>
#include <py/runtime.h>
}
#include <ion.h>
#include "port.h"
mp_obj_t modion_keyboard_keydown(mp_obj_t key_o) {
Ion::Keyboard::Key key = static_cast<Ion::Keyboard::Key>(mp_obj_get_int(key_o));
Ion::Keyboard::State state = Ion::Keyboard::scan();
micropython_port_interrupt_if_needed();
return mp_obj_new_bool(state.keyDown(key));
}
mp_obj_t modion_battery() {
return mp_obj_new_float(Ion::Battery::voltage());
}