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

review fix of get rgb leds state

parent 6dfda96c
No related tags found
No related merge requests found
...@@ -586,12 +586,14 @@ API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b)); ...@@ -586,12 +586,14 @@ API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b));
/** /**
* Get one of card10's RGB LEDs in format of RGB. * Get one of card10's RGB LEDs in format of RGB.
* *
* :c:func:`epic_leds_get_rgb` will get the value of a RGB LED described by ``led``.
*
* :param int led: Which LED to set. 0-10 are the LEDs on the top and 11-14 * :param int led: Which LED to set. 0-10 are the LEDs on the top and 11-14
* are the 4 "ambient" LEDs. * are the 4 "ambient" LEDs.
* :param uint8_t * rgb: need tree byte array to get the value of red, green and blue. * :param uint8_t * rgb: need tree byte array to get the value of red, green and blue.
* :return bool: if true the reading of value was not blocked by personal state * :returns: ``0`` on success or ``-EPERM`` if the LED is blocked by personal-state.
*/ */
API(API_LEDS_GET, bool epic_leds_get_rgb(int led, uint8_t * rgb)); API(API_LEDS_GET, int epic_leds_get_rgb(int led, uint8_t * rgb));
/** /**
* Set one of card10's RGB LEDs to a certain color in HSV format. * Set one of card10's RGB LEDs to a certain color in HSV format.
......
...@@ -49,13 +49,13 @@ void epic_leds_prep(int led, uint8_t r, uint8_t g, uint8_t b) ...@@ -49,13 +49,13 @@ void epic_leds_prep(int led, uint8_t r, uint8_t g, uint8_t b)
leds_prep(led, r, g, b); leds_prep(led, r, g, b);
} }
bool epic_leds_get_rgb(int led, uint8_t *rgb) int epic_leds_get_rgb(int led, uint8_t *rgb)
{ {
if (led == PERSONAL_STATE_LED && personal_state_enabled()) if (led == PERSONAL_STATE_LED && personal_state_enabled())
return false; return -EPERM;
leds_get_rgb(led, rgb); leds_get_rgb(led, rgb);
return true; return 0;
} }
void epic_leds_prep_hsv(int led, float h, float s, float v) void epic_leds_prep_hsv(int led, float h, float s, float v)
......
...@@ -78,7 +78,7 @@ static mp_obj_t mp_leds_prep(mp_obj_t led_in, mp_obj_t color_in) ...@@ -78,7 +78,7 @@ static mp_obj_t mp_leds_prep(mp_obj_t led_in, mp_obj_t color_in)
} }
static MP_DEFINE_CONST_FUN_OBJ_2(leds_prep_obj, mp_leds_prep); static MP_DEFINE_CONST_FUN_OBJ_2(leds_prep_obj, mp_leds_prep);
static mp_obj_t mp_leds_get_rgb(mp_obj_t led_in, mp_obj_t color_out) static mp_obj_t mp_leds_get_rgb(mp_obj_t led_in)
{ {
int led = mp_obj_get_int(led_in); int led = mp_obj_get_int(led_in);
uint8_t rgb[] = { 0, 0, 0 }; uint8_t rgb[] = { 0, 0, 0 };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment