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)
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;
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)
{
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;
}
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;
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)
{
//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);
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
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;
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++)
{
}
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;
}
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;
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)
{
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;
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;
for (int i = 0; i < key_frame->num_led; i++)
{
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;
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)
{
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;
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)
{
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)
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;
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)
{
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;
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;
for (int i = 0; i < key_frame->num_led; i++)
{
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;
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)
{
{"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"}
+ ]
}
]
}
"frame": [
{
"frame_id": 1,
+ "frame_duration": 480,
"led": [
{"id": 1, "color": "FFFFFF"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 2,
+ "frame_duration": 400,
"led": [
{"id": 1, "color": "000000"},
{"id": 2, "color": "FFFFFF"},
},
{
"frame_id": 3,
+ "frame_duration": 600,
"led": [
{"id": 1, "color": "000000"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 4,
+ "frame_duration": 480,
"led": [
{"id": 1, "color": "000000"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 5,
+ "frame_duration": 400,
"led": [
{"id": 1, "color": "FFFFFF"},
{"id": 2, "color": "000000"},
},
{
"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"}
+ ]
+ },
]
}
{
"type": "notification/emergency",
- "interval": 30,
+ "interval": 400,
"frame": [
{
"frame_id": 1,
+ "frame_duration": 1200,
"led": [
{"id": 1, "color": "FF0000"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 2,
+ "frame_duration": 1200,
"led": [
{"id": 1, "color": "000000"},
{"id": 2, "color": "000000"},
{"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"}
+ ]
}
]
}
"frame": [
{
"frame_id": 1,
+ "frame_duration": 500,
"led": [
{"id": 1, "color": "000000"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 2,
+ "frame_duration": 500,
"led": [
{"id": 1, "color": "000000"},
{"id": 2, "color": "000000"},
"frame": [
{
"frame_id": 1,
+ "frame_duration": 270,
"led": [
{"id": 1, "color": "000022"},
{"id": 2, "color": "000022"},
},
{
"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"}
+ ]
+ },
]
}
"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"},
},
{
"frame_id": 3,
+ "frame_duration": 120,
"led": [
{"id": 1, "color": "000000"},
{"id": 2, "color": "000000"},
"frame": [
{
"frame_id": 1,
+ "frame_duration": 270,
"led": [
{"id": 1, "color": "222222"},
{"id": 2, "color": "222222"},
},
{
"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"}
+ ]
+ }
]
}
"frame": [
{
"frame_id": 1,
+ "frame_duration": 210,
"led": [
{"id": 1, "color": "ffffff"},
{"id": 2, "color": "000000"},
},
{
"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"}
+ ]
+ }
]
}
"frame": [
{
"frame_id": 1,
+ "frame_duration": 120,
"led": [
{"id": 1, "color": "ffffff"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 2,
+ "frame_duration": 120,
"led": [
{"id": 1, "color": "444444"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 3,
+ "frame_duration": 570,
"led": [
{"id": 1, "color": "ffffff"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 4,
+ "frame_duration": 1200,
"led": [
{"id": 1, "color": "ffffff"},
{"id": 2, "color": "000000"},
},
{
"frame_id": 5,
+ "frame_duration": 30,
"led": [
{"id": 1, "color": "000000"},
{"id": 2, "color": "000000"},
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;
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;
for (int i = 0; i < key_frame->num_led; i++)
{
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;
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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;
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;
for (int i = 0; i < key_frame->num_led; i++)
{
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;
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)
{
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;
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;
for (int i = 0; i < key_frame->num_led; i++)
{
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;
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)
{
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;
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;
for (int i = 0; i < key_frame->num_led; i++)
{
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;
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)
{