LittlevGL  3.20.00.19
lv_anim.h
Go to the documentation of this file.
1 
6 #ifndef ANIM_H
7 #define ANIM_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  * INCLUDES
15  *********************/
16 #ifdef LV_CONF_INCLUDE_SIMPLE
17 #include "lv_conf.h"
18 #else
19 #include "../../../lv_conf.h"
20 #endif
21 
22 #include <stdint.h>
23 #include <stdbool.h>
24 #include <string.h>
25 
26 /*********************
27  * DEFINES
28  *********************/
29 
30 /**********************
31  * TYPEDEFS
32  **********************/
33 
35 enum {
38 };
39 
40 typedef uint8_t lv_anim_enable_t;
41 
43 typedef lv_coord_t lv_anim_value_t;
44 
45 #if LV_USE_ANIMATION
46 
47 struct _lv_anim_t;
48 
55 typedef void (*lv_anim_exec_xcb_t)(void *, lv_anim_value_t);
56 
59 typedef void (*lv_anim_custom_exec_cb_t)(struct _lv_anim_t *, lv_anim_value_t);
60 
62 typedef lv_anim_value_t (*lv_anim_path_cb_t)(const struct _lv_anim_t *);
63 
65 typedef void (*lv_anim_ready_cb_t)(struct _lv_anim_t *);
66 
68 typedef struct _lv_anim_t
69 {
70  void * var;
71  lv_anim_exec_xcb_t exec_cb;
72  lv_anim_path_cb_t path_cb;
73  lv_anim_ready_cb_t ready_cb;
74  int32_t start;
75  int32_t end;
76  uint16_t time;
77  int16_t act_time;
78  uint16_t playback_pause;
79  uint16_t repeat_pause;
80 #if LV_USE_USER_DATA
81  lv_anim_user_data_t user_data;
82 #endif
83 
84  uint8_t playback : 1;
85  uint8_t repeat : 1;
86  /*Animation system use these - user shouldn't set*/
87  uint8_t playback_now : 1;
88  uint32_t has_run : 1;
89 } lv_anim_t;
90 
91 
92 /**********************
93  * GLOBAL PROTOTYPES
94  **********************/
95 
99 void lv_anim_core_init(void);
100 
110 void lv_anim_init(lv_anim_t * a);
111 
120 static inline void lv_anim_set_exec_cb(lv_anim_t * a, void * var, lv_anim_exec_xcb_t exec_cb)
121 {
122  a->var = var;
123  a->exec_cb = exec_cb;
124 }
125 
132 static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, uint16_t delay)
133 {
134  a->time = duration;
135  a->act_time = -delay;
136 }
137 
144 static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_anim_value_t end)
145 {
146  a->start = start;
147  a->end = end;
148 }
149 
158 static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
159 {
160  a->var = a;
161  a->exec_cb = (lv_anim_exec_xcb_t)exec_cb;
162 }
163 
170 static inline void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb)
171 {
172  a->path_cb = path_cb;
173 }
174 
180 static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_cb)
181 {
182  a->ready_cb = ready_cb;
183 }
184 
190 static inline void lv_anim_set_playback(lv_anim_t * a, uint16_t wait_time)
191 {
192  a->playback = 1;
193  a->playback_pause = wait_time;
194 }
195 
200 static inline void lv_anim_clear_playback(lv_anim_t * a)
201 {
202  a->playback = 0;
203 }
204 
210 static inline void lv_anim_set_repeat(lv_anim_t * a, uint16_t wait_time)
211 {
212  a->repeat = 1;
213  a->repeat_pause = wait_time;
214 }
215 
220 static inline void lv_anim_clear_repeat(lv_anim_t * a)
221 {
222  a->repeat = 0;
223 }
224 
229 void lv_anim_create(lv_anim_t * a);
230 
238 bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb);
239 
251 static inline bool lv_anim_custom_del(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
252 {
253  return lv_anim_del(a->var, (lv_anim_exec_xcb_t)exec_cb);
254 }
255 
260 uint16_t lv_anim_count_running(void);
261 
269 uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end);
270 
276 lv_anim_value_t lv_anim_path_linear(const lv_anim_t * a);
277 
283 lv_anim_value_t lv_anim_path_ease_in(const lv_anim_t * a);
284 
290 lv_anim_value_t lv_anim_path_ease_out(const lv_anim_t * a);
291 
297 lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_t * a);
298 
304 lv_anim_value_t lv_anim_path_overshoot(const lv_anim_t * a);
305 
311 lv_anim_value_t lv_anim_path_bounce(const lv_anim_t * a);
312 
319 lv_anim_value_t lv_anim_path_step(const lv_anim_t * a);
320 
321 /**********************
322  * MACROS
323  **********************/
324 
325 #endif /*LV_USE_ANIMATION == 0*/
326 
327 #ifdef __cplusplus
328 } /* extern "C" */
329 #endif
330 
331 #endif /*LV_ANIM_H*/
Definition: lv_anim.h:37
lv_coord_t lv_anim_value_t
Definition: lv_anim.h:43
uint8_t lv_anim_enable_t
Definition: lv_anim.h:40
Definition: lv_anim.h:36
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale