default_backend: implements frame_duration to proceed each frame at a different speed
[platform/core/uifw/libpui.git] / backends / default_backend.h
1 /*
2  * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial
14  * portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  */
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <PUI_backend.h>
29
30 #include <json-c/json.h>
31 #include <dirent.h>
32 #include <errno.h>
33 #include <Eina.h>
34 #include <config.h>
35 #include <Ecore.h>
36 //#include <cmath.h>
37
38 #define ANI_COLLECTION_DIR "/usr/share/pui/"
39 #define MAX_STR 1024
40
41 #ifndef PI
42 #define PI 3.1415926545
43 #endif
44
45 #define LED_MASK_RED   0xFF0000
46 #define LED_MASK_GREEN 0x00FF00
47 #define LED_MASK_BLUE  0x0000FF
48
49 #define ERROR_CHECK(exp, action, fmt, ...) \
50         do { \
51                 if (!(exp)) \
52                 { \
53                         printf(fmt, ##__VA_ARGS__);     \
54                         action; \
55                 } \
56         } while (0)
57
58 typedef enum
59 {
60         None,
61         Linear,
62         EaseInSine,
63         EaseOutSine,
64         EaseInQuart,
65         EaseOutQuart
66 } pui_effect_func;
67
68 typedef struct _default_ani_info default_ani_info;
69 typedef struct _default_frame_info_t default_frame_info_t;
70 typedef struct _default_led_info_t default_led_info_t;
71
72 struct _default_ani_info
73 {
74         pui_id id;
75         pui_ani_status status;
76         pui_ani_control_buffer *buffer;
77         int repeat;
78
79         unsigned int num_key_frames;
80         default_frame_info_t *frames;
81         int interval;
82         pui_effect_func effect_func;
83
84         unsigned int repeat_cur;
85         unsigned int frame_idx;
86         unsigned int frame_max;
87         unsigned int key_frame_cur;
88 };
89
90 struct _default_frame_info_t
91 {
92         default_led_info_t *leds;
93         int num_led;
94         int frame_duration;
95 };
96
97 struct _default_led_info_t
98 {
99         unsigned int color;
100 };
101
102 void pui_default_backend_ani_listening_func_set(pui_backend_ani_func *func);
103 void pui_default_backend_ani_speaking_func_set(pui_backend_ani_func *func);
104 void pui_default_backend_ani_processing_func_set(pui_backend_ani_func *func);
105 void pui_default_backend_ani_streaming_func_set(pui_backend_ani_func *func);
106 void pui_default_backend_ani_timeout_func_set(pui_backend_ani_func *func);
107 void pui_default_backend_ani_system_processing_func_set(pui_backend_ani_func *func);
108 void pui_default_backend_ani_normal_func_set(pui_backend_ani_func *func);
109 void pui_default_backend_ani_emergency_func_set(pui_backend_ani_func *func);
110 void pui_default_backend_ani_easysetup_func_set(pui_backend_ani_func *func);
111 void pui_default_backend_ani_swupdatedone_func_set(pui_backend_ani_func *func);
112 void pui_default_backend_ani_micoff_func_set(pui_backend_ani_func *func);
113 void pui_default_backend_ani_networkerror_func_set(pui_backend_ani_func *func);
114 void pui_default_backend_ani_error_func_set(pui_backend_ani_func *func);
115 void pui_default_backend_ani_alarm_func_set(pui_backend_ani_func *func);
116 void pui_default_backend_ani_connected_func_set(pui_backend_ani_func *func);
117 void pui_default_backend_ani_pairing_func_set(pui_backend_ani_func *func);