default_backend: implements frame_duration to proceed each frame at a different speed 86/220686/1
authorjeon <jhyuni.kang@samsung.com>
Fri, 6 Sep 2019 06:49:40 +0000 (15:49 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Fri, 20 Dec 2019 07:26:00 +0000 (16:26 +0900)
Change-Id: Ie2f2edac3cb0357569b76506fe9c52050f49fb63

28 files changed:
backends/bt/default_ani_connected.c
backends/bt/default_ani_pairing.c
backends/default_backend.c
backends/default_backend.h
backends/notification/default_ani_alarm.c
backends/notification/default_ani_emergency.c
backends/notification/default_ani_error.c
backends/notification/default_ani_networkerror.c
backends/notification/default_ani_normal.c
backends/res/bt/connected.json
backends/res/notification/alarm.json
backends/res/notification/emergency.json
backends/res/notification/network_error.json
backends/res/notification/normal.json
backends/res/system/easy_setup.json
backends/res/system/sw_update_done.json
backends/res/voice/speaking.json
backends/res/voice/streaming.json
backends/res/voice/timeout.json
backends/system/default_ani_easysetup.c
backends/system/default_ani_micoff.c
backends/system/default_ani_swupdatedone.c
backends/system/default_ani_system_processing.c
backends/voice/default_ani_listening.c
backends/voice/default_ani_processing.c
backends/voice/default_ani_speaking.c
backends/voice/default_ani_streaming.c
backends/voice/default_ani_timeout.c

index 15e0e2b..0dbda8d 100644 (file)
@@ -49,13 +49,20 @@ _ani_backend_connected_free_frame(default_frame_info_t *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;
+       int idx;
 
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       key_frame = &ani_info->frames[0];
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
+       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)
@@ -64,27 +71,17 @@ _ani_backend_connected_get_frame(default_ani_info *ani_info)
                return NULL;
        }
 
-       if (ani_info->frame_idx % BLINK_FRAME == 0)
+       for (int i = 0; i < key_frame->num_led; i++)
        {
-               for (int i = 0; i < key_frame->num_led; i++)
-               {
-                       frame->leds[i].color = key_frame->leds[i].color;
-               }
+               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)
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -172,6 +169,10 @@ _ani_connected_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_connected_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index a272eda..b628e8e 100644 (file)
@@ -55,7 +55,12 @@ _ani_backend_pairing_get_frame(default_ani_info *ani_info)
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       idx = ani_info->frame_idx;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
 
        key_frame = &ani_info->frames[idx];
        frame->num_led = key_frame->num_led;
@@ -72,11 +77,12 @@ _ani_backend_pairing_get_frame(default_ani_info *ani_info)
        }
 
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= ani_info->num_key_frames)
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -164,6 +170,10 @@ _ani_pairing_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_pairing_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index bc13c94..8ed95cf 100644 (file)
@@ -267,6 +267,12 @@ _read_json(const char *path)
                //printf("\tframe id: %d\n", json_object_get_int(frame_data_obj));
                frame_id = json_object_get_int(frame_data_obj);
 
+               frame_data_obj = json_object_object_get(frame_obj, "frame_duration");
+               if (frame_data_obj)
+                       ani_info->frames[frame_id - 1].frame_duration = json_object_get_int(frame_data_obj);
+               else
+                       ani_info->frames[frame_id - 1].frame_duration = ani_info->interval;
+
                frame_data_obj = json_object_object_get(frame_obj, "led");
                led_len = json_object_array_length(frame_data_obj);
 
index a61bbe0..84210fc 100644 (file)
@@ -83,12 +83,15 @@ struct _default_ani_info
 
        unsigned int repeat_cur;
        unsigned int frame_idx;
+       unsigned int frame_max;
+       unsigned int key_frame_cur;
 };
 
 struct _default_frame_info_t
 {
        default_led_info_t *leds;
        int num_led;
+       int frame_duration;
 };
 
 struct _default_led_info_t
