diff --git a/apps/code/catalog.de.i18n b/apps/code/catalog.de.i18n index 9cb321ab8..da3c572fb 100644 --- a/apps/code/catalog.de.i18n +++ b/apps/code/catalog.de.i18n @@ -86,6 +86,7 @@ PythonIsFinite = "Prüft ob x endlich ist" PythonIsInfinite = "Prüft ob x unendlich ist" PythonIsNaN = "Prüft ob x NaN ist" PythonIsKeyDown = "true wenn k gedrückt ist" +PythonBattery = "Return battery voltage" PythonKandinskyFunction = "kandinsky module function prefix" PythonLdexp = "Return x*(2**i), inverse of frexp" PythonLength = "Length of an object" diff --git a/apps/code/catalog.en.i18n b/apps/code/catalog.en.i18n index 819887dbb..c3dbf902c 100644 --- a/apps/code/catalog.en.i18n +++ b/apps/code/catalog.en.i18n @@ -80,6 +80,7 @@ PythonIonFunction = "ion module function prefix" PythonIsFinite = "Check if x is finite" PythonIsInfinite = "Check if x is infinity" PythonIsKeyDown = "Return True if the k key is down" +PythonBattery = "Return battery voltage" PythonIsNaN = "Check if x is a NaN" PythonKandinskyFunction = "kandinsky module function prefix" PythonLdexp = "Return x*(2**i), inverse of frexp" diff --git a/apps/code/catalog.es.i18n b/apps/code/catalog.es.i18n index 960dd7eb9..147ffd829 100644 --- a/apps/code/catalog.es.i18n +++ b/apps/code/catalog.es.i18n @@ -80,6 +80,7 @@ PythonIonFunction = "ion module function prefix" PythonIsFinite = "Check if x is finite" PythonIsInfinite = "Check if x is infinity" PythonIsKeyDown = "Return True if the k key is down" +PythonBattery = "Return battery voltage" PythonIsNaN = "Check if x is a NaN" PythonKandinskyFunction = "kandinsky module function prefix" PythonLdexp = "Return x*(2**i), inverse of frexp" diff --git a/apps/code/catalog.fr.i18n b/apps/code/catalog.fr.i18n index 756ef882e..3f756c94f 100644 --- a/apps/code/catalog.fr.i18n +++ b/apps/code/catalog.fr.i18n @@ -80,6 +80,7 @@ PythonIonFunction = "Préfixe fonction module ion" PythonIsFinite = "Teste si x est fini" PythonIsInfinite = "Teste si x est infini" PythonIsKeyDown = "Renvoie True si touche k enfoncée" +PythonBattery = "Renvoie le voltage de la batterie" PythonIsNaN = "Teste si x est NaN" PythonKandinskyFunction = "Préfixe fonction module kandinsky" PythonLdexp = "Inverse de frexp : x*(2**i)" diff --git a/apps/code/catalog.hu.i18n b/apps/code/catalog.hu.i18n index a837db91b..d58d2acb4 100644 --- a/apps/code/catalog.hu.i18n +++ b/apps/code/catalog.hu.i18n @@ -80,6 +80,7 @@ PythonIonFunction = "ion modul funkció elötag" PythonIsFinite = "x véges-e" PythonIsInfinite = "x végtelen-e" PythonIsKeyDown = "True-t válaszol ha a k gomb le van nyomva" +PythonBattery = "Return battery voltage" PythonIsNaN = "Ellenörizze hogy x nem NaN" PythonKandinskyFunction = "kandinsky modul funkció elötag" PythonLdexp = "frexp ellentéte : x*(2**i)" diff --git a/apps/code/catalog.it.i18n b/apps/code/catalog.it.i18n index 94eacc262..c4b753fc9 100644 --- a/apps/code/catalog.it.i18n +++ b/apps/code/catalog.it.i18n @@ -85,6 +85,7 @@ PythonIonFunction = "Prefisso di funzione modulo ion" PythonIsFinite = "Testa se x è finito" PythonIsInfinite = "Testa se x est infinito" PythonIsKeyDown = "Restituisce True premendo tasto k" +PythonBattery = "Return battery voltage" PythonIsNaN = "Testa se x è NaN" PythonKandinskyFunction = "Prefisso funzione modulo kandinsky" PythonLdexp = "Inversa di frexp : x*(2**i)" diff --git a/apps/code/catalog.nl.i18n b/apps/code/catalog.nl.i18n index 1ee1f667c..f3b5d23a2 100644 --- a/apps/code/catalog.nl.i18n +++ b/apps/code/catalog.nl.i18n @@ -85,6 +85,7 @@ PythonIonFunction = "ion module voorvoegsel" PythonIsFinite = "Controleer of x eindig is" PythonIsInfinite = "Controleer of x oneindig is" PythonIsKeyDown = "Geef True als k toets omlaag is" +PythonBattery = "Return battery voltage" PythonIsNaN = "Controleer of x geen getal is" PythonKandinskyFunction = "kandinsky module voorvoegsel" PythonLdexp = "Geeft x*(2**i), inversie van frexp" diff --git a/apps/code/catalog.pt.i18n b/apps/code/catalog.pt.i18n index a17ea0ad5..8698fd5b5 100644 --- a/apps/code/catalog.pt.i18n +++ b/apps/code/catalog.pt.i18n @@ -80,6 +80,7 @@ PythonIonFunction = "Prefixo da função do módulo ion" PythonIsFinite = "Verificar se x é finito" PythonIsInfinite = "Verificar se x é infinito" PythonIsKeyDown = "Devolve True se tecla k pressionada" +PythonBattery = "Return battery voltage" PythonIsNaN = "Verificar se x é um NaN" PythonKandinskyFunction = "Prefixo da função do módulo kandinsky" PythonLdexp = "Devolve x*(2**i), inverso de frexp" diff --git a/apps/code/catalog.universal.i18n b/apps/code/catalog.universal.i18n index 39d1ff3b4..e34015345 100644 --- a/apps/code/catalog.universal.i18n +++ b/apps/code/catalog.universal.i18n @@ -151,6 +151,7 @@ PythonCommandKeyEe = "KEY_EE" PythonCommandKeyAns = "KEY_ANS" PythonCommandKeyExe = "KEY_EXE" PythonCommandIsKeyDown = "keydown(k)" +PythonCommandBattery = "battery()" PythonCommandLdexp = "ldexp(x,i)" PythonCommandLength = "len(object)" PythonCommandLgamma = "lgamma(x)" diff --git a/apps/code/python_toolbox.cpp b/apps/code/python_toolbox.cpp index 568e1f22c..a305c2587 100644 --- a/apps/code/python_toolbox.cpp +++ b/apps/code/python_toolbox.cpp @@ -202,6 +202,7 @@ const ToolboxMessageTree IonModuleChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportFromIon, I18n::Message::PythonImportIon, false), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandIonFunction, I18n::Message::PythonIonFunction, false, I18n::Message::PythonCommandIonFunctionWithoutArg), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandIsKeyDown, I18n::Message::PythonIsKeyDown), + ToolboxMessageTree::Leaf(I18n::Message::PythonCommandBattery, I18n::Message::PythonBattery), ToolboxMessageTree::Leaf(I18n::Message::IonSelector, I18n::Message::IonSelector) }; @@ -323,6 +324,7 @@ const ToolboxMessageTree catalogChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandIsNaN, I18n::Message::PythonIsNaN), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandKandinskyFunction, I18n::Message::PythonKandinskyFunction, false, I18n::Message::PythonCommandKandinskyFunctionWithoutArg), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandIsKeyDown, I18n::Message::PythonIsKeyDown), + ToolboxMessageTree::Leaf(I18n::Message::PythonCommandBattery, I18n::Message::PythonBattery), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandLdexp, I18n::Message::PythonLdexp), ToolboxMessageTree::Leaf(I18n::Message::PythonTurtleCommandLeft, I18n::Message::PythonTurtleLeft), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandLength, I18n::Message::PythonLength), diff --git a/python/port/genhdr/qstrdefs.in.h b/python/port/genhdr/qstrdefs.in.h index c580bcb8e..d620e08fc 100644 --- a/python/port/genhdr/qstrdefs.in.h +++ b/python/port/genhdr/qstrdefs.in.h @@ -323,6 +323,7 @@ Q(zip) // Ion QSTR Q(ion) Q(keydown) +Q(battery) Q(KEY_LEFT) Q(KEY_UP) Q(KEY_DOWN) diff --git a/python/port/mod/ion/modion.cpp b/python/port/mod/ion/modion.cpp index 8ab1ab142..dc6ca0045 100644 --- a/python/port/mod/ion/modion.cpp +++ b/python/port/mod/ion/modion.cpp @@ -12,3 +12,7 @@ mp_obj_t modion_keyboard_keydown(mp_obj_t key_o) { 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()); +} \ No newline at end of file diff --git a/python/port/mod/ion/modion.h b/python/port/mod/ion/modion.h index 4b4558be5..4afa40358 100644 --- a/python/port/mod/ion/modion.h +++ b/python/port/mod/ion/modion.h @@ -1,4 +1,5 @@ #include mp_obj_t modion_keyboard_keydown(mp_obj_t key_o); -extern const mp_obj_type_t file_type; +mp_obj_t modion_battery(); +extern const mp_obj_type_t file_type; \ No newline at end of file diff --git a/python/port/mod/ion/modion_table.cpp b/python/port/mod/ion/modion_table.cpp index 7e6a53bdd..751d29443 100644 --- a/python/port/mod/ion/modion_table.cpp +++ b/python/port/mod/ion/modion_table.cpp @@ -16,8 +16,14 @@ const mp_obj_fun_builtin_fixed_t modion_keyboard_keydown_obj = { {(mp_fun_0_t)modion_keyboard_keydown} }; +const mp_obj_fun_builtin_fixed_t modion_battery_obj = { + {&mp_type_fun_builtin_0}, + {(mp_fun_0_t)modion_battery} +}; + extern "C" const mp_rom_map_elem_t modion_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ion) }, + { MP_ROM_QSTR(MP_QSTR_battery), MP_ROM_PTR(&modion_battery_obj) }, { MP_ROM_QSTR(MP_QSTR_keydown), MP_ROM_PTR(&modion_keyboard_keydown_obj) }, { MP_ROM_QSTR(MP_QSTR_KEY_LEFT), MP_OBJ_NEW_SMALL_INT(Ion::Keyboard::Key::Left) }, { MP_ROM_QSTR(MP_QSTR_KEY_UP), MP_OBJ_NEW_SMALL_INT(Ion::Keyboard::Key::Up) }, diff --git a/python/port/mod/os/modos.cpp b/python/port/mod/os/modos.cpp index 6bf5124d1..f9cbc9266 100644 --- a/python/port/mod/os/modos.cpp +++ b/python/port/mod/os/modos.cpp @@ -111,5 +111,4 @@ mp_obj_t modos_listdir(void) { } return list; -} - +} \ No newline at end of file