default_backend: add some animations - alarm, connected, error, network_error, paring... 77/220677/1
authorjeon <jhyuni.kang@samsung.com>
Thu, 29 Aug 2019 10:23:05 +0000 (19:23 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Fri, 20 Dec 2019 07:22:04 +0000 (16:22 +0900)
Change-Id: Ic98e1fbd2a72aeb88fac91d9dfb1e395dae1a6eb

17 files changed:
backends/Makefile.am
backends/default_ani_alarm.c [new file with mode: 0644]
backends/default_ani_connected.c [new file with mode: 0644]
backends/default_ani_error.c [new file with mode: 0644]
backends/default_ani_networkerror.c [new file with mode: 0644]
backends/default_ani_pairing.c [new file with mode: 0644]
backends/default_ani_system_processing.c [new file with mode: 0644]
backends/default_backend.c
backends/default_backend.h
backends/res/alarm.json [new file with mode: 0644]
backends/res/connected.json [new file with mode: 0644]
backends/res/error.json [new file with mode: 0644]
backends/res/network_error.json [new file with mode: 0644]
backends/res/pairing.json [new file with mode: 0644]
backends/res/processing.json [new file with mode: 0644]
backends/res/system_processing.json
samples/PUI_sample.c

index 60f2cb4..90e0484 100644 (file)
@@ -20,7 +20,13 @@ libpui_default_backend_la_SOURCES = \
         default_ani_streaming.c \
         default_ani_timeout.c \
         default_ani_emergency.c \
+        default_ani_system_processing.c \
         default_ani_normal.c \
         default_ani_easysetup.c \
         default_ani_swupdatedone.c \
-        default_ani_micoff.c
+        default_ani_micoff.c \
+        default_ani_networkerror.c \
+        default_ani_error.c \
+        default_ani_alarm.c \
+        default_ani_pairing.c \
+        default_ani_connected.c
diff --git a/backends/default_ani_alarm.c b/backends/default_ani_alarm.c
new file mode 100644 (file)
index 0000000..52c6594
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "default_backend.h"
+
+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 void
+_ani_backend_alarm_free_frame(default_frame_info_t *frame)
+{
+       if (!frame) return;
+
+       if (frame->leds) free(frame->leds);
+       free(frame);
+}
+
+static default_frame_info_t *
+_ani_backend_alarm_get_frame(default_ani_info *ani_info)
+{
+#define SMOOTH_FRAME 75
+#define ALARM_REPEAT 3
+#define ALARM_FRAME 10
+       default_frame_info_t *frame, *key_frame;
+       int idx;
+       unsigned int r, g, b, r2, g2, b2;
+       int r3, g3, b3;
+       double div;
+       int fade_out_frame;
+
+       frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
+       if (!frame) return NULL;
+
+       idx = ((int)(ani_info->frame_idx / ALARM_FRAME)) % ani_info->num_key_frames;
+       key_frame = &ani_info->frames[idx];
+
+       frame->num_led = key_frame->num_led;
+       frame->leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), frame->num_led);
+       if (!frame->leds)
+       {
+               free(frame);
+               return NULL;
+       }
+
+       /* FIXME: calculate this data before animation start. this is not changed value */
+       fade_out_frame = (ALARM_FRAME) * ani_info->num_key_frames * (ALARM_REPEAT);
+
+       if (ani_info->frame_idx < fade_out_frame)
+       {
+               for (int i = 0; i < key_frame->num_led; i++)
+               {
+                       frame->leds[i].color = key_frame->leds[i].color;
+               }
+       }
+       else
+       {
+               key_frame = &ani_info->frames[0];
+               r2 = g2 = b2 = 0x00;
+               for (int i = 0; i < key_frame->num_led; i++)
+               {
+                       div = (double)(ani_info->frame_idx - fade_out_frame) / (double)SMOOTH_FRAME;
+                       _ani_backend_alarm_get_led_rgb(key_frame, i, &r, &g, &b);
+                       r3 = (int)(r2 - r) * div + r;
+                       g3 = (int)(g2 - g) * div + g;
+                       b3 = (int)(b2 - b) * div + b;
+
+                       frame->leds[i].color = (r3 << 16) + (g3 << 8) + (b3);
+               }
+       }
+
+       ani_info->frame_idx++;
+       if (ani_info->frame_idx >= (fade_out_frame + SMOOTH_FRAME))
+               ani_info->frame_idx = 0;
+
+       return frame;
+}
+
+static pui_bool
+_ani_backend_alarm_frame_cb(void *data, int serial)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       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;
+       double now;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info;
+
+       now = ecore_time_unix_get();
+       pui_info("[time:%.3f] serial=%d\n", now, serial);
+
+       /* TODO : make use of ani_info */
+       //(void) ani_info;
+
+       buffer = pui_backend_ani_get_buffer(ani);
+       if (!buffer) {
+               pui_err("Failed to get buffer for animation\n");
+               return (pui_bool)0;
+       }
+
+       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 */
+       }
+       _ani_backend_alarm_free_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)\n", serial);
+
+       return (pui_bool)1;
+}
+
+pui_error
+_ani_alarm_start(pui_ani_t *ani, int repeat)
+{
+       pui_bool ret = 0;
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s, repeat : %d, interval: %d\n", info->id, repeat, info->interval);
+
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STARTED);
+       ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_alarm_frame_cb, info->interval / 1000.0);
+
+       if (!ret)
+       {
+               pui_err("Failed to add frame callback !\n");
+               e = PUI_INT_ERROR_INVALID_RESOURCES;
+       }
+
+       return e;
+}
+
+pui_error
+_ani_alarm_stop(pui_ani_t *ani)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s\n", info->id);
+
+       pui_backend_ani_remove_frame_cb(ani);
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
+
+       return e;
+}
+
+
+void
+pui_default_backend_ani_alarm_func_set(pui_backend_ani_func *func)
+{
+       if (!func) return;
+
+       func->ani_start = _ani_alarm_start;
+       func->ani_stop = _ani_alarm_stop;
+}
+
+
diff --git a/backends/default_ani_connected.c b/backends/default_ani_connected.c
new file mode 100644 (file)
index 0000000..fcba3ad
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "default_backend.h"
+
+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 void
+_ani_backend_connected_free_frame(default_frame_info_t *frame)
+{
+       if (!frame) return;
+
+       if (frame->leds) free(frame->leds);
+       free(frame);
+}
+
+static default_frame_info_t *
+_ani_backend_connected_get_frame(default_ani_info *ani_info)
+{
+#define BLINK_FRAME 2
+       default_frame_info_t *frame, *key_frame;
+
+       frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
+       if (!frame) return NULL;
+
+       key_frame = &ani_info->frames[0];
+       frame->num_led = key_frame->num_led;
+       frame->leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), frame->num_led);
+       if (!frame->leds)
+       {
+               free(frame);
+               return NULL;
+       }
+
+       if (ani_info->frame_idx % BLINK_FRAME == 0)
+       {
+               for (int i = 0; i < key_frame->num_led; i++)
+               {
+                       frame->leds[i].color = key_frame->leds[i].color;
+               }
+       }
+       else
+       {
+               for (int i = 0; i < key_frame->num_led; i++)
+               {
+                       frame->leds[i].color = 0x000000;
+               }
+       }
+
+       ani_info->frame_idx++;
+       if (ani_info->frame_idx >= BLINK_FRAME)
+               ani_info->frame_idx = 0;
+
+       return frame;
+}
+
+
+static pui_bool
+_ani_backend_connected_frame_cb(void *data, int serial)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       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;
+       double now;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info;
+
+       now = ecore_time_unix_get();
+       pui_info("[time:%.3f] serial=%d\n", now, serial);
+
+       /* TODO : make use of ani_info */
+       //(void) ani_info;
+
+       buffer = pui_backend_ani_get_buffer(ani);
+       if (!buffer) {
+               pui_err("Failed to get buffer for animation\n");
+               return (pui_bool)0;
+       }
+
+       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 */
+       }
+       _ani_backend_connected_free_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)\n", serial);
+
+       return (pui_bool)1;
+}
+
+pui_error
+_ani_connected_start(pui_ani_t *ani, int repeat)
+{
+       pui_bool ret = 0;
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s, repeat : %d, interval: %d\n", info->id, repeat, info->interval);
+
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STARTED);
+       ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_connected_frame_cb, info->interval / 1000.0);
+
+       if (!ret)
+       {
+               pui_err("Failed to add frame callback !\n");
+               e = PUI_INT_ERROR_INVALID_RESOURCES;
+       }
+
+       return e;
+}
+
+pui_error
+_ani_connected_stop(pui_ani_t *ani)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s\n", info->id);
+
+       pui_backend_ani_remove_frame_cb(ani);
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
+
+       return e;
+}
+
+
+void
+pui_default_backend_ani_connected_func_set(pui_backend_ani_func *func)
+{
+       if (!func) return;
+
+       func->ani_start = _ani_connected_start;
+       func->ani_stop = _ani_connected_stop;
+}
+
+
diff --git a/backends/default_ani_error.c b/backends/default_ani_error.c
new file mode 100644 (file)
index 0000000..355d30e
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "default_backend.h"
+
+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 void
+_ani_backend_error_free_frame(default_frame_info_t *frame)
+{
+       if (!frame) return;
+
+       if (frame->leds) free(frame->leds);
+       free(frame);
+}
+
+static default_frame_info_t *
+_ani_backend_error_get_frame(default_ani_info *ani_info)
+{
+#define BLINK_FRAME 2
+       default_frame_info_t *frame, *key_frame;
+
+       frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
+       if (!frame) return NULL;
+
+       key_frame = &ani_info->frames[0];
+       frame->num_led = key_frame->num_led;
+       frame->leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), frame->num_led);
+       if (!frame->leds)
+       {
+               free(frame);
+               return NULL;
+       }
+
+       if (ani_info->frame_idx % BLINK_FRAME == 0)
+       {
+               for (int i = 0; i < key_frame->num_led; i++)
+               {
+                       frame->leds[i].color = key_frame->leds[i].color;
+               }
+       }
+       else
+       {
+               for (int i = 0; i < key_frame->num_led; i++)
+               {
+                       frame->leds[i].color = 0x000000;
+               }
+       }
+
+       ani_info->frame_idx++;
+       if (ani_info->frame_idx >= BLINK_FRAME)
+               ani_info->frame_idx = 0;
+
+       return frame;
+}
+
+
+static pui_bool
+_ani_backend_error_frame_cb(void *data, int serial)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       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;
+       double now;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info;
+
+       now = ecore_time_unix_get();
+       pui_info("[time:%.3f] serial=%d\n", now, serial);
+
+       /* TODO : make use of ani_info */
+       //(void) ani_info;
+
+       buffer = pui_backend_ani_get_buffer(ani);
+       if (!buffer) {
+               pui_err("Failed to get buffer for animation\n");
+               return (pui_bool)0;
+       }
+
+       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 */
+       }
+       _ani_backend_error_free_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)\n", serial);
+
+       return (pui_bool)1;
+}
+
+pui_error
+_ani_error_start(pui_ani_t *ani, int repeat)
+{
+       pui_bool ret = 0;
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s, repeat : %d, interval: %d\n", info->id, repeat, info->interval);
+
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STARTED);
+       ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_error_frame_cb, info->interval / 1000.0);
+
+       if (!ret)
+       {
+               pui_err("Failed to add frame callback !\n");
+               e = PUI_INT_ERROR_INVALID_RESOURCES;
+       }
+
+       return e;
+}
+
+pui_error
+_ani_error_stop(pui_ani_t *ani)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s\n", info->id);
+
+       pui_backend_ani_remove_frame_cb(ani);
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
+
+       return e;
+}
+
+
+void
+pui_default_backend_ani_error_func_set(pui_backend_ani_func *func)
+{
+       if (!func) return;
+
+       func->ani_start = _ani_error_start;
+       func->ani_stop = _ani_error_stop;
+}
+
+
diff --git a/backends/default_ani_networkerror.c b/backends/default_ani_networkerror.c
new file mode 100644 (file)
index 0000000..95a08bc
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "default_backend.h"
+
+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 void
+_ani_backend_networkerror_free_frame(default_frame_info_t *frame)
+{
+       if (!frame) return;
+
+       if (frame->leds) free(frame->leds);
+       free(frame);
+}
+
+static default_frame_info_t *
+_ani_backend_networkerror_get_frame(default_ani_info *ani_info)
+{
+#define BLINK_FRAME 40
+       default_frame_info_t *frame, *key_frame;
+
+       frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
+       if (!frame) return NULL;
+
+       key_frame = &ani_info->frames[0];
+       frame->num_led = key_frame->num_led;
+       frame->leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), frame->num_led);
+       if (!frame->leds)
+       {
+               free(frame);
+               return NULL;
+       }
+
+       if (ani_info->frame_idx % BLINK_FRAME == 0)
+       {
+               for (int i = 0; i < key_frame->num_led; i++)
+               {
+                       frame->leds[i].color = key_frame->leds[i].color;
+               }
+       }
+       else
+       {
+               for (int i = 0; i < key_frame->num_led; i++)
+               {
+                       frame->leds[i].color = 0x000000;
+               }
+       }
+
+       ani_info->frame_idx++;
+       if (ani_info->frame_idx >= BLINK_FRAME)
+               ani_info->frame_idx = 0;
+
+       return frame;
+}
+
+
+static pui_bool
+_ani_backend_networkerror_frame_cb(void *data, int serial)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       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;
+       double now;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info;
+
+       now = ecore_time_unix_get();
+       pui_info("[time:%.3f] serial=%d\n", now, serial);
+
+       /* TODO : make use of ani_info */
+       //(void) ani_info;
+
+       buffer = pui_backend_ani_get_buffer(ani);
+       if (!buffer) {
+               pui_err("Failed to get buffer for animation\n");
+               return (pui_bool)0;
+       }
+
+       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 */
+       }
+       _ani_backend_networkerror_free_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)\n", serial);
+
+       return (pui_bool)1;
+}
+
+pui_error
+_ani_networkerror_start(pui_ani_t *ani, int repeat)
+{
+       pui_bool ret = 0;
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s, repeat : %d, interval: %d\n", info->id, repeat, info->interval);
+
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STARTED);
+       ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_networkerror_frame_cb, info->interval / 1000.0);
+
+       if (!ret)
+       {
+               pui_err("Failed to add frame callback !\n");
+               e = PUI_INT_ERROR_INVALID_RESOURCES;
+       }
+
+       return e;
+}
+
+pui_error
+_ani_networkerror_stop(pui_ani_t *ani)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s\n", info->id);
+
+       pui_backend_ani_remove_frame_cb(ani);
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
+
+       return e;
+}
+
+
+void
+pui_default_backend_ani_networkerror_func_set(pui_backend_ani_func *func)
+{
+       if (!func) return;
+
+       func->ani_start = _ani_networkerror_start;
+       func->ani_stop = _ani_networkerror_stop;
+}
+
+
diff --git a/backends/default_ani_pairing.c b/backends/default_ani_pairing.c
new file mode 100644 (file)
index 0000000..5f4f626
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "default_backend.h"
+
+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 void
+_ani_backend_pairing_free_frame(default_frame_info_t *frame)
+{
+       if (!frame) return;
+
+       if (frame->leds) free(frame->leds);
+       free(frame);
+}
+
+static default_frame_info_t *
+_ani_backend_pairing_get_frame(default_ani_info *ani_info)
+{
+       default_frame_info_t *frame, *key_frame;
+       int idx;
+
+       frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
+       if (!frame) return NULL;
+
+       idx = ani_info->frame_idx;
+
+       key_frame = &ani_info->frames[idx];
+       frame->num_led = key_frame->num_led;
+       frame->leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), frame->num_led);
+       if (!frame->leds)
+       {
+               free(frame);
+               return NULL;
+       }
+
+       for (int i = 0; i < key_frame->num_led; i++)
+       {
+               frame->leds[i].color = key_frame->leds[i].color;
+       }
+
+       ani_info->frame_idx++;
+       if (ani_info->frame_idx >= ani_info->num_key_frames)
+               ani_info->frame_idx = 0;
+
+       return frame;
+}
+
+
+static pui_bool
+_ani_backend_pairing_frame_cb(void *data, int serial)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       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;
+       double now;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info;
+
+       now = ecore_time_unix_get();
+       pui_info("[time:%.3f] serial=%d\n", now, serial);
+
+       /* TODO : make use of ani_info */
+       //(void) ani_info;
+
+       buffer = pui_backend_ani_get_buffer(ani);
+       if (!buffer) {
+               pui_err("Failed to get buffer for animation\n");
+               return (pui_bool)0;
+       }
+
+       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 */
+       }
+       _ani_backend_pairing_free_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)\n", serial);
+
+       return (pui_bool)1;
+}
+
+pui_error
+_ani_pairing_start(pui_ani_t *ani, int repeat)
+{
+       pui_bool ret = 0;
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s, repeat : %d, interval: %d\n", info->id, repeat, info->interval);
+
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STARTED);
+       ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_pairing_frame_cb, info->interval / 1000.0);
+
+       if (!ret)
+       {
+               pui_err("Failed to add frame callback !\n");
+               e = PUI_INT_ERROR_INVALID_RESOURCES;
+       }
+
+       return e;
+}
+
+pui_error
+_ani_pairing_stop(pui_ani_t *ani)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s\n", info->id);
+
+       pui_backend_ani_remove_frame_cb(ani);
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
+
+       return e;
+}
+
+
+void
+pui_default_backend_ani_pairing_func_set(pui_backend_ani_func *func)
+{
+       if (!func) return;
+
+       func->ani_start = _ani_pairing_start;
+       func->ani_stop = _ani_pairing_stop;
+}
+
+
diff --git a/backends/default_ani_system_processing.c b/backends/default_ani_system_processing.c
new file mode 100644 (file)
index 0000000..b54e8c0
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "default_backend.h"
+
+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 void
+_ani_backend_system_processing_free_frame(default_frame_info_t *frame)
+{
+       if (!frame) return;
+
+       if (frame->leds) free(frame->leds);
+       free(frame);
+}
+
+static default_frame_info_t *
+_ani_backend_system_processing_get_frame(default_ani_info *ani_info)
+{
+       default_frame_info_t *frame, *key_frame;
+
+       frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
+       if (!frame) return NULL;
+
+       key_frame = &ani_info->frames[0];
+       frame->num_led = key_frame->num_led;
+       frame->leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), frame->num_led);
+       if (!frame->leds)
+       {
+               free(frame);
+               return NULL;
+       }
+       for (int i = 0; i < key_frame->num_led; i++)
+       {
+               int idx = (i - ani_info->frame_idx + key_frame->num_led) % key_frame->num_led;
+               frame->leds[idx] = key_frame->leds[i];
+       }
+       ani_info->frame_idx++;
+       if (ani_info->frame_idx >= key_frame->num_led)
+               ani_info->frame_idx = 0;
+
+       return frame;
+}
+
+static pui_bool
+_ani_backend_system_processing_frame_cb(void *data, int serial)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       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;
+       double now;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info;
+
+       now = ecore_time_unix_get();
+       pui_info("[time:%.3f] serial=%d\n", now, serial);
+
+       /* TODO : make use of ani_info */
+       //(void) ani_info;
+
+       buffer = pui_backend_ani_get_buffer(ani);
+       if (!buffer) {
+               pui_err("Failed to get buffer for animation\n");
+               return (pui_bool)0;
+       }
+
+       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 */
+       }
+       _ani_backend_system_processing_free_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)\n", serial);
+
+       return (pui_bool)1;
+}
+
+pui_error
+_ani_system_processing_start(pui_ani_t *ani, int repeat)
+{
+       pui_bool ret = 0;
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s, repeat : %d, interval: %d\n", info->id, repeat, info->interval);
+       if (info->num_key_frames != 1)
+       {
+               pui_err("invalid key frames: %d\n", info->num_key_frames);
+               return PUI_INT_ERROR_INVALID_RESOURCES;
+       }
+
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STARTED);
+       ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_system_processing_frame_cb, info->interval / 1000.0);
+
+       if (!ret)
+       {
+               pui_err("Failed to add frame callback !\n");
+               e = PUI_INT_ERROR_INVALID_RESOURCES;
+       }
+
+       return e;
+}
+
+pui_error
+_ani_system_processing_stop(pui_ani_t *ani)
+{
+       pui_int_error e = PUI_INT_ERROR_NONE;
+       pui_backend_ani_data *ani_data = NULL;
+
+       ani_data = pui_backend_ani_get_ani_data(ani);
+       default_ani_info *info = (default_ani_info *)ani_data->ani_info;
+
+       //TODO
+       (void) info;
+
+       pui_info("... info->id: %s\n", info->id);
+
+       pui_backend_ani_remove_frame_cb(ani);
+       pui_backend_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
+
+       return e;
+}
+
+
+void
+pui_default_backend_ani_system_processing_func_set(pui_backend_ani_func *func)
+{
+       if (!func) return;
+
+       func->ani_start = _ani_system_processing_start;
+       func->ani_stop = _ani_system_processing_stop;
+}
+
+
index 94603a3..afba9fc 100644 (file)
@@ -255,7 +255,7 @@ _read_json(const char *path)
        ani_info->num_key_frames = frame_len;
        ani_info->frames = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), frame_len);
        ERROR_CHECK(ani_info->frames, goto error, "Failed to alloc for default_frame_info_t\n");
