From 226c24371df3146bc1bd69fdc3bf00d5217b7ef5 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 30 Nov 2020 16:36:33 +0900 Subject: [PATCH] default_backend: remove duplicate code Change-Id: I10b92711133660c200e01b30c303b5f25a3e8ad2 Signed-off-by: Sung-Jin Park --- backends/bt/default_ani_connected.c | 52 ++----------------- backends/bt/default_ani_pairing.c | 52 ++----------------- backends/default/default_ani_clear_fadeout.c | 53 ++------------------ backends/default/default_ani_clear_immediate.c | 51 ++----------------- backends/default_backend.c | 64 ++++++++++++++++++++++++ backends/default_backend.h | 3 ++ backends/notification/default_ani_alarm.c | 56 ++------------------- backends/notification/default_ani_emergency.c | 56 ++------------------- backends/notification/default_ani_error.c | 52 ++----------------- backends/notification/default_ani_networkerror.c | 52 ++----------------- backends/notification/default_ani_normal.c | 56 ++------------------- backends/system/default_ani_easysetup.c | 56 ++------------------- backends/system/default_ani_micoff.c | 52 ++----------------- backends/system/default_ani_swupdatedone.c | 56 ++------------------- backends/system/default_ani_system_processing.c | 52 ++----------------- backends/voice/default_ani_listening.c | 52 ++----------------- backends/voice/default_ani_processing.c | 52 ++----------------- backends/voice/default_ani_speaking.c | 56 ++------------------- backends/voice/default_ani_streaming.c | 56 ++------------------- backends/voice/default_ani_timeout.c | 56 ++------------------- 20 files changed, 138 insertions(+), 897 deletions(-) diff --git a/backends/bt/default_ani_connected.c b/backends/bt/default_ani_connected.c index dbe27d1..b8893fb 100644 --- a/backends/bt/default_ani_connected.c +++ b/backends/bt/default_ani_connected.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_connected_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_connected_get_frame(default_ani_info *ani_info) { @@ -73,12 +61,11 @@ _ani_backend_connected_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_connected_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -93,42 +80,9 @@ _ani_backend_connected_frame_cb(void *data, int serial) } frame = _ani_backend_connected_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_connected_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/bt/default_ani_pairing.c b/backends/bt/default_ani_pairing.c index 08306c0..82e95e4 100644 --- a/backends/bt/default_ani_pairing.c +++ b/backends/bt/default_ani_pairing.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_pairing_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_pairing_get_frame(default_ani_info *ani_info) { @@ -74,12 +62,11 @@ _ani_backend_pairing_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_pairing_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -94,42 +81,9 @@ _ani_backend_pairing_frame_cb(void *data, int serial) } frame = _ani_backend_pairing_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_pairing_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/default/default_ani_clear_fadeout.c b/backends/default/default_ani_clear_fadeout.c index 39a6d7d..9ba9819 100644 --- a/backends/default/default_ani_clear_fadeout.c +++ b/backends/default/default_ani_clear_fadeout.c @@ -24,17 +24,6 @@ */ #include "../default_backend.h" -static void -_ani_backend_clear_fadeout_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} static default_frame_info_t *ani_frame = NULL; @@ -56,7 +45,7 @@ _ani_clear_fadeout_get_frame(default_ani_info *ani_info) r = g = b = r2 = g2 = b2 = 0x0; for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_clear_fadeout_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); r2 = r - (int)(r * div); g2 = g - (int)(g * div); b2 = b - (int)(b * div); @@ -77,12 +66,11 @@ _ani_clear_fadeout_get_frame(default_ani_info *ani_info) static pui_bool _ani_clear_fadeout_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -97,42 +85,9 @@ _ani_clear_fadeout_frame_cb(void *data, int serial) } frame = _ani_clear_fadeout_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_clear_fadeout_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } - - return (pui_bool)1; + return (pui_bool)ret; } pui_bool diff --git a/backends/default/default_ani_clear_immediate.c b/backends/default/default_ani_clear_immediate.c index 5a2b0be..6ba3c9c 100644 --- a/backends/default/default_ani_clear_immediate.c +++ b/backends/default/default_ani_clear_immediate.c @@ -24,17 +24,6 @@ */ #include "../default_backend.h" -static void -_ani_backend_clear_immediate_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} static default_frame_info_t *ani_frame = NULL; @@ -54,12 +43,11 @@ _ani_clear_immediate_get_frame(default_ani_info *ani_info) static pui_bool _ani_clear_immediate_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -74,42 +62,9 @@ _ani_clear_immediate_frame_cb(void *data, int serial) } frame = _ani_clear_immediate_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_clear_immediate_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/default_backend.c b/backends/default_backend.c index 789e0f9..ef6b4e5 100644 --- a/backends/default_backend.c +++ b/backends/default_backend.c @@ -705,6 +705,70 @@ backend_util_free_frame(default_frame_info_t *frame) free(frame); } +void +pui_default_backend_ani_get_led_rgb(default_frame_info_t *frame, + int led_idx, + unsigned int *r, + unsigned int *g, + unsigned int *b) +{ + if (!frame) return; + if (!r || !g || !b) return; + if (led_idx > frame->num_led) return; + + *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; + *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; + *b = (frame->leds[led_idx].color & LED_MASK_BLUE); +} + +int +pui_default_backend_ani_update_frame(pui_ani_t *ani, + pui_backend_ani_data *ani_data, + pui_ani_control_buffer *buffer, + default_frame_info_t *frame, + int serial) +{ + pui_int_error e = PUI_INT_ERROR_NONE; + default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; + unsigned int r = 0x0, g = 0x0, b = 0x0; + + for(int i = 0; i<12; i++) + { + pui_default_backend_ani_get_led_rgb(frame, i, &r, &g, &b); + buffer->ptr[4*i] = 0; + buffer->ptr[4*i + 1] = b; /* BLUE */ + buffer->ptr[4*i + 2] = g; /* GREEN */ + buffer->ptr[4*i + 3] = r; /* RED */ + } + backend_util_cleanup_frame(frame); + + e = pui_backend_ani_set_buffer(ani, buffer); + + if (e != PUI_INT_ERROR_NONE) + { + pui_err("Failed on setting buffer on animation !(e=%d)\n", e); + return 0; + } + + e = pui_backend_ani_update(ani); + + if (e != PUI_INT_ERROR_NONE) + { + pui_err("Failed on updating animation !(e=%d)\n", e); + return 0; + } + + pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", + serial, ani_info->repeat_cur, ani_info->repeat); + + if (ani_info->repeat >= 0 && + ani_info->repeat_cur >= ani_info->repeat) + { + ani_data->ani_func->ani_stop(ani, EINA_FALSE); + } + + return 1; +} static pui_backend_module_data * pui_default_backend_init(void) diff --git a/backends/default_backend.h b/backends/default_backend.h index 3755b3d..446875c 100644 --- a/backends/default_backend.h +++ b/backends/default_backend.h @@ -125,3 +125,6 @@ void pui_default_backend_ani_connected_func_set(pui_backend_ani_func *func); void pui_default_backend_ani_pairing_func_set(pui_backend_ani_func *func); void pui_default_backend_ani_clear_fadeout_func_set(pui_backend_ani_func *func); void pui_default_backend_ani_clear_immediate_func_set(pui_backend_ani_func *func); + +void pui_default_backend_ani_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b); +int pui_default_backend_ani_update_frame(pui_ani_t *ani, pui_backend_ani_data *ani_data, pui_ani_control_buffer *buffer, default_frame_info_t *frame, int serial); \ No newline at end of file diff --git a/backends/notification/default_ani_alarm.c b/backends/notification/default_ani_alarm.c index c915d75..880700c 100644 --- a/backends/notification/default_ani_alarm.c +++ b/backends/notification/default_ani_alarm.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_alarm_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_alarm_get_frame(default_ani_info *ani_info) { @@ -73,8 +61,8 @@ _ani_backend_alarm_get_frame(default_ani_info *ani_info) r = g = b = r2 = g2 = b2 = 0x0; for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_alarm_get_led_rgb(key_frame, i, &r, &g, &b); - _ani_backend_alarm_get_led_rgb(key_frame2, i, &r2, &g2, &b2); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame2, i, &r2, &g2, &b2); r3 = (int)(r2 - r) * div + r; g3 = (int)(g2 - g) * div + g; b3 = (int)(b2 - b) * div + b; @@ -98,12 +86,11 @@ _ani_backend_alarm_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_alarm_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -118,42 +105,9 @@ _ani_backend_alarm_frame_cb(void *data, int serial) } frame = _ani_backend_alarm_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_alarm_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/notification/default_ani_emergency.c b/backends/notification/default_ani_emergency.c index 889d465..a1d6056 100644 --- a/backends/notification/default_ani_emergency.c +++ b/backends/notification/default_ani_emergency.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_emergency_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_emergency_get_frame(default_ani_info *ani_info) { @@ -63,8 +51,8 @@ _ani_backend_emergency_get_frame(default_ani_info *ani_info) r = g = b = r2 = g2 = b2 = 0x0; for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_emergency_get_led_rgb(key_frame, i, &r, &g, &b); - _ani_backend_emergency_get_led_rgb(key_frame2, i, &r2, &g2, &b2); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame2, i, &r2, &g2, &b2); r3 = (int)(r2 - r) * div + r; g3 = (int)(g2 - g) * div + g; b3 = (int)(b2 - b) * div + b; @@ -88,12 +76,11 @@ _ani_backend_emergency_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_emergency_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -108,42 +95,9 @@ _ani_backend_emergency_frame_cb(void *data, int serial) } frame = _ani_backend_emergency_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_emergency_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/notification/default_ani_error.c b/backends/notification/default_ani_error.c index 2520af8..5b49118 100644 --- a/backends/notification/default_ani_error.c +++ b/backends/notification/default_ani_error.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_error_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_error_get_frame(default_ani_info *ani_info) { @@ -78,12 +66,11 @@ _ani_backend_error_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_error_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -98,42 +85,9 @@ _ani_backend_error_frame_cb(void *data, int serial) } frame = _ani_backend_error_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_error_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/notification/default_ani_networkerror.c b/backends/notification/default_ani_networkerror.c index 7824398..96f6cc8 100644 --- a/backends/notification/default_ani_networkerror.c +++ b/backends/notification/default_ani_networkerror.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_networkerror_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_networkerror_get_frame(default_ani_info *ani_info) { @@ -74,12 +62,11 @@ _ani_backend_networkerror_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_networkerror_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -94,42 +81,9 @@ _ani_backend_networkerror_frame_cb(void *data, int serial) } frame = _ani_backend_networkerror_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_networkerror_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/notification/default_ani_normal.c b/backends/notification/default_ani_normal.c index b0a72fa..82eee8c 100644 --- a/backends/notification/default_ani_normal.c +++ b/backends/notification/default_ani_normal.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_normal_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_normal_get_frame(default_ani_info *ani_info) { @@ -63,8 +51,8 @@ _ani_backend_normal_get_frame(default_ani_info *ani_info) r = g = b = r2 = g2 = b2 = 0x0; for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_normal_get_led_rgb(key_frame, i, &r, &g, &b); - _ani_backend_normal_get_led_rgb(key_frame2, i, &r2, &g2, &b2); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame2, i, &r2, &g2, &b2); r3 = (int)(r2 - r) * div + r; g3 = (int)(g2 - g) * div + g; b3 = (int)(b2 - b) * div + b; @@ -87,12 +75,11 @@ _ani_backend_normal_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_normal_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -107,42 +94,9 @@ _ani_backend_normal_frame_cb(void *data, int serial) } frame = _ani_backend_normal_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_normal_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/system/default_ani_easysetup.c b/backends/system/default_ani_easysetup.c index cad2d53..117198a 100644 --- a/backends/system/default_ani_easysetup.c +++ b/backends/system/default_ani_easysetup.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_easysetup_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_easysetup_get_frame(default_ani_info *ani_info) { @@ -63,8 +51,8 @@ _ani_backend_easysetup_get_frame(default_ani_info *ani_info) r = g = b = r2 = g2 = b2 = 0x0; for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_easysetup_get_led_rgb(key_frame, i, &r, &g, &b); - _ani_backend_easysetup_get_led_rgb(key_frame2, i, &r2, &g2, &b2); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame2, i, &r2, &g2, &b2); r3 = (int)(r2 - r) * div + r; g3 = (int)(g2 - g) * div + g; b3 = (int)(b2 - b) * div + b; @@ -86,12 +74,11 @@ _ani_backend_easysetup_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_easysetup_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -106,42 +93,9 @@ _ani_backend_easysetup_frame_cb(void *data, int serial) } frame = _ani_backend_easysetup_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_easysetup_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/system/default_ani_micoff.c b/backends/system/default_ani_micoff.c index 4c991c2..e2934be 100644 --- a/backends/system/default_ani_micoff.c +++ b/backends/system/default_ani_micoff.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_micoff_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_micoff_get_frame(default_ani_info *ani_info) { @@ -61,12 +49,11 @@ _ani_backend_micoff_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_micoff_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -81,42 +68,9 @@ _ani_backend_micoff_frame_cb(void *data, int serial) } frame = _ani_backend_micoff_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_micoff_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/system/default_ani_swupdatedone.c b/backends/system/default_ani_swupdatedone.c index 17a024d..68a2320 100644 --- a/backends/system/default_ani_swupdatedone.c +++ b/backends/system/default_ani_swupdatedone.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_swupdatedone_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_swupdatedone_get_frame(default_ani_info *ani_info) { @@ -64,8 +52,8 @@ _ani_backend_swupdatedone_get_frame(default_ani_info *ani_info) for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_swupdatedone_get_led_rgb(key_frame, i, &r, &g, &b); - _ani_backend_swupdatedone_get_led_rgb(key_frame2, i, &r2, &g2, &b2); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame2, i, &r2, &g2, &b2); r3 = (int)(r2 - r) * div + r; g3 = (int)(g2 - g) * div + g; b3 = (int)(b2 - b) * div + b; @@ -88,12 +76,11 @@ _ani_backend_swupdatedone_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_swupdatedone_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -108,42 +95,9 @@ _ani_backend_swupdatedone_frame_cb(void *data, int serial) } frame = _ani_backend_swupdatedone_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_swupdatedone_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/system/default_ani_system_processing.c b/backends/system/default_ani_system_processing.c index 713a90a..704c01c 100644 --- a/backends/system/default_ani_system_processing.c +++ b/backends/system/default_ani_system_processing.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_system_processing_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_system_processing_get_frame(default_ani_info *ani_info) { @@ -65,12 +53,11 @@ _ani_backend_system_processing_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_system_processing_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -85,42 +72,9 @@ _ani_backend_system_processing_frame_cb(void *data, int serial) } frame = _ani_backend_system_processing_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_system_processing_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/voice/default_ani_listening.c b/backends/voice/default_ani_listening.c index cc86e1a..5258242 100644 --- a/backends/voice/default_ani_listening.c +++ b/backends/voice/default_ani_listening.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_listening_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_listening_get_frame(default_ani_info *ani_info) { @@ -94,12 +82,11 @@ _ani_backend_listening_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_listening_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -114,42 +101,9 @@ _ani_backend_listening_frame_cb(void *data, int serial) } frame = _ani_backend_listening_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_listening_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/voice/default_ani_processing.c b/backends/voice/default_ani_processing.c index c0b3a06..bd05672 100644 --- a/backends/voice/default_ani_processing.c +++ b/backends/voice/default_ani_processing.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_processing_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_processing_get_frame(default_ani_info *ani_info) { @@ -65,12 +53,11 @@ _ani_backend_processing_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_processing_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -85,42 +72,9 @@ _ani_backend_processing_frame_cb(void *data, int serial) } frame = _ani_backend_processing_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_processing_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/voice/default_ani_speaking.c b/backends/voice/default_ani_speaking.c index 43a2a11..51e160d 100644 --- a/backends/voice/default_ani_speaking.c +++ b/backends/voice/default_ani_speaking.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_speaking_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_speaking_get_frame(default_ani_info *ani_info) { @@ -63,8 +51,8 @@ _ani_backend_speaking_get_frame(default_ani_info *ani_info) r = g = b = r2 = g2 = b2 = 0x0; for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_speaking_get_led_rgb(key_frame, i, &r, &g, &b); - _ani_backend_speaking_get_led_rgb(key_frame2, i, &r2, &g2, &b2); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame2, i, &r2, &g2, &b2); r3 = (int)(r2 - r) * div + r; g3 = (int)(g2 - g) * div + g; b3 = (int)(b2 - b) * div + b; @@ -87,12 +75,11 @@ _ani_backend_speaking_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_speaking_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -107,42 +94,9 @@ _ani_backend_speaking_frame_cb(void *data, int serial) } frame = _ani_backend_speaking_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_speaking_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/voice/default_ani_streaming.c b/backends/voice/default_ani_streaming.c index 39da2a4..d603fe8 100644 --- a/backends/voice/default_ani_streaming.c +++ b/backends/voice/default_ani_streaming.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_streaming_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_streaming_get_frame(default_ani_info *ani_info) { @@ -63,8 +51,8 @@ _ani_backend_streaming_get_frame(default_ani_info *ani_info) r = g = b = r2 = g2 = b2 = 0x0; for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_streaming_get_led_rgb(key_frame, i, &r, &g, &b); - _ani_backend_streaming_get_led_rgb(key_frame2, i, &r2, &g2, &b2); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame2, i, &r2, &g2, &b2); r3 = (int)(r2 - r) * div + r; g3 = (int)(g2 - g) * div + g; b3 = (int)(b2 - b) * div + b; @@ -86,12 +74,11 @@ _ani_backend_streaming_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_streaming_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -106,42 +93,9 @@ _ani_backend_streaming_frame_cb(void *data, int serial) } frame = _ani_backend_streaming_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_streaming_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error diff --git a/backends/voice/default_ani_timeout.c b/backends/voice/default_ani_timeout.c index 4862ac5..33ba1fd 100644 --- a/backends/voice/default_ani_timeout.c +++ b/backends/voice/default_ani_timeout.c @@ -27,18 +27,6 @@ static default_frame_info_t *ani_frame = NULL; -static void -_ani_backend_timeout_get_led_rgb(default_frame_info_t *frame, int led_idx, unsigned int *r, unsigned int *g, unsigned int *b) -{ - if (!frame) return; - if (!r || !g || !b) return; - if (led_idx > frame->num_led) return; - - *r = (frame->leds[led_idx].color & LED_MASK_RED) >> 16; - *g = (frame->leds[led_idx].color & LED_MASK_GREEN) >> 8; - *b = (frame->leds[led_idx].color & LED_MASK_BLUE); -} - static default_frame_info_t * _ani_backend_timeout_get_frame(default_ani_info *ani_info) { @@ -63,8 +51,8 @@ _ani_backend_timeout_get_frame(default_ani_info *ani_info) r = g = b = r2 = g2 = b2 = 0x0; for (int i = 0; i < key_frame->num_led; i++) { - _ani_backend_timeout_get_led_rgb(key_frame, i, &r, &g, &b); - _ani_backend_timeout_get_led_rgb(key_frame2, i, &r2, &g2, &b2); + pui_default_backend_ani_get_led_rgb(key_frame, i, &r, &g, &b); + pui_default_backend_ani_get_led_rgb(key_frame2, i, &r2, &g2, &b2); r3 = (int)(r2 - r) * div + r; g3 = (int)(g2 - g) * div + g; b3 = (int)(b2 - b) * div + b; @@ -86,12 +74,11 @@ _ani_backend_timeout_get_frame(default_ani_info *ani_info) static pui_bool _ani_backend_timeout_frame_cb(void *data, int serial) { - pui_int_error e = PUI_INT_ERROR_NONE; + int ret = 0; pui_ani_t *ani = (pui_ani_t *)data; pui_backend_ani_data *ani_data = NULL; pui_ani_control_buffer *buffer = NULL; default_frame_info_t *frame; - unsigned int r = 0x0, g = 0x0, b = 0x0; ani_data = pui_backend_ani_get_ani_data(ani); default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info; @@ -106,42 +93,9 @@ _ani_backend_timeout_frame_cb(void *data, int serial) } frame = _ani_backend_timeout_get_frame(ani_info); - for(int i = 0; i<12; i++) - { - _ani_backend_timeout_get_led_rgb(frame, i, &r, &g, &b); - buffer->ptr[4*i] = 0; - buffer->ptr[4*i + 1] = b; /* BLUE */ - buffer->ptr[4*i + 2] = g; /* GREEN */ - buffer->ptr[4*i + 3] = r; /* RED */ - } - backend_util_cleanup_frame(frame); - - e = pui_backend_ani_set_buffer(ani, buffer); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on setting buffer on animation !(e=%d)\n", e); - return (pui_bool)0; - } - - e = pui_backend_ani_update(ani); - - if (e != PUI_INT_ERROR_NONE) - { - pui_err("Failed on updating animation !(e=%d)\n", e); - return (pui_bool)0; - } - - pui_info("... update (serial=%d), (repeat| cur: %d, want: %d)\n", - serial, ani_info->repeat_cur, ani_info->repeat); - - if (ani_info->repeat >= 0 && - ani_info->repeat_cur >= ani_info->repeat) - { - ani_data->ani_func->ani_stop(ani, EINA_FALSE); - } + ret = pui_default_backend_ani_update_frame(ani, ani_data, buffer, frame, serial); - return (pui_bool)1; + return (pui_bool)ret; } pui_error -- 2.7.4