mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 08:47:28 +01:00
Ion.battery_level() return a int with the current battery level Ion.battery_ischarging() return a bool with the current battery charging state bugfix for upsilon
26 lines
681 B
C++
26 lines
681 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());
|
|
}
|
|
|
|
mp_obj_t modion_battery_level(){
|
|
return mp_obj_new_int(static_cast<int>(Ion::Battery::level()));
|
|
}
|
|
|
|
mp_obj_t modion_battery_ischarging(){
|
|
return mp_obj_new_bool(Ion::Battery::isCharging());
|
|
} |