anim: minor updates
This commit is contained in:
@@ -96,11 +96,7 @@ void lv_anim_create(lv_anim_t * a)
|
|||||||
memcpy(new_anim, a, sizeof(lv_anim_t));
|
memcpy(new_anim, a, sizeof(lv_anim_t));
|
||||||
|
|
||||||
/*Set the start value*/
|
/*Set the start value*/
|
||||||
if(new_anim->exec_cb != NULL) {
|
if(new_anim->exec_cb) new_anim->exec_cb(new_anim->var, new_anim->start);
|
||||||
/*Pass `new_anim` if `var` is not set*/
|
|
||||||
if(a->var) new_anim->exec_cb(new_anim->var, new_anim->start);
|
|
||||||
else new_anim->exec_cb(new_anim, new_anim->start);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Creating an animation changed the linked list.
|
/* Creating an animation changed the linked list.
|
||||||
* It's important if it happens in a ready callback. (see `anim_task`)*/
|
* It's important if it happens in a ready callback. (see `anim_task`)*/
|
||||||
@@ -410,14 +406,7 @@ static void anim_task(lv_task_t * param)
|
|||||||
new_value = a->path_cb(a);
|
new_value = a->path_cb(a);
|
||||||
|
|
||||||
/*Apply the calculated value*/
|
/*Apply the calculated value*/
|
||||||
if(a->exec_cb != NULL) {
|
if(a->exec_cb) a->exec_cb(a->var, new_value);
|
||||||
/*Pass `a` as first parameter if `var` is not set*/
|
|
||||||
if(a->var) {
|
|
||||||
a->exec_cb(a->var, new_value);
|
|
||||||
} else {
|
|
||||||
a->exec_cb(a, new_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*If the time is elapsed the animation is ready*/
|
/*If the time is elapsed the animation is ready*/
|
||||||
if(a->act_time >= a->time) {
|
if(a->act_time >= a->time) {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void lv_anim_init(lv_anim_t * a);
|
|||||||
* LittelvGL's built-in functions can be used.
|
* LittelvGL's built-in functions can be used.
|
||||||
* E.g. lv_obj_set_x
|
* E.g. lv_obj_set_x
|
||||||
*/
|
*/
|
||||||
static inline void lv_anim_set_var_and_cb(lv_anim_t * a, void * var, lv_anim_exec_cb_t exec_cb)
|
static inline void lv_anim_set_exec_cb(lv_anim_t * a, void * var, lv_anim_exec_cb_t exec_cb)
|
||||||
{
|
{
|
||||||
a->var = var;
|
a->var = var;
|
||||||
a->exec_cb = exec_cb;
|
a->exec_cb = exec_cb;
|
||||||
@@ -146,7 +146,7 @@ static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_a
|
|||||||
*/
|
*/
|
||||||
static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
|
static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb)
|
||||||
{
|
{
|
||||||
a->var = NULL;
|
a->var = a;
|
||||||
a->exec_cb = (lv_anim_exec_cb_t)exec_cb;
|
a->exec_cb = (lv_anim_exec_cb_t)exec_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user