index fbafe63..1324cc7 100644 (file)
@@ -49,20 +49,23 @@ _ani_backend_alarm_free_frame(default_frame_info_t *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;
+/* FIXME: ALAMR_FRAME need to changed after we imply animation type, suchas ease function */
+#define ALARM_FRAME 18
+       default_frame_info_t *frame, *key_frame, *key_frame2;
+       int idx, idx2;
        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;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
        key_frame = &ani_info->frames[idx];
 
        frame->num_led = key_frame->num_led;
@@ -73,10 +76,7 @@ _ani_backend_alarm_get_frame(default_ani_info *ani_info)
                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)
+       if (ani_info->key_frame_cur < ALARM_FRAME)
        {
                for (int i = 0; i < key_frame->num_led; i++)
                {
@@ -85,12 +85,14 @@ _ani_backend_alarm_get_frame(default_ani_info *ani_info)
        }
        else
        {
-               key_frame = &ani_info->frames[0];
-               r2 = g2 = b2 = 0x00;
+               idx2 = (idx + 1) % ani_info->num_key_frames;
+               key_frame2 = &ani_info->frames[idx2];
+               div = (double)(ani_info->frame_idx) / (double)ani_info->frame_max;
+               r = g = b = r2 = g2 = b2 = 0x0;
                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);
+                       _ani_backend_alarm_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;
@@ -100,11 +102,12 @@ _ani_backend_alarm_get_frame(default_ani_info *ani_info)
        }
 
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= (fade_out_frame + SMOOTH_FRAME))
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -191,6 +194,10 @@ _ani_alarm_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_alarm_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 6e4ea8d..54cb04c 100644 (file)
@@ -49,7 +49,6 @@ _ani_backend_emergency_free_frame(default_frame_info_t *frame)
 static default_frame_info_t *
 _ani_backend_emergency_get_frame(default_ani_info *ani_info)
 {
-#define SMOOTH_FRAME 15
        default_frame_info_t *frame, *key_frame, *key_frame2;
        int idx, idx2;
        unsigned int r, g, b, r2, g2, b2;
@@ -59,7 +58,12 @@ _ani_backend_emergency_get_frame(default_ani_info *ani_info)
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       idx = ((int)(ani_info->frame_idx / SMOOTH_FRAME)) % ani_info->num_key_frames;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
        idx2 = (idx + 1) % ani_info->num_key_frames;
 
        key_frame = &ani_info->frames[idx];
@@ -71,7 +75,7 @@ _ani_backend_emergency_get_frame(default_ani_info *ani_info)
                free(frame);
                return NULL;
        }
-       div = (double)(ani_info->frame_idx % SMOOTH_FRAME) / (double)SMOOTH_FRAME;
+       div = (double)(ani_info->frame_idx) / (double)ani_info->frame_max;
        r = g = b = r2 = g2 = b2 = 0x0;
        for (int i = 0; i < key_frame->num_led; i++)
        {
@@ -83,12 +87,14 @@ _ani_backend_emergency_get_frame(default_ani_info *ani_info)
 
                frame->leds[i].color = (r3 << 16) + (g3 << 8) + (b3);
        }
