int default_r, int default_g, int default_b,
int *red, int *green, int *blue)
{
- bool modified = false;
- int color;
+ GError *error;
+ gsize length;
- if (config_get_int(group, key, &color) != 0) {
+ gint *list = g_key_file_get_integer_list(gk, group, key, &length, &error);
- color = (default_r & 0xFF) << 16;
- color += (default_g & 0xFF) << 8;
- color += (default_b & 0xFF) << 0;
+ if (length <= 0) {
+ gint list[3] = { default_r, default_g, default_b};
+ g_key_file_set_integer_list (gk, group, key, list, 3);
- config_set_int(group, key, color);
+ *red = default_r;
+ *green = default_g;
+ *blue = default_b;
- modified = true;
+ return true;
}
- *red = (color >> 16) & 0xFF;
- *green = (color >> 8) & 0xFF;
- *blue = (color >> 0) & 0xFF;
+ *red = list[0];
+ *green = list[1];
+ *blue = list[2];
- return modified;
+ return false;
}
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;
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)
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;
}
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);
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;
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;
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)
{
_D("Set led to: %d", color);
if (color == s_info.current_color) {
+ _D("No change in bi led");
return;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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];
if (modified) {
config_save();
}
+
_D("%s: bicolor: [%d]", final_key, value);
+
+ FUNCTION_END;
}
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;
}