Changed the way that the led colors are stored in the config file
[apps/native/gear-racing-car.git] / src / resource / resource_led.c
index 71bd003..df11e7c 100644 (file)
@@ -139,6 +139,7 @@ static inline void _rgb_gpio_set(bool red, bool green, bool blue)
 
 static inline void _rgb_l2c_set(int red, int green, int blue)
 {
+       FUNCTION_START;
        if (!s_info.use_rgb_l2c) {
                _D("l2c rgb led is turned OFF");
                return;
@@ -154,6 +155,7 @@ static inline void _rgb_l2c_set(int red, int green, int blue)
        ret_error_message(ret != PERIPHERAL_ERROR_NONE, ret);
 
        _D("RGB L2C: [%d, %d, %d] -> [%d, %d, %d]", red, green, blue, RGB_TO_REGISTER(red), RGB_TO_REGISTER(green), RGB_TO_REGISTER(blue));
+       FUNCTION_END;
 }
 
 static gboolean _restore_bi_color_cb(gpointer data)
@@ -170,16 +172,22 @@ static gboolean _restore_rgb_gpio_color_cb(gpointer data)
 
 static gboolean _restore_rgb_l2c_color_cb(gpointer data)
 {
+       FUNCTION_START;
        _rgb_l2c_set(s_info.current_rgb_l2c_color[0], s_info.current_rgb_l2c_color[1], s_info.current_rgb_l2c_color[2]);
+       FUNCTION_END;
        return false;
 }
 
 static gboolean _restore_rgb_color_cb(gpointer data)
 {
+       FUNCTION_START;
+
        _restore_bi_color_cb(data);
        _restore_rgb_gpio_color_cb(data);
        _restore_rgb_l2c_color_cb(data);
 
+       FUNCTION_END;
+
        return false;
 }
 
@@ -213,6 +221,9 @@ static void _init_bi_led(void)
                config_save();
        }
 
+       _D("Use bi_led: %d", s_info.use_bi_led);
+
+
        if (s_info.use_bi_led) {
                s_info.gpio_bi_led[LED_COLOR_RED] = _init_gpio(DEFAULT_BI_LED_RED, CONFIG_KEY_RPI_BI_LED_RED);
                s_info.gpio_bi_led[LED_COLOR_GREEN] = _init_gpio(DEFAULT_BI_LED_GREEN, CONFIG_KEY_RPI_BI_LED_GREEN);
@@ -228,6 +239,8 @@ static void _init_rgb_gpio_led(void)
                config_save();
        }
 
+       _D("Use rgb_gpio_led: %d", s_info.use_rgb_gpio);
+
        if (!s_info.use_rgb_gpio) {
                _D("RGB GPIO is turned off");
                return;
@@ -257,6 +270,8 @@ static void _init_rgb_l2c_led(void)
                config_save();
        }
 
+       _D("Use rgb_l2c_led: %d", s_info.use_rgb_l2c);
+
        if (!s_info.use_rgb_l2c) {
                _D("RGB L2C is turned off");
                return;
@@ -269,10 +284,12 @@ static void _init_rgb_l2c_led(void)
 
 void resource_led_init(void)
 {
+       FUNCTION_START;
        _D("Initialize Led");
        _init_rgb_gpio_led();
        _init_bi_led();
        _init_rgb_l2c_led();
+       FUNCTION_END;
 }
 
 void resource_led_destroy(void)
@@ -295,6 +312,7 @@ void resource_led_bi_set(bi_led_color_e color)
 {
        _D("Set led to: %d", color);
        if (color == s_info.current_color) {
+               _D("No change in bi led");
                return;
        }
 
@@ -305,6 +323,7 @@ void resource_led_bi_set(bi_led_color_e color)
 void resource_led_bi_blink(bi_led_color_e color, unsigned timeout)
 {
        if (color == s_info.current_color) {
+               _D("No change in bi led");
                return;
        }
 
@@ -317,6 +336,7 @@ void resource_led_rgb_gpio_set(bool red, bool green, bool blue)
        if (red == s_info.current_rgb_gpio_color[0] &&
                        green == s_info.current_rgb_gpio_color[1] &&
                        blue == s_info.current_rgb_gpio_color[2]) {
+               _D("No change in gpio led");
                return;
        }
 
@@ -333,6 +353,7 @@ void resource_led_gpio_rgb_blink(bool red, bool green, bool blue, unsigned timeo
        if (red == s_info.current_rgb_gpio_color[0] &&
                        green == s_info.current_rgb_gpio_color[1] &&
                        blue == s_info.current_rgb_gpio_color[2]) {
+               _D("No change in gpio led");
                return;
        }
 
@@ -345,6 +366,7 @@ void resource_led_rgb_l2c_set(int red, int green, int blue)
        if (red == s_info.current_rgb_l2c_color[0] &&
                        green == s_info.current_rgb_l2c_color[1] &&
                        blue == s_info.current_rgb_l2c_color[2]) {
+               _D("No change in l2c led");
                return;
        }
 
@@ -360,6 +382,7 @@ void resource_led_rgb_l2c_blink(int red, int green, int blue, unsigned timeout)
        if (red == s_info.current_rgb_l2c_color[0] &&
                        green == s_info.current_rgb_l2c_color[1] &&
                        blue == s_info.current_rgb_l2c_color[2]) {
+               _D("No change in l2c led");
                return;
        }
 
@@ -372,6 +395,8 @@ void resource_led_set_rgb_colors(char *key,
                int def_r_24bit, int def_g_24bit, int def_b_24bit,
                bi_led_color_e bi_led)
 {
+       FUNCTION_START;
+
        int red, green, blue;
        char final_key[PATH_MAX];
 
@@ -395,7 +420,10 @@ void resource_led_set_rgb_colors(char *key,
        if (modified) {
                config_save();
        }
+
        _D("%s: bicolor: [%d]", final_key, value);
+
+       FUNCTION_END;
 }
 
 void resource_led_blink_rgb_colors(char *key,
@@ -403,7 +431,12 @@ void resource_led_blink_rgb_colors(char *key,
                int def_r_24bit, int def_g_24bit, int def_b_24bit,
                bi_led_color_e bi_led, int timeout)
 {
+       FUNCTION_START;
+
        resource_led_set_rgb_colors(key, def_r_3bit, def_g_3bit, def_b_3bit, def_r_24bit, def_g_24bit, def_b_24bit, bi_led);
 
        g_timeout_add(timeout, _restore_rgb_color_cb, NULL);
+
+
+       FUNCTION_END;
 }