Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_misc/lv_anim.h
1476 views
1
/**
2
* @file anim.h
3
*
4
*/
5
6
#ifndef ANIM_H
7
#define ANIM_H
8
9
#ifdef __cplusplus
10
extern "C" {
11
#endif
12
13
14
/*********************
15
* INCLUDES
16
*********************/
17
#ifdef LV_CONF_INCLUDE_SIMPLE
18
#include "lv_conf.h"
19
#else
20
#include "../../lv_conf.h"
21
#endif
22
23
#if USE_LV_ANIMATION
24
25
#include <stdint.h>
26
27
/*********************
28
* DEFINES
29
*********************/
30
31
/**********************
32
* TYPEDEFS
33
**********************/
34
35
struct _lv_anim_t;
36
37
typedef int32_t(*lv_anim_path_t)(const struct _lv_anim_t*);
38
39
typedef void (*lv_anim_fp_t)(void *, int32_t);
40
typedef void (*lv_anim_cb_t)(void *);
41
42
typedef struct _lv_anim_t
43
{
44
void * var; /*Variable to animate*/
45
lv_anim_fp_t fp; /*Animator function*/
46
lv_anim_cb_t end_cb; /*Call it when the animation is ready*/
47
lv_anim_path_t path; /*An array with the steps of animations*/
48
int32_t start; /*Start value*/
49
int32_t end; /*End value*/
50
uint16_t time; /*Animation time in ms*/
51
int16_t act_time; /*Current time in animation. Set to negative to make delay.*/
52
uint16_t playback_pause; /*Wait before play back*/
53
uint16_t repeat_pause; /*Wait before repeat*/
54
uint8_t playback :1; /*When the animation is ready play it back*/
55
uint8_t repeat :1; /*Repeat the animation infinitely*/
56
/*Animation system use these - user shouldn't set*/
57
uint8_t playback_now :1; /*Play back is in progress*/
58
uint32_t has_run :1; /*Indicates the animation has run it this round*/
59
} lv_anim_t;
60
61
/*Example initialization
62
lv_anim_t a;
63
a.var = obj;
64
a.start = lv_obj_get_height(obj);
65
a.end = new_height;
66
a.fp = (lv_anim_fp_t)lv_obj_set_height;
67
a.path = lv_anim_path_linear;
68
a.end_cb = NULL;
69
a.act_time = 0;
70
a.time = 200;
71
a.playback = 0;
72
a.playback_pause = 0;
73
a.repeat = 0;
74
a.repeat_pause = 0;
75
lv_anim_create(&a);
76
*/
77
/**********************
78
* GLOBAL PROTOTYPES
79
**********************/
80
81
/**
82
* Init. the animation module
83
*/
84
void lv_anim_init(void);
85
86
/**
87
* Create an animation
88
* @param anim_p an initialized 'anim_t' variable. Not required after call.
89
*/
90
void lv_anim_create(lv_anim_t * anim_p);
91
92
/**
93
* Delete an animation for a variable with a given animatior function
94
* @param var pointer to variable
95
* @param fp a function pointer which is animating 'var',
96
* or NULL to ignore it and delete all animation with 'var
97
* @return true: at least 1 animation is deleted, false: no animation is deleted
98
*/
99
bool lv_anim_del(void * var, lv_anim_fp_t fp);
100
101
/**
102
* Get the number of currently running animations
103
* @return the number of running animations
104
*/
105
uint16_t lv_anim_count_running(void);
106
107
/**
108
* Calculate the time of an animation with a given speed and the start and end values
109
* @param speed speed of animation in unit/sec
110
* @param start start value of the animation
111
* @param end end value of the animation
112
* @return the required time [ms] for the animation with the given parameters
113
*/
114
uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end);
115
116
/**
117
* Calculate the current value of an animation applying linear characteristic
118
* @param a pointer to an animation
119
* @return the current value to set
120
*/
121
int32_t lv_anim_path_linear(const lv_anim_t *a);
122
123
/**
124
* Calculate the current value of an animation slowing down the start phase
125
* @param a pointer to an animation
126
* @return the current value to set
127
*/
128
int32_t lv_anim_path_ease_in(const lv_anim_t * a);
129
130
/**
131
* Calculate the current value of an animation slowing down the end phase
132
* @param a pointer to an animation
133
* @return the current value to set
134
*/
135
int32_t lv_anim_path_ease_out(const lv_anim_t * a);
136
137
/**
138
* Calculate the current value of an animation applying an "S" characteristic (cosine)
139
* @param a pointer to an animation
140
* @return the current value to set
141
*/
142
int32_t lv_anim_path_ease_in_out(const lv_anim_t *a);
143
144
/**
145
* Calculate the current value of an animation with overshoot at the end
146
* @param a pointer to an animation
147
* @return the current value to set
148
*/
149
int32_t lv_anim_path_overshoot(const lv_anim_t * a);
150
151
/**
152
* Calculate the current value of an animation with 3 bounces
153
* @param a pointer to an animation
154
* @return the current value to set
155
*/
156
int32_t lv_anim_path_bounce(const lv_anim_t * a);
157
158
/**
159
* Calculate the current value of an animation applying step characteristic.
160
* (Set end value on the end of the animation)
161
* @param a pointer to an animation
162
* @return the current value to set
163
*/
164
int32_t lv_anim_path_step(const lv_anim_t *a);
165
/**********************
166
* MACROS
167
**********************/
168
169
#endif /*USE_LV_ANIMATION == 0*/
170
171
#ifdef __cplusplus
172
} /* extern "C" */
173
#endif
174
175
#endif /*LV_ANIM_H*/
176
177
178