From 17dc574f70bafd3c8b09eb5d459bc043304ff092 Mon Sep 17 00:00:00 2001 From: Martin/Geno <geno+dev@fireorbit.de> Date: Tue, 27 Aug 2019 12:03:19 +0200 Subject: [PATCH] review fix of get rgb leds state --- epicardium/epicardium.h | 6 ++++-- epicardium/modules/leds.c | 6 +++--- pycardium/modules/sys_leds.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index 2a57adbf..5c066ada 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -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. * + * :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 * are the 4 "ambient" LEDs. * :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. diff --git a/epicardium/modules/leds.c b/epicardium/modules/leds.c index 27702835..3a394559 100644 --- a/epicardium/modules/leds.c +++ b/epicardium/modules/leds.c @@ -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); } -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()) - return false; + return -EPERM; leds_get_rgb(led, rgb); - return true; + return 0; } void epic_leds_prep_hsv(int led, float h, float s, float v) diff --git a/pycardium/modules/sys_leds.c b/pycardium/modules/sys_leds.c index 86012f25..1df647ca 100644 --- a/pycardium/modules/sys_leds.c +++ b/pycardium/modules/sys_leds.c @@ -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_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); uint8_t rgb[] = { 0, 0, 0 }; -- GitLab