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;
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];
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);
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;
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)
{