Temporary fix to wrong response format
[apps/native/gear-racing-car.git] / src / resource / resource_led.c
index 1de1ea1..1640343 100644 (file)
@@ -67,6 +67,7 @@ typedef struct _led_s {
        int use_bi_led;
        int use_rgb_gpio;
        int use_rgb_l2c;
+       bool is_in_blink_mode;
 } led_s;
 
 static led_s s_info = {
@@ -118,6 +119,10 @@ static inline void _led_bi_set(bi_led_color_e color, bool store_current_color)
                        break;
        }
 
+       if(s_info.is_in_blink_mode) {
+               return;
+       }
+
        int ret = peripheral_gpio_write(s_info.gpio_bi_led[LED_COLOR_RED], red);
        ret_error_message(ret != PERIPHERAL_ERROR_NONE, ret);
 
@@ -148,6 +153,10 @@ static inline void _rgb_gpio_set(bool red, bool green, bool blue, bool store_cur
        }
        _D("RGB GPIO: [%d, %d, %d]", red, green, blue);
 
+       if(s_info.is_in_blink_mode) {
+               return;
+       }
+
        int ret = peripheral_gpio_write(s_info.rgb_gpio[0], red);
        ret_error_message(ret != PERIPHERAL_ERROR_NONE, ret);
 
@@ -179,6 +188,10 @@ static inline void _rgb_l2c_set(int red, int green, int blue, bool store_current
                s_info.current_rgb_l2c_color[2] = blue;
        }
 
+       if(s_info.is_in_blink_mode) {
+               return;
+       }
+
        int ret = resource_pca9685_set_value_to_channel(DEFAULT_RGB_L2C_R, 0, RGB_TO_REGISTER(red));
        ret_error_message(ret != PERIPHERAL_ERROR_NONE, ret);
 
@@ -215,7 +228,7 @@ static gboolean _restore_rgb_l2c_color_cb(gpointer data)
 static gboolean _restore_rgb_color_cb(gpointer data)
 {
        FUNCTION_START;
-
+       s_info.is_in_blink_mode = false;
        _restore_bi_color_cb(data);
        _restore_rgb_gpio_color_cb(data);
        _restore_rgb_l2c_color_cb(data);
@@ -388,6 +401,7 @@ void resource_led_blink_rgb_colors(char *key,
        FUNCTION_START;
 
        _set_rgb(key, false, def_r_3bit, def_g_3bit, def_b_3bit, def_r_24bit, def_g_24bit, def_b_24bit, bi_led);
+       s_info.is_in_blink_mode = true;
        g_timeout_add(timeout, _restore_rgb_color_cb, NULL);