+
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= (ani_info->num_key_frames * SMOOTH_FRAME))
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -176,6 +182,10 @@ _ani_emergency_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_emergency_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 82ed9a2..a973d0c 100644 (file)
@@ -49,6 +49,7 @@ _ani_backend_error_free_frame(default_frame_info_t *frame)
 static default_frame_info_t *
 _ani_backend_error_get_frame(default_ani_info *ani_info)
 {
+/* FIXME: ALAMR_FRAME need to changed after we imply animation type, suchas ease function */
 #define BLINK_FRAME 2
        default_frame_info_t *frame, *key_frame;
 
@@ -172,6 +173,10 @@ _ani_error_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_error_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 218d43a..f24c74c 100644 (file)
@@ -49,13 +49,20 @@ _ani_backend_networkerror_free_frame(default_frame_info_t *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;
+       int idx;
 
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       key_frame = &ani_info->frames[0];
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
+       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)
@@ -64,27 +71,18 @@ _ani_backend_networkerror_get_frame(default_ani_info *ani_info)
                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++)
        {
-               for (int i = 0; i < key_frame->num_led; i++)
-               {
-                       frame->leds[i].color = 0x000000;
-               }
+               frame->leds[i].color = key_frame->leds[i].color;
        }
 
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= BLINK_FRAME)
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -172,6 +170,10 @@ _ani_networkerror_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_networkerror_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 6d5b2b3..9dc7173 100644 (file)
@@ -49,7 +49,6 @@ _ani_backend_normal_free_frame(default_frame_info_t *frame)
 static default_frame_info_t *
 _ani_backend_normal_get_frame(default_ani_info *ani_info)
 {
-#define SMOOTH_FRAME 15
        default_frame_info_t *frame, *key_frame, *key_frame2;
        int idx, idx2;
        unsigned int r, g, b, r2, g2, b2;
@@ -59,7 +58,12 @@ _ani_backend_normal_get_frame(default_ani_info *ani_info)
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       idx = ((int)(ani_info->frame_idx / SMOOTH_FRAME)) % ani_info->num_key_frames;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
        idx2 = (idx + 1) % ani_info->num_key_frames;
 
        key_frame = &ani_info->frames[idx];
@@ -71,7 +75,7 @@ _ani_backend_normal_get_frame(default_ani_info *ani_info)
                free(frame);
                return NULL;
        }
-       div = (double)(ani_info->frame_idx % SMOOTH_FRAME) / (double)SMOOTH_FRAME;
+       div = (double)(ani_info->frame_idx) / (double)ani_info->frame_max;
        r = g = b = r2 = g2 = b2 = 0x0;
        for (int i = 0; i < key_frame->num_led; i++)
        {
@@ -84,11 +88,12 @@ _ani_backend_normal_get_frame(default_ani_info *ani_info)
                frame->leds[i].color = (r3 << 16) + (g3 << 8) + (b3);
        }
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= (ani_info->num_key_frames * SMOOTH_FRAME))
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -176,6 +181,10 @@ _ani_normal_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_normal_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 686afa3..8a78b34 100644 (file)
                                {"id": 11, "color": "000000"},
                                {"id": 12, "color": "000000"}
                        ]
+               },
+               {
+                       "frame_id": 2,
+                       "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"}
+                       ]
                }
        ]
 }
index 46a15b1..c0f1afe 100644 (file)
@@ -4,6 +4,7 @@
        "frame": [
                {
                        "frame_id": 1,
+                       "frame_duration": 480,
                        "led": [
                                {"id": 1,  "color": "FFFFFF"},
                                {"id": 2,  "color": "000000"},
@@ -21,6 +22,7 @@
                },
                {
                        "frame_id": 2,
+                       "frame_duration": 400,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "FFFFFF"},
@@ -38,6 +40,7 @@
                },
                {
                        "frame_id": 3,
+                       "frame_duration": 600,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "000000"},
@@ -55,6 +58,7 @@
                },
                {
                        "frame_id": 4,
+                       "frame_duration": 480,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "000000"},
@@ -72,6 +76,7 @@
                },
                {
                        "frame_id": 5,
+                       "frame_duration": 400,
                        "led": [
                                {"id": 1,  "color": "FFFFFF"},
                                {"id": 2,  "color": "000000"},
@@ -89,6 +94,7 @@
                },
                {
                        "frame_id": 6,
+                       "frame_duration": 600,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "000000"},
                                {"id": 11, "color": "000000"},
                                {"id": 12, "color": "000000"}
                        ]
