Skip to content
Snippets Groups Projects
Verified Commit 4318fa5c authored by genofire's avatar genofire
Browse files

py: get rocket state

parent 0f600f98
Branches
Tags
No related merge requests found
......@@ -72,6 +72,26 @@ def set_rocket(led, value):
sys_leds.set_rocket(led, value)
def get_rocket(led):
"""
Get brightness of one of the rocket LEDs.
:param int led: Choose your rocket!
+-------+--------+----------+
| ID | Color | Location |
+=======+========+==========+
| ``0`` | Blue | Left |
+-------+--------+----------+
| ``1`` | Yellow | Top |
+-------+--------+----------+
| ``2`` | Green | Right |
+-------+--------+----------+
:return int: Brightness of LED (value between 0 and 31).
"""
return sys_leds.get_rocket(led)
def dim_top(value):
"""
Set global brightness for top RGB LEDs.
......
......@@ -15,6 +15,7 @@ Q(set_all)
Q(set_all_hsv)
Q(set_flashlight)
Q(set_rocket)
Q(get_rocket)
Q(set_powersave)
Q(set_gamma)
Q(dim_top)
......
......@@ -6,7 +6,6 @@
#include <stdio.h>
static mp_obj_t mp_leds_set(mp_obj_t led_in, mp_obj_t color_in)
{
int led = mp_obj_get_int(led_in);
......@@ -174,6 +173,14 @@ static mp_obj_t mp_leds_set_rocket(mp_obj_t led_in, mp_obj_t value_in)
}
static MP_DEFINE_CONST_FUN_OBJ_2(leds_set_rocket_obj, mp_leds_set_rocket);
static mp_obj_t mp_leds_get_rocket(mp_obj_t led_in)
{
int led = mp_obj_get_int(led_in);
uint8_t ret = epic_leds_get_rocket(led);
return MP_OBJ_NEW_SMALL_INT(ret);
}
static MP_DEFINE_CONST_FUN_OBJ_1(leds_get_rocket_obj, mp_leds_get_rocket);
static mp_obj_t mp_leds_dim_top(mp_obj_t dim_in)
{
int dim = mp_obj_get_int(dim_in);
......@@ -242,6 +249,7 @@ static const mp_rom_map_elem_t leds_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_set_all), MP_ROM_PTR(&leds_set_all_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_all_hsv), MP_ROM_PTR(&leds_set_all_hsv_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_rocket), MP_ROM_PTR(&leds_set_rocket_obj) },
{ MP_ROM_QSTR(MP_QSTR_get_rocket), MP_ROM_PTR(&leds_get_rocket_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_flashlight),
MP_ROM_PTR(&leds_set_flashlight_obj) },
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&leds_update_obj) },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment