* SOFTWARE.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <PUI_backend.h>
-
-#include <json-c/json.h>
-#include <dirent.h>
-#include <errno.h>
-#include <Eina.h>
-#include <Ecore.h>
-#include <config.h>
-
-#define ANI_COLLECTION_DIR "/usr/share/pui/"
-#define MAX_STR 1024
-
-#define ERROR_CHECK(exp, action, fmt, ...) \
- do { \
- if (!(exp)) \
- { \
- printf(fmt, ##__VA_ARGS__); \
- action; \
- } \
- } while (0)
+#include "default_backend.h"
pui_backend_ani_func *ani_func = NULL;
Eina_Hash *_animations_hash = NULL;
+pui_backend_ani_data *g_ani_data = NULL;
-typedef enum
-{
- None,
- Linear,
- EaseInSine,
- EaseOutSine,
- EaseInQuart,
- EaseOutQuart
-} pui_effect_func;
-
-typedef struct _default_ani_info default_ani_info;
-typedef struct _default_frame_info_t default_frame_info_t;
-typedef struct _default_led_info_t default_led_info_t;
-
-struct _default_ani_info
+#if 0
+static double
+_ani_backend_ease_function_get_intensity(pui_effect_func func, double interval)
{
- pui_id id;
- pui_ani_status status;
- pui_ani_control_buffer *buffer;
- unsigned int repeat;
-
- unsigned int key_frame_idx;
- unsigned int num_key_frames;
- default_frame_info_t *frames;
- int interval;
- pui_effect_func effect_func;
-};
+ double intensity = interval;
+ switch (func)
+ {
+ case None:
+ break;
+ case Linear:
+ break;
+ case EaseInSine:
+ intensity = 1 - cos(PI / 2 * interval);
+ break;
+ case EaseOutSine:
+ intensity = sin(PI / 2 * interval);
+ break;
+ case EaseInQuart:
+ intensity = interval * interval;
+ break;
+ case EaseOutQuart:
+ intensity = interval * (2 - interval);
+ break;
+ default:
+ break;
+ }
-struct _default_frame_info_t
-{
- default_led_info_t *leds;
- int num_led;
-};
+ return intensity;
+}
-struct _default_led_info_t
+static unsigned int
+_ani_backend_get_value(unsigned int end_frame, unsigned int start_frame, double interval)
{
- unsigned int color;
-};
+ double res = 0.0;
-pui_backend_ani_data *g_ani_data = NULL;
+ // interval: frame ratio between key frame to key frame
+ // end_frame and start_frame is key frame
+
+ res = (end_frame - start_frame) * interval + start_frame;
+
+ return res;
+}
+#endif
static pui_bool
_ani_backend_frame_cb(void *data, int serial)
for(int i = 0; i<12; i++)
{
buffer->ptr[4*i] = 0;
- buffer->ptr[4*i + 1] = (ani_info->frames[ani_info->key_frame_idx].leds[i].color & 0xFF0000) >> 16;//R
- buffer->ptr[4*i + 2] = (ani_info->frames[ani_info->key_frame_idx].leds[i].color & 0x00FF00) >> 8;//G
- buffer->ptr[4*i + 3] = ani_info->frames[ani_info->key_frame_idx].leds[i].color & 0x0000FF;//B
+ buffer->ptr[4*i + 1] = (ani_info->frames[ani_info->frame_idx].leds[i].color & LED_MASK_RED) >> 16;//R
+ buffer->ptr[4*i + 2] = (ani_info->frames[ani_info->frame_idx].leds[i].color & LED_MASK_GREEN) >> 8;//G
+ buffer->ptr[4*i + 3] = ani_info->frames[ani_info->frame_idx].leds[i].color & LED_MASK_BLUE;//B
}
e = pui_backend_ani_set_buffer(ani, buffer);
return NULL;
}
- /* Assign each function pointer that corresponds to the given id if needed. */
- ani_func->ani_start = _ani_start;
- ani_func->ani_stop = _ani_stop;
-
/* get animation info associate with the given id from animation collection */
ani_info = get_ani_info_from_ani_collection(id);
pui_err("Failed to allocate memory for pui backend ani data !\n");
goto err;
}
+
+ /* Assign each function pointer that corresponds to the given id if needed. */
+ if (!strncmp(ani_info->id, "processing", sizeof("processing")))
+ {
+ pui_default_backend_ani_processing_func_set(ani_func);
+ }
+ else if (!strncmp(ani_info->id, "emergency", sizeof("emergency")))
+ {
+ pui_default_backend_ani_emergency_func_set(ani_func);
+ }
+ else if (!strncmp(ani_info->id, "listening", sizeof("listening")))
+ {
+ pui_default_backend_ani_listening_func_set(ani_func);
+ }
+ else if (!strncmp(ani_info->id, "speaking", sizeof("speaking")))
+ {
+ pui_default_backend_ani_speaking_func_set(ani_func);
+ }
+ else if (!strncmp(ani_info->id, "streaming", sizeof("streaming")))
+ {
+ pui_default_backend_ani_streaming_func_set(ani_func);
+ }
+ else
+ {
+ pui_info("%s animation has no animation handler, using default handler\n", ani_info->id);
+ /* Assign each function pointer that corresponds to the given id if needed. */
+ ani_func->ani_start = _ani_start;
+ ani_func->ani_stop = _ani_stop;
+ }
ani_data->ani_func = ani_func;
ani_data->ani_info = (pui_backend_ani_info *)ani_info;