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 15e0e2babdd9226f5a6e9c7559005282a62caea0..0dbda8d3f1dae6f47a0ab3d52c7b80a353569f5c 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 a272edab93ce6b820b205dfc182ad37a43d8fb90..b628e8e2f9fb54a49784de3f78b5a08776095431 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 bc13c94ee200f6dbd76d0ceb4a2c4e35931aebd4..8ed95cff0e037b0230fa17ca8a6ca607727e554d 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 a61bbe04ce49b160f3e6391546e11567da9c58a5..84210fc29fad0f14e43ac26d002c68104799c073 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 fbafe632fce28bd9ce88003a7e53daa4b0107aab..1324cc7c74601d0904ab393c60617ff74ef1fa21 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 6e4ea8d3954203e2ef40f87718e223cc7c3f083d..54cb04c88afe38ddac65334b8ab17b8020ce7377 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 82ed9a29f6a990f0409442f4029fe031968bf47c..a973d0cb484d8a4e3fc2312b3f6bff0c31642fef 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 218d43a2b0d4fc7082d396b3837a8e6c8bec57ed..f24c74c6a4b37545033031f11f2ff5c689bf12dc 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 6d5b2b3d1c5c1e6c37cf3aa58b4fd28c2080143e..9dc717368d0041878f12cf1a29d076113e7e95aa 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 686afa3194915a93d0fc4b0dd567783ab2931d57..8a78b3433e23e5e5b436a9fd747442ff4e543ef9 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 46a15b137000e5b1b17159505c897e683ee0a038..c0f1afeaa12fc33a67a296be08a2d35a8fe4bf92 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 8e8046fd2e64795d5b9dc7d3671899f6d55dbada..076cb510d2077b58640bd54819848232f663ff3a 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 75304deb1bd211a4904fa0e0c3534a8648327a52..6f2041b4800e1bcfcf73dd092bbd5cf205157ec2 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 acad93a260c6591af35e54139bf62ca5de7d4b07..ed8dc88f2887e6b8ed6418a8ee44da3fc50eedb8 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 72b92f216ace03fd389fac2f7902c05fd5abad15..cd7bf9fd46e24f802b138a3ab332c15aefcee959 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 a250ce1df4197ffbf4d80df031d975d637c97d08..851b419e8dcdb35a491b12b29a431e193446bbff 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 5f514a18ff214791b30c57a749e8994b262630fd..fbd98b0e900eb3ae625f51648e9df2f248861415 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 6328c51c0af140c65b38a5fba62a4a1228e90fc3..5fc13812bba4b11f1f7be3da1a19529778b91b91 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 fffbe5bca661d9f4a0053b21b32eb4813f0cdedb..3b7df7b419092b9927ff20f16de45d91e32bdf26 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 4449a4e2969f91d213f0356bc64efb590fced850..afc9ff4d3e250a2ff9c2950dd532f1ff95aa3793 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 2e746d55e29022bfd9e753ab28ed9a7010536dbd..b8b433efc3c7217177669a03a7ab6522b23e2da8 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 81c236cbe4779adb2d4086420b08ccc3aab27124..84f36acfb28dd94f340165d48aac76845943d61f 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 223c0bf92ba7d774e6d3b744b974ded181210e40..816e4d56e2feb7ef3fb62b4a3055397c5b26d11e 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 9385efc676f13adb96fea659265fce6b9185b9e8..93ecba2fbfdcb33607ef55a2f65eee7acd1cdba6 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 ffd58e8e297816ae58120a380050b437cd301488..b31ef8028ba95d1d1ca1992a2a4eeadfbd0953c3 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 fb489240886effbb022e1606c5a1b2f6e99504ef..fee1e8fe2ddd3202ff2cd06c89d44beb81efd8ed 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 502ec968cfb2ca852a8bcc1c37147293f9175d80..56fe4c3ebb369e59544dde92b19eb5e1e097d9d5 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 90b3b4bc5e0cb11729183098e5b8137cb8b206f2..058b114ee9c05710ae229f1261e9a00a8b58fbf0 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)
        {