-               }
+               },
+               {
+                       "frame_id": 7,
+                       "frame_duration": 480,
+                       "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": 8,
+                       "frame_duration": 400,
+                       "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": 9,
+                       "frame_duration": 600,
+                       "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": 10,
+                       "frame_duration": 480,
+                       "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": 11,
+                       "frame_duration": 400,
+                       "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": 12,
+                       "frame_duration": 600,
+                       "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": 13,
+                       "frame_duration": 480,
+                       "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": 14,
+                       "frame_duration": 400,
+                       "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": 15,
+                       "frame_duration": 600,
+                       "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": 16,
+                       "frame_duration": 480,
+                       "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": 17,
+                       "frame_duration": 400,
+                       "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": 18,
+                       "frame_duration": 600,
+                       "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": 19,
+                       "frame_duration": 3200,
+                       "led": [
+                               {"id": 1,  "color": "FFFFFF"},
+                               {"id": 2,  "color": "FFFFFF"},
+                               {"id": 3,  "color": "FFFFFF"},
+                               {"id": 4,  "color": "FFFFFF"},
+                               {"id": 5,  "color": "FFFFFF"},
+                               {"id": 6,  "color": "FFFFFF"},
+                               {"id": 7,  "color": "FFFFFF"},
+                               {"id": 8,  "color": "FFFFFF"},
+                               {"id": 9,  "color": "FFFFFF"},
+                               {"id": 10, "color": "FFFFFF"},
+                               {"id": 11, "color": "FFFFFF"},
+                               {"id": 12, "color": "FFFFFF"}
+                       ]
+               },
+               {
+                       "frame_id": 20,
+                       "frame_duration": 40,
+                       "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"}
+                       ]
+               },              
        ]
 }
index 8e8046f..076cb51 100644 (file)
@@ -1,9 +1,10 @@
 {
        "type": "notification/emergency",
-       "interval": 30,
+       "interval": 400,
        "frame": [
                {
                        "frame_id": 1,
+                       "frame_duration": 1200,
                        "led": [
                                {"id": 1,  "color": "FF0000"},
                                {"id": 2,  "color": "000000"},
@@ -21,6 +22,7 @@
                },
                {
                        "frame_id": 2,
+                       "frame_duration": 1200,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "000000"},
index 75304de..6f2041b 100644 (file)
                                {"id": 11, "color": "000000"},
                                {"id": 12, "color": "000000"}
                        ]
+               },
+               {
+                       "frame_id": 2,
+                       "frame_duration": 500,
+                       "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"}
+                       ]
                }
        ]
 }
index acad93a..ed8dc88 100644 (file)
@@ -4,6 +4,7 @@
        "frame": [
                {
                        "frame_id": 1,
+                       "frame_duration": 500,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "000000"},
@@ -21,6 +22,7 @@
                },
                {
                        "frame_id": 2,
+                       "frame_duration": 500,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "000000"},
index 72b92f2..cd7bf9f 100644 (file)
@@ -4,6 +4,7 @@
        "frame": [
                {
                        "frame_id": 1,
+                       "frame_duration": 270,
                        "led": [
                                {"id": 1,  "color": "000022"},
                                {"id": 2,  "color": "000022"},
@@ -21,6 +22,7 @@
                },
                {
                        "frame_id": 2,
+                       "frame_duration": 420,
                        "led": [
                                {"id": 1,  "color": "0000ee"},
                                {"id": 2,  "color": "0000ee"},
                                {"id": 12, "color": "0000ee"}
                        ]
                },
+               {
+                       "frame_id": 3,
+                       "frame_duration": 300,
+                       "led": [
+                               {"id": 1,  "color": "000022"},
+                               {"id": 2,  "color": "000022"},
+                               {"id": 3,  "color": "000022"},
+                               {"id": 4,  "color": "000022"},
+                               {"id": 5,  "color": "000022"},
+                               {"id": 6,  "color": "000022"},
+                               {"id": 7,  "color": "000022"},
+                               {"id": 8,  "color": "000022"},
+                               {"id": 9,  "color": "000022"},
+                               {"id": 10, "color": "000022"},
+                               {"id": 11, "color": "000022"},
+                               {"id": 12, "color": "000022"}
+                       ]
+               },
        ]
 }
