mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/python] Add set_brightness and get_brightness in Ion module (#132)
This commit is contained in:
@@ -105,6 +105,8 @@ PythonIsKeyDown = "Wahr, wenn die Taste k gedrückt ist"
|
||||
PythonBattery = "Rückgabe der Batteriespannung"
|
||||
PythonBatteryLevel = "Gibt den Batteriestand zurück"
|
||||
PythonBatteryIscharging = "Gibt zurück, ob die Batterie geladen wird"
|
||||
PythonSetBrightness = "Helligkeitsstufe festlegen"
|
||||
PythonGetBrightness = "Helligkeitsstufe abrufen"
|
||||
PythonKandinskyFunction = "Kandinsky-Modul Funktionspräfix"
|
||||
PythonLdexp = "Liefert x*(2**i), Inverse von frexp"
|
||||
PythonLength = "Länge eines Objekts"
|
||||
|
||||
@@ -90,6 +90,8 @@ PythonIsKeyDown = "Return True if the k key is down"
|
||||
PythonBattery = "Return battery voltage"
|
||||
PythonBatteryLevel = "Return battery level"
|
||||
PythonBatteryIscharging = "Return if battery is charging"
|
||||
PythonSetBrightness = "Set brightness level"
|
||||
PythonGetBrightness = "Get brightness level"
|
||||
PythonIsNaN = "Check if x is a NaN"
|
||||
PythonKandinskyFunction = "kandinsky module function prefix"
|
||||
PythonLdexp = "Return x*(2**i), inverse of frexp"
|
||||
|
||||
@@ -90,6 +90,8 @@ PythonIsKeyDown = "Return True if the k key is down"
|
||||
PythonBattery = "Rückgabe der Batteriespannung"
|
||||
PythonBatteryLevel = "Gibt den Batteriestand zurück"
|
||||
PythonBatteryIscharging = "Gibt zurück, ob die Batterie geladen wird"
|
||||
PythonSetBrightness = "Establecer nivel de brillo"
|
||||
PythonGetBrightness = "Obtener nivel de brillo"
|
||||
PythonIsNaN = "Check if x is a NaN"
|
||||
PythonKandinskyFunction = "kandinsky module function prefix"
|
||||
PythonLdexp = "Return x*(2**i), inverse of frexp"
|
||||
|
||||
@@ -90,6 +90,8 @@ PythonIsKeyDown = "Renvoie True si touche k enfoncée"
|
||||
PythonBattery = "Renvoie le voltage de la batterie"
|
||||
PythonBatteryLevel = "Renvoie le niveau de la batterie"
|
||||
PythonBatteryIscharging = "Chargement en cours"
|
||||
PythonSetBrightness = "Définir le niveau de luminosité"
|
||||
PythonGetBrightness = "Obtenir le niveau de luminosité"
|
||||
PythonIsNaN = "Teste si x est NaN"
|
||||
PythonKandinskyFunction = "Préfixe fonction module kandinsky"
|
||||
PythonLdexp = "Inverse de frexp : x*(2**i)"
|
||||
@@ -127,7 +129,7 @@ PythonRandrange = "Nombre dans range(start,stop)"
|
||||
PythonRangeStartStop = "Liste de start à stop-1"
|
||||
PythonRangeStop = "Liste de 0 à stop-1"
|
||||
PythonRect = "Conversion en algébrique"
|
||||
PythonRemove = "Supprime le premier x de la liste"
|
||||
PythonRemove = "Supprime le premier x de la liste"
|
||||
PythonReverse = "Inverse les éléments de la liste"
|
||||
PythonRound = "Arrondi à n décimales"
|
||||
PythonScatter = "Nuage des points (x,y)"
|
||||
|
||||
@@ -90,6 +90,8 @@ PythonIsKeyDown = "True-t válaszol ha a k gomb le van nyomva"
|
||||
PythonBattery = "Az akkumulátor feszültségének visszaadása"
|
||||
PythonBatteryLevel = "Az akkumulátor töltöttségi szintjének visszaadása"
|
||||
PythonBatteryIscharging = "Visszaadja, ha az akkumulátor töltődik"
|
||||
PythonSetBrightness = "Fényerőszint beállítása"
|
||||
PythonGetBrightness = "Get brightness level"
|
||||
PythonIsNaN = "Ellenörizze hogy x nem NaN"
|
||||
PythonKandinskyFunction = "kandinsky modul funkció elötag"
|
||||
PythonLdexp = "frexp ellentéte : x*(2**i)"
|
||||
|
||||
@@ -104,6 +104,8 @@ PythonIsKeyDown = "Restituisce True premendo tasto k"
|
||||
PythonBattery = "Restituisce la tensione della batteria"
|
||||
PythonBatteryLevel = "Restituisce il livello della batteria"
|
||||
PythonBatteryIscharging = "Restituisce se la batteria è in carica"
|
||||
PythonSetBrightness = "Imposta livello di luminosità"
|
||||
PythonGetBrightness = "Ottieni livello di luminosità"
|
||||
PythonIsNaN = "Testa se x è NaN"
|
||||
PythonKandinskyFunction = "Prefisso funzione modulo kandinsky"
|
||||
PythonLdexp = "Inversa di frexp : x*(2**i)"
|
||||
@@ -141,7 +143,7 @@ PythonRandrange = "Numero dentro il range(start, stop)"
|
||||
PythonRangeStartStop = "Lista da start a stop-1"
|
||||
PythonRangeStop = "Lista da 0 a stop-1"
|
||||
PythonRect = "Converte in coordinate algebriche"
|
||||
PythonRemove = "Cancella la prima x dalla lista"
|
||||
PythonRemove = "Cancella la prima x dalla lista"
|
||||
PythonReverse = "Inverte gli elementi della lista"
|
||||
PythonRound = "Arrotondato a n cifre decimali"
|
||||
PythonScatter = "Diagramma dispersione y in f. di x"
|
||||
|
||||
@@ -105,6 +105,8 @@ PythonIsKeyDown = "Geef True als k toets omlaag is"
|
||||
PythonBattery = "Return batterijspanning"
|
||||
PythonBatteryLevel = "Batterijniveau teruggeven"
|
||||
PythonBatteryIscharging = "Keer terug als de batterij wordt opgeladen"
|
||||
PythonSetBrightness = "Set brightness level"
|
||||
PythonGetBrightness = "Get brightness level"
|
||||
PythonIsNaN = "Controleer of x geen getal is"
|
||||
PythonKandinskyFunction = "kandinsky module voorvoegsel"
|
||||
PythonLdexp = "Geeft x*(2**i), inversie van frexp"
|
||||
@@ -149,7 +151,7 @@ PythonScatter = "Teken scatterplot van y versus x"
|
||||
PythonSeed = "Start willek. getallengenerator"
|
||||
PythonSetPixel = "Kleur pixel (x,y)"
|
||||
PythonShow = "Figuur weergeven"
|
||||
PythonSin= "Sinus"
|
||||
PythonSin = "Sinus"
|
||||
PythonSinh = "Sinus hyperbolicus"
|
||||
PythonSleep = "Stel executie voor t seconden uit"
|
||||
PythonLocalTime = "Zet tijd om in tuple"
|
||||
|
||||
@@ -90,6 +90,8 @@ PythonIsKeyDown = "Devolve True se tecla k pressionada"
|
||||
PythonBattery = "Retornar a voltagem da bateria"
|
||||
PythonBatteryLevel = "Retornar nível de bateria"
|
||||
PythonBatteryIscharging = "Retorne se a bateria estiver carregando"
|
||||
PythonSetBrightness = "Definir nível de brilho"
|
||||
PythonGetBrightness = "Obter nível de brilho"
|
||||
PythonIsNaN = "Verificar se x é um NaN"
|
||||
PythonKandinskyFunction = "Prefixo da função do módulo kandinsky"
|
||||
PythonLdexp = "Devolve x*(2**i), inverso de frexp"
|
||||
|
||||
@@ -163,6 +163,8 @@ PythonCommandIsKeyDown = "keydown(k)"
|
||||
PythonCommandBattery = "battery()"
|
||||
PythonCommandBatteryLevel = "battery_level()"
|
||||
PythonCommandBatteryIscharging = "battery_ischarging()"
|
||||
PythonCommandSetBrightness = "set_brightness()"
|
||||
PythonCommandGetBrightness = "get_brightness()"
|
||||
PythonCommandLdexp = "ldexp(x,i)"
|
||||
PythonCommandLength = "len(object)"
|
||||
PythonCommandLgamma = "lgamma(x)"
|
||||
|
||||
@@ -376,6 +376,8 @@ const ToolboxMessageTree IonModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandBattery, I18n::Message::PythonBattery),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandBatteryLevel, I18n::Message::PythonBatteryLevel),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandBatteryIscharging, I18n::Message::PythonBatteryIscharging),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandSetBrightness, I18n::Message::PythonSetBrightness),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandGetBrightness, I18n::Message::PythonGetBrightness),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::IonSelector, I18n::Message::IonSelector)
|
||||
};
|
||||
|
||||
|
||||
@@ -346,6 +346,8 @@ Q(keydown)
|
||||
Q(battery)
|
||||
Q(battery_level)
|
||||
Q(battery_ischarging)
|
||||
Q(set_brightness)
|
||||
Q(get_brightness)
|
||||
Q(KEY_LEFT)
|
||||
Q(KEY_UP)
|
||||
Q(KEY_DOWN)
|
||||
|
||||
@@ -4,6 +4,8 @@ extern "C" {
|
||||
#include <py/runtime.h>
|
||||
}
|
||||
#include <ion.h>
|
||||
#include "apps/apps_container.h"
|
||||
#include "apps/global_preferences.h"
|
||||
#include "port.h"
|
||||
|
||||
mp_obj_t modion_keyboard_keydown(mp_obj_t key_o) {
|
||||
@@ -103,3 +105,17 @@ mp_obj_t modion_get_keys() {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
mp_obj_t modion_set_brightness(mp_obj_t brightness_mp){
|
||||
uint8_t brightness = static_cast<uint8_t>(mp_obj_get_int(brightness_mp));
|
||||
GlobalPreferences::sharedGlobalPreferences()->setBrightnessLevel(brightness);
|
||||
Ion::Backlight::setBrightness(brightness);
|
||||
micropython_port_interrupt_if_needed();
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t modion_get_brightness(){
|
||||
uint8_t brightness = GlobalPreferences::sharedGlobalPreferences()->brightnessLevel();
|
||||
micropython_port_interrupt_if_needed();
|
||||
return mp_obj_new_int((int)brightness);
|
||||
}
|
||||
|
||||
@@ -5,4 +5,6 @@ mp_obj_t modion_battery();
|
||||
mp_obj_t modion_battery_level();
|
||||
mp_obj_t modion_battery_ischarging();
|
||||
mp_obj_t modion_get_keys();
|
||||
mp_obj_t modion_set_brightness(mp_obj_t brightness_mp);
|
||||
mp_obj_t modion_get_brightness();
|
||||
extern const mp_obj_type_t file_type;
|
||||
|
||||
@@ -36,6 +36,16 @@ const mp_obj_fun_builtin_fixed_t modion_battery_ischarging_obj = {
|
||||
{(mp_fun_0_t)modion_battery_ischarging}
|
||||
};
|
||||
|
||||
const mp_obj_fun_builtin_fixed_t modion_set_brightness_obj = {
|
||||
{&mp_type_fun_builtin_1},
|
||||
{(mp_fun_0_t)modion_set_brightness}
|
||||
};
|
||||
|
||||
const mp_obj_fun_builtin_fixed_t modion_get_brightness_obj = {
|
||||
{&mp_type_fun_builtin_0},
|
||||
{(mp_fun_0_t)modion_get_brightness}
|
||||
};
|
||||
|
||||
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) },
|
||||
@@ -43,6 +53,8 @@ extern "C" const mp_rom_map_elem_t modion_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_battery_ischarging), MP_ROM_PTR(&modion_battery_ischarging_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_keydown), MP_ROM_PTR(&modion_keyboard_keydown_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_get_keys), MP_ROM_PTR(&modion_get_keys_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_brightness), MP_ROM_PTR(&modion_set_brightness_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_get_brightness), MP_ROM_PTR(&modion_get_brightness_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) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_KEY_DOWN), MP_OBJ_NEW_SMALL_INT(Ion::Keyboard::Key::Down) },
|
||||
|
||||
Reference in New Issue
Block a user