mikroSDK Reference Manual
lv_anim.h
Go to the documentation of this file.
1
6#ifndef LV_ANIM_H
7#define LV_ANIM_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17
18#include <stdint.h>
19#include <stdbool.h>
20#include <stddef.h>
21
22/*********************
23 * DEFINES
24 *********************/
25
26#define LV_ANIM_REPEAT_INFINITE 0xFFFF
27#define LV_ANIM_PLAYTIME_INFINITE 0xFFFFFFFF
28
29LV_EXPORT_CONST_INT(LV_ANIM_REPEAT_INFINITE);
30LV_EXPORT_CONST_INT(LV_ANIM_PLAYTIME_INFINITE);
31
32/**********************
33 * TYPEDEFS
34 **********************/
35
37typedef enum {
38 LV_ANIM_OFF,
39 LV_ANIM_ON,
41
42struct _lv_anim_t;
43struct _lv_timer_t;
44
46typedef int32_t (*lv_anim_path_cb_t)(const struct _lv_anim_t *);
47
54typedef void (*lv_anim_exec_xcb_t)(void *, int32_t);
55
58typedef void (*lv_anim_custom_exec_cb_t)(struct _lv_anim_t *, int32_t);
59
61typedef void (*lv_anim_ready_cb_t)(struct _lv_anim_t *);
62
64typedef void (*lv_anim_start_cb_t)(struct _lv_anim_t *);
65
67typedef int32_t (*lv_anim_get_value_cb_t)(struct _lv_anim_t *);
68
70typedef void (*lv_anim_deleted_cb_t)(struct _lv_anim_t *);
71
73typedef struct _lv_anim_t {
74 void * var;
80#if LV_USE_USER_DATA
81 void * user_data;
82#endif
84 int32_t start_value;
85 int32_t current_value;
86 int32_t end_value;
87 int32_t time;
88 int32_t act_time;
89 uint32_t playback_delay;
90 uint32_t playback_time;
91 uint32_t repeat_delay;
92 uint16_t repeat_cnt;
93 uint8_t early_apply : 1;
95 /*Animation system use these - user shouldn't set*/
96 uint8_t playback_now : 1;
97 uint8_t run_round : 1;
98 uint8_t start_cb_called : 1;
100
101/**********************
102 * GLOBAL PROTOTYPES
103 **********************/
104
109
120
126static inline void lv_anim_set_var(lv_anim_t * a, void * var)
127{
128 a->var = var;
129}
130
138static inline void lv_anim_set_exec_cb(lv_anim_t * a, lv_anim_exec_xcb_t exec_cb)
139{
140 a->exec_cb = exec_cb;
141}
142
148static inline void lv_anim_set_time(lv_anim_t * a, uint32_t duration)
149{
150 a->time = duration;
151}
152
158static inline void lv_anim_set_delay(lv_anim_t * a, uint32_t delay)
159{
160 a->act_time = -(int32_t)(delay);
161}
162
169static inline void lv_anim_set_values(lv_anim_t * a, int32_t start, int32_t end)
170{
171 a->start_value = start;
172 a->current_value = start;
173 a->end_value = end;
174}
175
185static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
186{
187 a->var = a;
188 a->exec_cb = (lv_anim_exec_xcb_t)exec_cb;
189}
190
196static inline void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb)
197{
198 a->path_cb = path_cb;
199}
200
206static inline void lv_anim_set_start_cb(lv_anim_t * a, lv_anim_start_cb_t start_cb)
207{
208 a->start_cb = start_cb;
209}
210
217static inline void lv_anim_set_get_value_cb(lv_anim_t * a, lv_anim_get_value_cb_t get_value_cb)
218{
219 a->get_value_cb = get_value_cb;
220}
221
227static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_cb)
228{
229 a->ready_cb = ready_cb;
230}
231
237static inline void lv_anim_set_deleted_cb(lv_anim_t * a, lv_anim_deleted_cb_t deleted_cb)
238{
239 a->deleted_cb = deleted_cb;
240}
241
247static inline void lv_anim_set_playback_time(lv_anim_t * a, uint32_t time)
248{
249 a->playback_time = time;
250}
251
257static inline void lv_anim_set_playback_delay(lv_anim_t * a, uint32_t delay)
258{
259 a->playback_delay = delay;
260}
261
267static inline void lv_anim_set_repeat_count(lv_anim_t * a, uint16_t cnt)
268{
269 a->repeat_cnt = cnt;
270}
271
277static inline void lv_anim_set_repeat_delay(lv_anim_t * a, uint32_t delay)
278{
279 a->repeat_delay = delay;
280}
281
288static inline void lv_anim_set_early_apply(lv_anim_t * a, bool en)
289{
290 a->early_apply = en;
291}
292
298#if LV_USE_USER_DATA
299static inline void lv_anim_set_user_data(lv_anim_t * a, void * user_data)
300{
301 a->user_data = user_data;
302}
303#endif
304
311
317static inline uint32_t lv_anim_get_delay(lv_anim_t * a)
318{
319 return -a->act_time;
320}
321
328
334#if LV_USE_USER_DATA
335static inline void * lv_anim_get_user_data(lv_anim_t * a)
336{
337 return a->user_data;
338}
339#endif
340
348bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb);
349
354
362
368
380static inline bool lv_anim_custom_del(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
381{
382 return lv_anim_del(a ? a->var : NULL, (lv_anim_exec_xcb_t)exec_cb);
383}
384
394static inline lv_anim_t * lv_anim_custom_get(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
395{
396 return lv_anim_get(a ? a->var : NULL, (lv_anim_exec_xcb_t)exec_cb);
397}
398
404
412uint32_t lv_anim_speed_to_time(uint32_t speed, int32_t start, int32_t end);
413
421
428
435
442
449
456
463
470int32_t lv_anim_path_step(const lv_anim_t * a);
471
472/**********************
473 * GLOBAL VARIABLES
474 **********************/
475
476/**********************
477 * MACROS
478 **********************/
479
480#ifdef __cplusplus
481} /*extern "C"*/
482#endif
483
484#endif /*LV_ANIM_H*/
lv_anim_enable_t
Definition lv_anim.h:37
void lv_anim_refr_now(void)
void(* lv_anim_custom_exec_cb_t)(struct _lv_anim_t *, int32_t)
Definition lv_anim.h:58
int32_t(* lv_anim_path_cb_t)(const struct _lv_anim_t *)
Definition lv_anim.h:46
int32_t lv_anim_path_step(const lv_anim_t *a)
uint16_t lv_anim_count_running(void)
void lv_anim_del_all(void)
lv_anim_t * lv_anim_start(const lv_anim_t *a)
struct _lv_timer_t * lv_anim_get_timer(void)
void(* lv_anim_exec_xcb_t)(void *, int32_t)
Definition lv_anim.h:54
int32_t lv_anim_path_ease_out(const lv_anim_t *a)
struct _lv_anim_t lv_anim_t
int32_t lv_anim_path_ease_in(const lv_anim_t *a)
bool lv_anim_del(void *var, lv_anim_exec_xcb_t exec_cb)
int32_t lv_anim_path_ease_in_out(const lv_anim_t *a)
int32_t lv_anim_path_linear(const lv_anim_t *a)
void(* lv_anim_ready_cb_t)(struct _lv_anim_t *)
Definition lv_anim.h:61
int32_t(* lv_anim_get_value_cb_t)(struct _lv_anim_t *)
Definition lv_anim.h:67
void lv_anim_init(lv_anim_t *a)
uint32_t lv_anim_speed_to_time(uint32_t speed, int32_t start, int32_t end)
void(* lv_anim_deleted_cb_t)(struct _lv_anim_t *)
Definition lv_anim.h:70
int32_t lv_anim_path_bounce(const lv_anim_t *a)
int32_t lv_anim_path_overshoot(const lv_anim_t *a)
void(* lv_anim_start_cb_t)(struct _lv_anim_t *)
Definition lv_anim.h:64
uint32_t lv_anim_get_playtime(lv_anim_t *a)
void _lv_anim_core_init(void)
lv_anim_t * lv_anim_get(void *var, lv_anim_exec_xcb_t exec_cb)
Definition lv_anim.h:73
lv_anim_start_cb_t start_cb
Definition lv_anim.h:76
uint32_t repeat_delay
Definition lv_anim.h:91
uint8_t start_cb_called
Definition lv_anim.h:98
uint8_t early_apply
Definition lv_anim.h:93
uint8_t run_round
Definition lv_anim.h:97
int32_t time
Definition lv_anim.h:87
void * var
Definition lv_anim.h:74
uint16_t repeat_cnt
Definition lv_anim.h:92
lv_anim_deleted_cb_t deleted_cb
Definition lv_anim.h:78
int32_t current_value
Definition lv_anim.h:85
lv_anim_path_cb_t path_cb
Definition lv_anim.h:83
lv_anim_get_value_cb_t get_value_cb
Definition lv_anim.h:79
uint8_t playback_now
Definition lv_anim.h:96
uint32_t playback_delay
Definition lv_anim.h:89
uint32_t playback_time
Definition lv_anim.h:90
int32_t act_time
Definition lv_anim.h:88
lv_anim_ready_cb_t ready_cb
Definition lv_anim.h:77
int32_t end_value
Definition lv_anim.h:86
lv_anim_exec_xcb_t exec_cb
Definition lv_anim.h:75
int32_t start_value
Definition lv_anim.h:84
Definition lv_timer.h:44