-       
+
        for (i = 0; i < frame_len; i++) {
                frame_obj = json_object_array_get_idx(data_obj, i);
 
@@ -265,11 +265,11 @@ _read_json(const char *path)
 
                frame_data_obj = json_object_object_get(frame_obj, "led");
                led_len = json_object_array_length(frame_data_obj);
-               
+
                ani_info->frames[frame_id - 1].num_led = led_len;
                ani_info->frames[frame_id - 1].leds = (default_led_info_t *)calloc(sizeof(default_led_info_t), led_len);
                ERROR_CHECK(ani_info->frames[frame_id - 1].leds, goto error, "Failed to alloc for default_led_info_t\n");
-               
+
                for (j = 0; j < led_len; j++) {
                        led_obj = json_object_array_get_idx(frame_data_obj, j);
 
@@ -422,7 +422,7 @@ _ani_create(pui_id id)
 
        /* get animation info associate with the given id from animation collection */
        ani_info = get_ani_info_from_ani_collection(id);
-       
+
        if (!ani_info)
        {
                pui_err("Failed to get ani info from animation collection !\n");
@@ -431,7 +431,7 @@ _ani_create(pui_id id)
 
        /* allocate backend ani_data and return it to pui ani core */
        ani_data = (pui_backend_ani_data *)calloc(1, sizeof(pui_backend_ani_data));
-       
+
        if (!ani_data)
        {
                pui_err("Failed to allocate memory for pui backend ani data !\n");
@@ -459,6 +459,10 @@ _ani_create(pui_id id)
        {
                pui_default_backend_ani_timeout_func_set(ani_func);
        }
+       else if (!strncmp(ani_info->id, "system_processing", sizeof("system_processing")))
+       {
+               pui_default_backend_ani_system_processing_func_set(ani_func);
+       }
        else if (!strncmp(ani_info->id, "normal", sizeof("normal")))
        {
                pui_default_backend_ani_normal_func_set(ani_func);
@@ -479,6 +483,26 @@ _ani_create(pui_id id)
        {
                pui_default_backend_ani_micoff_func_set(ani_func);
        }
+       else if (!strncmp(ani_info->id, "network_error", sizeof("network_error")))
+       {
+               pui_default_backend_ani_networkerror_func_set(ani_func);
+       }
+       else if (!strncmp(ani_info->id, "error", sizeof("error")))
+       {
+               pui_default_backend_ani_error_func_set(ani_func);
+       }
+       else if (!strncmp(ani_info->id, "alarm", sizeof("alarm")))
+       {
+               pui_default_backend_ani_alarm_func_set(ani_func);
+       }
+       else if (!strncmp(ani_info->id, "connected", sizeof("connected")))
+       {
+               pui_default_backend_ani_connected_func_set(ani_func);
+       }
+       else if (!strncmp(ani_info->id, "pairing", sizeof("pairing")))
+       {
+               pui_default_backend_ani_pairing_func_set(ani_func);
+       }
        else
        {
                pui_info("%s animation has no animation handler, using default handler\n", ani_info->id);
@@ -486,7 +510,7 @@ _ani_create(pui_id id)
                ani_func->ani_start = _ani_start;
                ani_func->ani_stop = _ani_stop;
        }
-       
+
        ani_data->ani_func = ani_func;
        ani_data->ani_info = (pui_backend_ani_info *)ani_info;
 
index 04ebd7c..7bfd132 100644 (file)
@@ -100,9 +100,14 @@ void pui_default_backend_ani_speaking_func_set(pui_backend_ani_func *func);
 void pui_default_backend_ani_processing_func_set(pui_backend_ani_func *func);
 void pui_default_backend_ani_streaming_func_set(pui_backend_ani_func *func);
 void pui_default_backend_ani_timeout_func_set(pui_backend_ani_func *func);
+void pui_default_backend_ani_system_processing_func_set(pui_backend_ani_func *func);
 void pui_default_backend_ani_normal_func_set(pui_backend_ani_func *func);
 void pui_default_backend_ani_emergency_func_set(pui_backend_ani_func *func);
 void pui_default_backend_ani_easysetup_func_set(pui_backend_ani_func *func);
 void pui_default_backend_ani_swupdatedone_func_set(pui_backend_ani_func *func);
 void pui_default_backend_ani_micoff_func_set(pui_backend_ani_func *func);
-
+void pui_default_backend_ani_networkerror_func_set(pui_backend_ani_func *func);
+void pui_default_backend_ani_error_func_set(pui_backend_ani_func *func);
+void pui_default_backend_ani_alarm_func_set(pui_backend_ani_func *func);
+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);
diff --git a/backends/res/alarm.json b/backends/res/alarm.json
new file mode 100644 (file)
index 0000000..75d5ddd
--- /dev/null
@@ -0,0 +1,108 @@
+{
+       "type": "alarm",
+       "interval": 40,
+       "frame": [
+               {
+                       "frame_id": 1,
+                       "led": [
+                               {"id": 1,  "color": "FFFFFF"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "FFFFFF"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "FFFFFF"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "FFFFFF"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               },
+               {
+                       "frame_id": 2,
+                       "led": [
+                               {"id": 1,  "color": "000000"},
+                               {"id": 2,  "color": "FFFFFF"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "FFFFFF"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "FFFFFF"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "FFFFFF"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               },
+               {
+                       "frame_id": 3,
+                       "led": [
+                               {"id": 1,  "color": "000000"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               },
+               {
+                       "frame_id": 4,
+                       "led": [
+                               {"id": 1,  "color": "000000"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "FFFFFF"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "FFFFFF"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "FFFFFF"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "FFFFFF"}
+                       ]
+               },
+               {
+                       "frame_id": 5,
+                       "led": [
+                               {"id": 1,  "color": "FFFFFF"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "FFFFFF"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "FFFFFF"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "FFFFFF"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               },
+               {
+                       "frame_id": 6,
+                       "led": [
+                               {"id": 1,  "color": "000000"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               }
+       ]
+}
diff --git a/backends/res/connected.json b/backends/res/connected.json
new file mode 100644 (file)
index 0000000..9236ea6
--- /dev/null
@@ -0,0 +1,23 @@
+{
+       "type": "connected",
+       "interval": 100,
+       "frame": [
+               {
+                       "frame_id": 1,
+                       "led": [
+                               {"id": 1,  "color": "0000FF"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               }
+       ]
+}
diff --git a/backends/res/error.json b/backends/res/error.json
new file mode 100644 (file)
index 0000000..7170501
--- /dev/null
@@ -0,0 +1,23 @@
+{
+       "type": "error",
+       "interval": 500,
+       "frame": [
+               {
+                       "frame_id": 1,
+                       "led": [
+                               {"id": 1,  "color": "FF0000"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               }
+       ]
+}
diff --git a/backends/res/network_error.json b/backends/res/network_error.json
new file mode 100644 (file)
index 0000000..6869777
--- /dev/null
@@ -0,0 +1,23 @@
+{
+       "type": "network_error",
+       "interval": 100,
+       "frame": [
+               {
+                       "frame_id": 1,
+                       "led": [
+                               {"id": 1,  "color": "FF0000"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               }
+       ]
+}
diff --git a/backends/res/pairing.json b/backends/res/pairing.json
new file mode 100644 (file)
index 0000000..4db2bc6
--- /dev/null
@@ -0,0 +1,57 @@
+{
+       "type": "pairing",
+       "interval": 500,
+       "frame": [
+               {
+                       "frame_id": 1,
+                       "led": [
+                               {"id": 1,  "color": "FF0000"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               },
+               {
+                       "frame_id": 2,
+                       "led": [
+                               {"id": 1,  "color": "00FF00"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               },
+               {
+                       "frame_id": 3,
+                       "led": [
+                               {"id": 1,  "color": "0000FF"},
+                               {"id": 2,  "color": "000000"},
+                               {"id": 3,  "color": "000000"},
+                               {"id": 4,  "color": "000000"},
+                               {"id": 5,  "color": "000000"},
+                               {"id": 6,  "color": "000000"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"}
+                       ]
+               }
+       ]
+}
diff --git a/backends/res/processing.json b/backends/res/processing.json
new file mode 100644 (file)
index 0000000..a402de9
--- /dev/null
@@ -0,0 +1,23 @@
+{
+       "type": "processing",
+       "interval": 100,
+       "frame": [
+               {
+                       "frame_id": 1,
+                       "led": [
+                               {"id": 1,  "color": "bbbbbb"},
+                               {"id": 2,  "color": "a0a0a0"},
+                               {"id": 3,  "color": "909090"},
+                               {"id": 4,  "color": "666666"},
+                               {"id": 5,  "color": "454545"},
+                               {"id": 6,  "color": "202020"},
+                               {"id": 7,  "color": "000000"},
+                               {"id": 8,  "color": "000000"},
+                               {"id": 9,  "color": "000000"},
+                               {"id": 10, "color": "000000"},
+                               {"id": 11, "color": "000000"},
+                               {"id": 12, "color": "000000"},
+                       ]
+               },
+       ]
+}
index a402de9..a3a037a 100644 (file)
@@ -1,5 +1,5 @@
 {
-       "type": "processing",
+       "type": "system_processing",
        "interval": 100,
        "frame": [
                {
index a5c22a7..10f9f95 100644 (file)
@@ -68,16 +68,22 @@ struct app_data
 
 static Eina_Array *_ecore_event_hdls = NULL;
 static animation_t ani_collection[] = {
-       { "processing", PUI_ANI_CMD_START, -1 },
-       { "listening", PUI_ANI_CMD_START, -1 },
-       { "speaking", PUI_ANI_CMD_START, -1 },
-       { "streaming", PUI_ANI_CMD_START, -1 },
-       { "emergency", PUI_ANI_CMD_START, -1 },
        { "easy_setup", PUI_ANI_CMD_START, -1 },
+       { "system_processing", PUI_ANI_CMD_START, -1 },
        { "sw_update_done", PUI_ANI_CMD_START, -1 },
        { "mic_off", PUI_ANI_CMD_START, -1 },
+       { "listening", PUI_ANI_CMD_START, -1 },
+       { "streaming", PUI_ANI_CMD_START, -1 },
+       { "processing", PUI_ANI_CMD_START, -1 },
+       { "speaking", PUI_ANI_CMD_START, -1 },
        { "time_out", PUI_ANI_CMD_START, -1 },
-       { "normal", PUI_ANI_CMD_START, -1 }
+       { "normal", PUI_ANI_CMD_START, -1 },
+       { "emergency", PUI_ANI_CMD_START, -1 },
+       { "network_error", PUI_ANI_CMD_START, -1 },
+       { "error", PUI_ANI_CMD_START, -1 },
+       { "alarm", PUI_ANI_CMD_START, -1 },
+       { "pairing", PUI_ANI_CMD_START, -1 },
+       { "connected", PUI_ANI_CMD_START, -1 }
 };
 
 pui_ani_h ani_handles[sizeof(ani_collection) / sizeof(animation_t)];
@@ -200,7 +206,7 @@ _cb_ani_stopped(void *data, int type EINA_UNUSED, void *event)
        debug_info("[%s] ani id=%s, status=%d, window=0x%x\n", __FUNCTION__, pui_ani_get_id(ev->ani_h), ev->status, ev->win);
 
        /* decrease animation idx for starting from stopped animation */
-       app->ani_idx--;
+       //app->ani_idx--;
 
        return ECORE_CALLBACK_PASS_ON;
 }