From 5af101a1eb01249fa1aa67047e53557aa6da4fd4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 15 May 2019 06:15:12 +0200 Subject: [PATCH] add inline anim set functions --- src/lv_core/lv_obj.c | 2 +- src/lv_core/lv_style.c | 2 +- src/lv_core/lv_style.h | 63 ++++++++++++++++++++++++++++++++ src/lv_misc/lv_anim.c | 2 +- src/lv_misc/lv_anim.h | 83 +++++++++++++++++++++++++++++++++++++++++- 5 files changed, 148 insertions(+), 4 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8ef301738..7766d2862 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -90,7 +90,7 @@ void lv_init(void) lv_font_init(); #if LV_USE_ANIMATION - lv_anim_init(); + lv_anim_core_init(); #endif #if LV_USE_GROUP diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index ea6b3bb59..894326e9b 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -318,7 +318,7 @@ void * lv_style_anim_create(lv_style_anim_t * anim) a.playback_pause = anim->playback_pause; a.repeat = anim->repeat; a.repeat_pause = anim->repeat_pause; - + a.user_data = anim->user_data; lv_anim_create(&a); return dsc; diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 4f4ac19b4..05d63331f 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -147,6 +147,69 @@ a.ready_cb = NULL; a.user_data = NULL; lv_style_anim_create(&a); */ + + +static inline void lv_style_anim_init(lv_style_anim_t * a) +{ + memset(a, 0, sizeof(lv_style_anim_t)); +} + +static inline void lv_style_anim_set_styles(lv_style_anim_t * a, lv_style_t * to_anim, const lv_style_t * start, const lv_style_t * end) +{ + a->style_anim = to_anim; + a->style_start = start; + a->style_end = end; +} + +static inline void lv_style_anim_set_time(lv_style_anim_t * a, uint16_t duration, uint16_t delay) +{ + a->time = duration; + a->act_time = -delay; +} + +static inline void lv_style_anim_set_ready_cb(lv_style_anim_t * a, lv_anim_ready_cb_t ready_cb) +{ + a->ready_cb = ready_cb; +} + +static inline void lv_style_anim_set_playback(lv_style_anim_t * a, uint16_t wait_time) +{ + a->playback = 1; + a->playback_pause = wait_time; +} + +static inline void lv_style_anim_clear_playback(lv_style_anim_t * a) +{ + a->playback = 0; +} + +static inline void lv_style_anim_set_repeat(lv_style_anim_t * a, uint16_t wait_time) +{ + a->repeat = 1; + a->repeat_pause = wait_time; +} + +static inline void lv_style_anim_clear_repeat(lv_style_anim_t * a) +{ + a->repeat = 0; +} + +static inline void lv_style_anim_set_user_data(lv_style_anim_t * a, lv_anim_user_data_t user_data) +{ + memcpy(&a->user_data, &user_data, sizeof(user_data)); +} + +static inline lv_anim_user_data_t lv_style_anim_get_user_data(lv_style_anim_t * a) +{ + return a->user_data; +} + +static inline lv_anim_user_data_t * lv_style_anim_get_user_data_ptr(lv_style_anim_t * a) +{ + return &a->user_data; +} + + #endif /********************** diff --git a/src/lv_misc/lv_anim.c b/src/lv_misc/lv_anim.c index ef2d6696c..24d158325 100644 --- a/src/lv_misc/lv_anim.c +++ b/src/lv_misc/lv_anim.c @@ -53,7 +53,7 @@ static bool anim_list_changed; /** * Init. the animation module */ -void lv_anim_init(void) +void lv_anim_core_init(void) { lv_ll_init(&LV_GC_ROOT(_lv_anim_ll), sizeof(lv_anim_t)); last_task_run = lv_tick_get(); diff --git a/src/lv_misc/lv_anim.h b/src/lv_misc/lv_anim.h index 95444d60b..393a7c6fa 100644 --- a/src/lv_misc/lv_anim.h +++ b/src/lv_misc/lv_anim.h @@ -98,7 +98,88 @@ lv_anim_create(&a); /** * Init. the animation module */ -void lv_anim_init(void); +void lv_anim_core_init(void); + + +/** + * Initialize an animation variable + * @param a pointer to animation + */ +static inline void lv_anim_init(lv_anim_t * a) +{ + memset(a, 0, sizeof(lv_anim_t)); +} + + +static inline void lv_anim_set_var(lv_anim_t * a, void * var) +{ + a->var = var; +} + +static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, uint16_t delay) +{ + a->time = duration; + a->act_time = -delay; +} + +static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_anim_value_t end) +{ + a->start = start; + a->end = end; +} + +static inline void lv_anim_set_exec_cb(lv_anim_t * a, lv_anim_exec_cb_t exec_cb) +{ + a->exec_cb = exec_cb; +} + +static inline void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb) +{ + a->path_cb = path_cb; +} + +static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_cb) +{ + a->ready_cb = ready_cb; +} + +static inline void lv_anim_set_playback(lv_anim_t * a, uint16_t wait_time) +{ + a->playback = 1; + a->playback_pause = wait_time; +} + +static inline void lv_anim_clear_playback(lv_anim_t * a) +{ + a->playback = 0; +} + +static inline void lv_anim_set_repeat(lv_anim_t * a, uint16_t wait_time) +{ + a->repeat = 1; + a->repeat_pause = wait_time; +} + +static inline void lv_anim_clear_repeat(lv_anim_t * a) +{ + a->repeat = 0; +} + +static inline void lv_anim_set_user_data(lv_anim_t * a, lv_anim_user_data_t user_data) +{ + memcpy(&a->user_data, &user_data, sizeof(user_data)); +} + +static inline lv_anim_user_data_t lv_anim_get_user_data(lv_anim_t * a) +{ + return a->user_data; +} + +static inline lv_anim_user_data_t * lv_anim_get_user_data_ptr(lv_anim_t * a) +{ + return &a->user_data; +} + /** * Create an animation