index a250ce1..851b419 100644 (file)
@@ -4,23 +4,25 @@
        "frame": [
                {
                        "frame_id": 1,
+                       "frame_duration": 210,
                        "led": [
-                               {"id": 1,  "color": "222222"},
-                               {"id": 2,  "color": "222222"},
-                               {"id": 3,  "color": "222222"},
-                               {"id": 4,  "color": "222222"},
-                               {"id": 5,  "color": "222222"},
-                               {"id": 6,  "color": "222222"},
-                               {"id": 7,  "color": "222222"},
-                               {"id": 8,  "color": "222222"},
-                               {"id": 9,  "color": "222222"},
-                               {"id": 10, "color": "222222"},
-                               {"id": 11, "color": "222222"},
-                               {"id": 12, "color": "222222"}
+                               {"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": 2,
+                       "frame_duration": 450,
                        "led": [
                                {"id": 1,  "color": "eeeeee"},
                                {"id": 2,  "color": "eeeeee"},
@@ -38,6 +40,7 @@
                },
                {
                        "frame_id": 3,
+                       "frame_duration": 120,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "000000"},
index 5f514a1..fbd98b0 100644 (file)
@@ -4,6 +4,7 @@
        "frame": [
                {
                        "frame_id": 1,
+                       "frame_duration": 270,
                        "led": [
                                {"id": 1,  "color": "222222"},
                                {"id": 2,  "color": "222222"},
@@ -21,6 +22,7 @@
                },
                {
                        "frame_id": 2,
+                       "frame_duration": 420,
                        "led": [
                                {"id": 1,  "color": "eeeeee"},
                                {"id": 2,  "color": "eeeeee"},
                                {"id": 12, "color": "eeeeee"}
                        ]
                },
+               {
+                       "frame_id": 3,
+                       "frame_duration": 330,
+                       "led": [
+                               {"id": 1,  "color": "222222"},
+                               {"id": 2,  "color": "222222"},
+                               {"id": 3,  "color": "222222"},
+                               {"id": 4,  "color": "222222"},
+                               {"id": 5,  "color": "222222"},
+                               {"id": 6,  "color": "222222"},
+                               {"id": 7,  "color": "222222"},
+                               {"id": 8,  "color": "222222"},
+                               {"id": 9,  "color": "222222"},
+                               {"id": 10, "color": "222222"},
+                               {"id": 11, "color": "222222"},
+                               {"id": 12, "color": "222222"}
+                       ]
+               }
        ]
 }
index 6328c51..5fc1381 100644 (file)
@@ -4,6 +4,7 @@
        "frame": [
                {
                        "frame_id": 1,
+                       "frame_duration": 210,
                        "led": [
                                {"id": 1,  "color": "ffffff"},
                                {"id": 2,  "color": "000000"},
@@ -21,6 +22,7 @@
                },
                {
                        "frame_id": 2,
+                       "frame_duration": 210,
                        "led": [
                                {"id": 1,  "color": "222222"},
                                {"id": 2,  "color": "000000"},
                                {"id": 12, "color": "222222"}
                        ]
                },
+               {
+                       "frame_id": 3,
+                       "frame_duration": 480,
+                       "led": [
+                               {"id": 1,  "color": "ffffff"},
+                               {"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": "ffffff"}
+                       ]
+               }
        ]
 }
index fffbe5b..3b7df7b 100644 (file)
@@ -4,6 +4,7 @@
        "frame": [
                {
                        "frame_id": 1,
+                       "frame_duration": 120,
                        "led": [
                                {"id": 1,  "color": "ffffff"},
                                {"id": 2,  "color": "000000"},
@@ -21,6 +22,7 @@
                },
                {
                        "frame_id": 2,
+                       "frame_duration": 120,
                        "led": [
                                {"id": 1,  "color": "444444"},
                                {"id": 2,  "color": "000000"},
@@ -38,6 +40,7 @@
                },
                {
                        "frame_id": 3,
+                       "frame_duration": 570,
                        "led": [
                                {"id": 1,  "color": "ffffff"},
                                {"id": 2,  "color": "000000"},
@@ -55,6 +58,7 @@
                },
                {
                        "frame_id": 4,
+                       "frame_duration": 1200,
                        "led": [
                                {"id": 1,  "color": "ffffff"},
                                {"id": 2,  "color": "000000"},
@@ -72,6 +76,7 @@
                },
                {
                        "frame_id": 5,
+                       "frame_duration": 30,
                        "led": [
                                {"id": 1,  "color": "000000"},
                                {"id": 2,  "color": "000000"},
index 4449a4e..afc9ff4 100644 (file)
@@ -49,7 +49,6 @@ _ani_backend_easysetup_free_frame(default_frame_info_t *frame)
 static default_frame_info_t *
 _ani_backend_easysetup_get_frame(default_ani_info *ani_info)
 {
-#define SMOOTH_FRAME 20
        default_frame_info_t *frame, *key_frame, *key_frame2;
        int idx, idx2;
        unsigned int r, g, b, r2, g2, b2;
@@ -59,7 +58,12 @@ _ani_backend_easysetup_get_frame(default_ani_info *ani_info)
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       idx = ((int)(ani_info->frame_idx / SMOOTH_FRAME)) % ani_info->num_key_frames;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
        idx2 = (idx + 1) % ani_info->num_key_frames;
 
        key_frame = &ani_info->frames[idx];
@@ -71,7 +75,7 @@ _ani_backend_easysetup_get_frame(default_ani_info *ani_info)
                free(frame);
                return NULL;
        }
-       div = (double)(ani_info->frame_idx % SMOOTH_FRAME) / (double)SMOOTH_FRAME;
+       div = (double)(ani_info->frame_idx) / (double)ani_info->frame_max;
        r = g = b = r2 = g2 = b2 = 0x0;
        for (int i = 0; i < key_frame->num_led; i++)
        {
@@ -84,11 +88,12 @@ _ani_backend_easysetup_get_frame(default_ani_info *ani_info)
                frame->leds[i].color = (r3 << 16) + (g3 << 8) + (b3);
        }
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= (ani_info->num_key_frames * SMOOTH_FRAME))
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -175,6 +180,10 @@ _ani_easysetup_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_easysetup_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 2e746d5..b8b433e 100644 (file)
@@ -156,6 +156,10 @@ _ani_micoff_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_micoff_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 81c236c..84f36ac 100644 (file)
@@ -49,7 +49,6 @@ _ani_backend_swupdatedone_free_frame(default_frame_info_t *frame)
 static default_frame_info_t *
 _ani_backend_swupdatedone_get_frame(default_ani_info *ani_info)
 {
-#define SMOOTH_FRAME 20
        default_frame_info_t *frame, *key_frame, *key_frame2;
        int idx, idx2;
        unsigned int r, g, b, r2, g2, b2;
@@ -59,7 +58,12 @@ _ani_backend_swupdatedone_get_frame(default_ani_info *ani_info)
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       idx = ((int)(ani_info->frame_idx / SMOOTH_FRAME)) % ani_info->num_key_frames;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
        idx2 = (idx + 1) % ani_info->num_key_frames;
 
        key_frame = &ani_info->frames[idx];
@@ -71,8 +75,12 @@ _ani_backend_swupdatedone_get_frame(default_ani_info *ani_info)
                free(frame);
                return NULL;
        }
-       div = (double)(ani_info->frame_idx % SMOOTH_FRAME) / (double)SMOOTH_FRAME;
+
+       div = (double)(ani_info->frame_idx) / (double)ani_info->frame_max;
        r = g = b = r2 = g2 = b2 = 0x0;
+
+       printf("[jeon] idx: %d, frame_max: %d, frame_idx: %d, div: %lf\n",
+               idx, ani_info->frame_max, ani_info->frame_idx, div);
        for (int i = 0; i < key_frame->num_led; i++)
        {
                _ani_backend_swupdatedone_get_led_rgb(key_frame, i, &r, &g, &b);
@@ -82,13 +90,18 @@ _ani_backend_swupdatedone_get_frame(default_ani_info *ani_info)
                b3 = (int)(b2 - b) * div + b;
 
                frame->leds[i].color = (r3 << 16) + (g3 << 8) + (b3);
+               
+               printf("[jeon][%d] (%d)rgb(0x%x, 0x%x, 0x%x), (%d)rgb2(0x%x, 0x%x, 0x%x), color: 0x%x(0x%x, 0x%x, 0x%x)\n",
+                       i, idx, r, g, b, idx2, r2, g2, b2, frame->leds[i].color, r3, g3, b3);
        }
+
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= (ani_info->num_key_frames * SMOOTH_FRAME))
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -175,6 +188,10 @@ _ani_swupdatedone_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_swupdatedone_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 223c0bf..816e4d5 100644 (file)
@@ -164,6 +164,10 @@ _ani_system_processing_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_system_processing_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 9385efc..93ecba2 100644 (file)
@@ -188,6 +188,10 @@ _ani_listening_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_listening_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index ffd58e8..b31ef80 100644 (file)
@@ -164,6 +164,10 @@ _ani_processing_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_processing_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index fb48924..fee1e8f 100644 (file)
@@ -49,7 +49,6 @@ _ani_backend_speaking_free_frame(default_frame_info_t *frame)
 static default_frame_info_t *
 _ani_backend_speaking_get_frame(default_ani_info *ani_info)
 {
-#define SMOOTH_FRAME 20
        default_frame_info_t *frame, *key_frame, *key_frame2;
        int idx, idx2;
        unsigned int r, g, b, r2, g2, b2;
@@ -59,7 +58,12 @@ _ani_backend_speaking_get_frame(default_ani_info *ani_info)
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       idx = ((int)(ani_info->frame_idx / SMOOTH_FRAME)) % ani_info->num_key_frames;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
        idx2 = (idx + 1) % ani_info->num_key_frames;
 
        key_frame = &ani_info->frames[idx];
@@ -71,7 +75,7 @@ _ani_backend_speaking_get_frame(default_ani_info *ani_info)
                free(frame);
                return NULL;
        }
-       div = (double)(ani_info->frame_idx % SMOOTH_FRAME) / (double)SMOOTH_FRAME;
+       div = (double)(ani_info->frame_idx) / (double)ani_info->frame_max;
        r = g = b = r2 = g2 = b2 = 0x0;
        for (int i = 0; i < key_frame->num_led; i++)
        {
@@ -84,11 +88,13 @@ _ani_backend_speaking_get_frame(default_ani_info *ani_info)
                frame->leds[i].color = (r3 << 16) + (g3 << 8) + (b3);
        }
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= (ani_info->num_key_frames * SMOOTH_FRAME))
+
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -175,6 +181,10 @@ _ani_speaking_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_speaking_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 502ec96..56fe4c3 100644 (file)
@@ -49,7 +49,6 @@ _ani_backend_streaming_free_frame(default_frame_info_t *frame)
 static default_frame_info_t *
 _ani_backend_streaming_get_frame(default_ani_info *ani_info)
 {
-#define SMOOTH_FRAME 15
        default_frame_info_t *frame, *key_frame, *key_frame2;
        int idx, idx2;
        unsigned int r, g, b, r2, g2, b2;
@@ -59,7 +58,12 @@ _ani_backend_streaming_get_frame(default_ani_info *ani_info)
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       idx = ((int)(ani_info->frame_idx / SMOOTH_FRAME)) % ani_info->num_key_frames;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
        idx2 = (idx + 1) % ani_info->num_key_frames;
 
        key_frame = &ani_info->frames[idx];
@@ -71,7 +75,7 @@ _ani_backend_streaming_get_frame(default_ani_info *ani_info)
                free(frame);
                return NULL;
        }
-       div = (double)(ani_info->frame_idx % SMOOTH_FRAME) / (double)SMOOTH_FRAME;
+       div = (double)(ani_info->frame_idx) / (double)ani_info->frame_max;
        r = g = b = r2 = g2 = b2 = 0x0;
        for (int i = 0; i < key_frame->num_led; i++)
        {
@@ -84,11 +88,12 @@ _ani_backend_streaming_get_frame(default_ani_info *ani_info)
                frame->leds[i].color = (r3 << 16) + (g3 << 8) + (b3);
        }
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= (ani_info->num_key_frames * SMOOTH_FRAME))
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -175,6 +180,10 @@ _ani_streaming_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_streaming_frame_cb, info->interval / 1000.0);
        if (!ret)
        {
index 90b3b4b..058b114 100644 (file)
@@ -49,7 +49,6 @@ _ani_backend_timeout_free_frame(default_frame_info_t *frame)
 static default_frame_info_t *
 _ani_backend_timeout_get_frame(default_ani_info *ani_info)
 {
-#define SMOOTH_FRAME 15
        default_frame_info_t *frame, *key_frame, *key_frame2;
        int idx, idx2;
        unsigned int r, g, b, r2, g2, b2;
@@ -59,7 +58,12 @@ _ani_backend_timeout_get_frame(default_ani_info *ani_info)
        frame = (default_frame_info_t *)calloc(sizeof(default_frame_info_t), 1);
        if (!frame) return NULL;
 
-       idx = ((int)(ani_info->frame_idx / SMOOTH_FRAME)) % ani_info->num_key_frames;
+       if (ani_info->frame_idx == 0)
+       {
+               ani_info->frame_max = (unsigned int)(ani_info->frames[ani_info->key_frame_cur].frame_duration / ani_info->interval);
+       }
+
+       idx = ani_info->key_frame_cur;
        idx2 = (idx + 1) % ani_info->num_key_frames;
 
        key_frame = &ani_info->frames[idx];
@@ -71,7 +75,7 @@ _ani_backend_timeout_get_frame(default_ani_info *ani_info)
                free(frame);
                return NULL;
        }
-       div = (double)(ani_info->frame_idx % SMOOTH_FRAME) / (double)SMOOTH_FRAME;
+       div = (double)(ani_info->frame_idx) / (double)ani_info->frame_max;
        r = g = b = r2 = g2 = b2 = 0x0;
        for (int i = 0; i < key_frame->num_led; i++)
        {
@@ -84,11 +88,12 @@ _ani_backend_timeout_get_frame(default_ani_info *ani_info)
                frame->leds[i].color = (r3 << 16) + (g3 << 8) + (b3);
        }
        ani_info->frame_idx++;
-       if (ani_info->frame_idx >= (ani_info->num_key_frames * SMOOTH_FRAME))
+       if (ani_info->frame_idx >= ani_info->frame_max)
        {
-               if (ani_info->repeat >= 0)
-                       ani_info->repeat_cur++;
                ani_info->frame_idx = 0;
+               ani_info->key_frame_cur = (ani_info->key_frame_cur + 1) % ani_info->num_key_frames;
+               if (ani_info->repeat >= 0 && ani_info->key_frame_cur == 0)
+                       ani_info->repeat_cur++;
        }
 
        return frame;
@@ -175,6 +180,10 @@ _ani_timeout_start(pui_ani_t *ani, int repeat)
        if (repeat == 0) info->repeat = 1;
        else info->repeat = repeat;
 
+       info->key_frame_cur = 0;
+       info->frame_idx = 0;
+       info->repeat_cur = 0;
+
        ret = pui_backend_ani_add_frame_cb(ani, _ani_backend_timeout_frame_cb, info->interval / 1000.0);
        if (!ret)
        {