lv_anim.h
API reference for lv_anim.h
Functions
lv_anim_set_var
Set a variable to animate
void lv_anim_set_var(lv_anim_t *a, void *var)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
var | void * | pointer to a variable to animate |
lv_anim_set_exec_cb
Set a function to animate var
void lv_anim_set_exec_cb(lv_anim_t *a, lv_anim_exec_xcb_t exec_cb)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
exec_cb | lv_anim_exec_xcb_t | a function to execute during animation LVGL's built-in functions can be used. E.g. lv_obj_set_x |
lv_anim_set_duration
Set the duration of an animation
void lv_anim_set_duration(lv_anim_t *a, uint32_t duration)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
duration | uint32_t | duration of the animation in milliseconds |
lv_anim_set_delay
Set a delay before starting the animation
void lv_anim_set_delay(lv_anim_t *a, uint32_t delay)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
delay | uint32_t | delay before the animation in milliseconds |
lv_anim_set_values
Set the start and end values of an animation
void lv_anim_set_values(lv_anim_t *a, int32_t start, int32_t end)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
start | int32_t | the start value |
end | int32_t | the end value |
lv_anim_set_custom_exec_cb
Similar to lv_anim_set_exec_cb but lv_anim_custom_exec_cb_t receives lv_anim_t * as its first parameter instead of void *. This function might be used when LVGL is bound to other languages because it's more consistent to have lv_anim_t * as first parameter.
void lv_anim_set_custom_exec_cb(lv_anim_t *a, lv_anim_custom_exec_cb_t exec_cb)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
exec_cb | lv_anim_custom_exec_cb_t | a function to execute. |
lv_anim_set_path_cb
Set the path (curve) of the animation.
void lv_anim_set_path_cb(lv_anim_t *a, lv_anim_path_cb_t path_cb)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
path_cb | lv_anim_path_cb_t | a function to set the current value of the animation. |
lv_anim_set_start_cb
Set a function call when the animation really starts (considering delay)
void lv_anim_set_start_cb(lv_anim_t *a, lv_anim_start_cb_t start_cb)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
start_cb | lv_anim_start_cb_t | a function call when the animation starts |
lv_anim_set_get_value_cb
Set a function to use the current value of the variable and make start and end value relative to the returned current value.
void lv_anim_set_get_value_cb(lv_anim_t *a, lv_anim_get_value_cb_t get_value_cb)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
get_value_cb | lv_anim_get_value_cb_t | a function call when the animation starts |
lv_anim_set_completed_cb
Set a function call when the animation is completed
void lv_anim_set_completed_cb(lv_anim_t *a, lv_anim_completed_cb_t completed_cb)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
completed_cb | lv_anim_completed_cb_t | a function call when the animation is fully completed |
lv_anim_set_deleted_cb
Set a function call when the animation is deleted.
void lv_anim_set_deleted_cb(lv_anim_t *a, lv_anim_deleted_cb_t deleted_cb)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
deleted_cb | lv_anim_deleted_cb_t | a function call when the animation is deleted |
lv_anim_set_reverse_duration
Make the animation to play back to when the forward direction is ready
void lv_anim_set_reverse_duration(lv_anim_t *a, uint32_t duration)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
duration | uint32_t | duration of playback animation in milliseconds. 0: disable playback |
lv_anim_set_reverse_time
Legacy lv_anim_set_reverse_time API will be removed soon, use lv_anim_set_reverse_duration instead.
void lv_anim_set_reverse_time(lv_anim_t *a, uint32_t duration)| Name | Type |
|---|---|
a | lv_anim_t * |
duration | uint32_t |
lv_anim_set_reverse_delay
Make the animation to play back to when the forward direction is ready
void lv_anim_set_reverse_delay(lv_anim_t *a, uint32_t delay)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
delay | uint32_t | delay in milliseconds before starting the playback animation. |
lv_anim_set_repeat_count
Make the animation repeat itself.
void lv_anim_set_repeat_count(lv_anim_t *a, uint32_t cnt)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
cnt | uint32_t | repeat count or LV_ANIM_REPEAT_INFINITE for infinite repetition. 0: to disable repetition. |
lv_anim_set_repeat_delay
Set a delay before repeating the animation.
void lv_anim_set_repeat_delay(lv_anim_t *a, uint32_t delay)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
delay | uint32_t | delay in milliseconds before repeating the animation. |
lv_anim_set_early_apply
Set a whether the animation's should be applied immediately or only when the delay expired.
void lv_anim_set_early_apply(lv_anim_t *a, bool en)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
en | bool | true: apply the start value immediately in lv_anim_start; false: apply the start value only when delay ms is elapsed and the animations really starts |
lv_anim_set_user_data
Set the custom user data field of the animation.
void lv_anim_set_user_data(lv_anim_t *a, void *user_data)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
user_data | void * | pointer to the new user_data. |
lv_anim_set_bezier3_param
Set parameter for cubic bezier path
void lv_anim_set_bezier3_param(lv_anim_t *a, int16_t x1, int16_t y1, int16_t x2, int16_t y2)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to an initialized lv_anim_t variable |
x1 | int16_t | first control point X |
y1 | int16_t | first control point Y |
x2 | int16_t | second control point X |
y2 | int16_t | second control point Y |
lv_anim_set_external_data
Associates external user data with an animation instance.
Attaches arbitrary user-defined data to an LVGL animation object along with an optional destructor callback that will be automatically invoked when the animation completes or is deleted, enabling proper resource cleanup.
void lv_anim_set_external_data(lv_anim_t *anim, void *data, void(*free_cb)(void *data))| Name | Type | Description |
|---|---|---|
anim | lv_anim_t * | Pointer to the animation object to configure |
data | void * | User-defined data pointer to associate |
free_cb | void(*)(void *data) | Cleanup callback that receives ext_data when: - Animation completes naturally - Animation is deleted prematurely - New data replaces current association NULL indicates no cleanup required |
Structs
lv_anim_bezier3_para_t
Parameter used when path is custom_bezier
_lv_anim_t
Describes an animation
| Member | Type | Description |
|---|---|---|
ext_data | lv_ext_data_t | |
var | void * | Variable (Widget or other user-provided object) to animate |
exec_cb | lv_anim_exec_xcb_t | Function to execute to animate |
custom_exec_cb | lv_anim_custom_exec_cb_t | Function to execute to animate, same purpose as exec_cb but different parameters |
start_cb | lv_anim_start_cb_t | Call it when animation is starts (considering delay) |
completed_cb | lv_anim_completed_cb_t | Call it when animation is fully completed |
deleted_cb | lv_anim_deleted_cb_t | Call it when animation is deleted |
get_value_cb | lv_anim_get_value_cb_t | Get current value in relative mode |
user_data | void * | Custom user data |
path_cb | lv_anim_path_cb_t | Provides path (curve) of animation |
start_value | int32_t | Start value |
current_value | int32_t | Current value |
end_value | int32_t | End value |
duration | int32_t | Animation duration in ms |
act_time | int32_t | Ms elapsed since animation started. Set to negative to make delay. |
reverse_delay | uint32_t | Wait (in ms) after forward play ends and before reverse play begins. |
reverse_duration | uint32_t | Reverse animation duration in ms |
repeat_delay | uint32_t | Wait before repeating |
repeat_cnt | uint32_t | Repeat count for animation |
parameter | union _lv_anim_t::_lv_anim_path_para_t | |
last_timer_run | uint32_t | |
pause_time | uint32_t | The time when the animation was paused |
pause_duration | uint32_t | The amount of the time the animation must stay paused for |
is_paused | uint8_t | Indicates that the animation is paused |
reverse_play_in_progress | uint8_t | Reverse play is in progress |
run_round | uint8_t | When not equal to global.anim_state.anim_run_round (which toggles each time animation timer executes), indicates this animation needs to be updated. |
start_cb_called | uint8_t | Indicates that start_cb was already called |
early_apply | uint8_t | 1: Apply start value immediately even is there is a delay |
_lv_anim_t::_lv_anim_path_para_t
| Member | Type | Description |
|---|---|---|
bezier3 | lv_anim_bezier3_para_t | Parameter used when path is custom_bezier |
Typedefs
lv_anim_enable_t
typedef bool lv_anim_enable_tUsed by 19 functions
lv_obj_scroll_by— paramanim_enlv_obj_scroll_by_bounded— paramanim_enlv_obj_scroll_to— paramanim_enlv_obj_scroll_to_x— paramanim_enlv_obj_scroll_to_y— paramanim_enlv_obj_scroll_to_view— paramanim_enlv_obj_scroll_to_view_recursive— paramanim_enlv_obj_update_snap— paramanim_enlv_obj_readjust_scroll— paramanim_enlv_gridnav_set_focused— paramanim_enlv_bar_set_value— paramanimlv_bar_set_start_value— paramanimlv_roller_set_selected— paramanimlv_roller_set_selected_str— paramanimlv_slider_set_value— paramanimlv_slider_set_start_value— paramanimlv_tabview_set_active— paramanim_enlv_tileview_set_tile— paramanim_enlv_tileview_set_tile_by_index— paramanim_en
lv_anim_path_cb_t
typedef int32_t(* lv_anim_path_cb_t) (const lv_anim_t *)Get the current value during an animation
Used by 2 functions
lv_anim_set_path_cb— parampath_cblv_style_transition_dsc_init— parampath_cb
lv_anim_exec_xcb_t
typedef void(* lv_anim_exec_xcb_t) (void *, int32_t)Generic prototype of "animator" functions. First parameter is the variable to animate. Second parameter is the value to set. Compatible with lv_xxx_set_yyy(obj, value) functions The x in _xcb_t means it's not a fully generic prototype because it doesn't receive lv_anim_t * as its first argument
Used by 3 functions
lv_anim_set_exec_cb— paramexec_cblv_anim_delete— paramexec_cblv_anim_get— paramexec_cb
lv_anim_custom_exec_cb_t
typedef void(* lv_anim_custom_exec_cb_t) (lv_anim_t *, int32_t)Same as lv_anim_exec_xcb_t but receives lv_anim_t * as the first parameter. It's more consistent but less convenient. Might be used by binding generator functions.
Used by 3 functions
lv_anim_set_custom_exec_cb— paramexec_cblv_anim_custom_delete— paramexec_cblv_anim_custom_get— paramexec_cb
lv_anim_completed_cb_t
typedef void(* lv_anim_completed_cb_t) (lv_anim_t *)Callback to call when the animation is ready
Used by 2 functions
lv_anim_set_completed_cb— paramcompleted_cblv_animimg_set_completed_cb— paramcompleted_cb
lv_anim_start_cb_t
typedef void(* lv_anim_start_cb_t) (lv_anim_t *)Callback to call when the animation really stars (considering delay)
Used by 2 functions
lv_anim_set_start_cb— paramstart_cblv_animimg_set_start_cb— paramstart_cb
lv_anim_get_value_cb_t
typedef int32_t(* lv_anim_get_value_cb_t) (lv_anim_t *)Callback used when the animation values are relative to get the current value
Used by 1 function
lv_anim_set_get_value_cb— paramget_value_cb
lv_anim_deleted_cb_t
typedef void(* lv_anim_deleted_cb_t) (lv_anim_t *)Callback used when the animation is deleted
Used by 1 function
lv_anim_set_deleted_cb— paramdeleted_cb
Macros
LV_ANIM_REPEAT_INFINITE
#define LV_ANIM_REPEAT_INFINITE 0xFFFFFFFFLV_ANIM_PLAYTIME_INFINITE
#define LV_ANIM_PLAYTIME_INFINITE 0xFFFFFFFFLV_ANIM_PAUSE_FOREVER
#define LV_ANIM_PAUSE_FOREVER 0xFFFFFFFF_PARA
#define _PARA(a, x1, y1, x2, y2) \
((a)->parameter.bezier3 = \
(lv_anim_bezier3_para_t) { \
LV_BEZIER_VAL_FLOAT(x1), LV_BEZIER_VAL_FLOAT(y1), \
LV_BEZIER_VAL_FLOAT(x2), LV_BEZIER_VAL_FLOAT(y2) } \
)LV_ANIM_SET_EASE_IN_SINE
#define LV_ANIM_SET_EASE_IN_SINE(a) \
_PARA(a, 0.12, 0, 0.39, 0)LV_ANIM_SET_EASE_OUT_SINE
#define LV_ANIM_SET_EASE_OUT_SINE(a) \
_PARA(a, 0.61, 1, 0.88, 1)LV_ANIM_SET_EASE_IN_OUT_SINE
#define LV_ANIM_SET_EASE_IN_OUT_SINE(a) \
_PARA(a, 0.37, 0, 0.63, 1)LV_ANIM_SET_EASE_IN_QUAD
#define LV_ANIM_SET_EASE_IN_QUAD(a) \
_PARA(a, 0.11, 0, 0.5, 0)LV_ANIM_SET_EASE_OUT_QUAD
#define LV_ANIM_SET_EASE_OUT_QUAD(a) \
_PARA(a, 0.5, 1, 0.89, 1)LV_ANIM_SET_EASE_IN_OUT_QUAD
#define LV_ANIM_SET_EASE_IN_OUT_QUAD(a) \
_PARA(a, 0.45, 0, 0.55, 1)LV_ANIM_SET_EASE_IN_CUBIC
#define LV_ANIM_SET_EASE_IN_CUBIC(a) \
_PARA(a, 0.32, 0, 0.67, 0)LV_ANIM_SET_EASE_OUT_CUBIC
#define LV_ANIM_SET_EASE_OUT_CUBIC(a) \
_PARA(a, 0.33, 1, 0.68, 1)LV_ANIM_SET_EASE_IN_OUT_CUBIC
#define LV_ANIM_SET_EASE_IN_OUT_CUBIC(a) \
_PARA(a, 0.65, 0, 0.35, 1)LV_ANIM_SET_EASE_IN_QUART
#define LV_ANIM_SET_EASE_IN_QUART(a) \
_PARA(a, 0.5, 0, 0.75, 0)LV_ANIM_SET_EASE_OUT_QUART
#define LV_ANIM_SET_EASE_OUT_QUART(a) \
_PARA(a, 0.25, 1, 0.5, 1)LV_ANIM_SET_EASE_IN_OUT_QUART
#define LV_ANIM_SET_EASE_IN_OUT_QUART(a) \
_PARA(a, 0.76, 0, 0.24, 1)LV_ANIM_SET_EASE_IN_QUINT
#define LV_ANIM_SET_EASE_IN_QUINT(a) \
_PARA(a, 0.64, 0, 0.78, 0)LV_ANIM_SET_EASE_OUT_QUINT
#define LV_ANIM_SET_EASE_OUT_QUINT(a) \
_PARA(a, 0.22, 1, 0.36, 1)LV_ANIM_SET_EASE_IN_OUT_QUINT
#define LV_ANIM_SET_EASE_IN_OUT_QUINT(a) \
_PARA(a, 0.83, 0, 0.17, 1)LV_ANIM_SET_EASE_IN_EXPO
#define LV_ANIM_SET_EASE_IN_EXPO(a) \
_PARA(a, 0.7, 0, 0.84, 0)LV_ANIM_SET_EASE_OUT_EXPO
#define LV_ANIM_SET_EASE_OUT_EXPO(a) \
_PARA(a, 0.16, 1, 0.3, 1)LV_ANIM_SET_EASE_IN_OUT_EXPO
#define LV_ANIM_SET_EASE_IN_OUT_EXPO(a) \
_PARA(a, 0.87, 0, 0.13, 1)LV_ANIM_SET_EASE_IN_CIRC
#define LV_ANIM_SET_EASE_IN_CIRC(a) \
_PARA(a, 0.55, 0, 1, 0.45)LV_ANIM_SET_EASE_OUT_CIRC
#define LV_ANIM_SET_EASE_OUT_CIRC(a) \
_PARA(a, 0, 0.55, 0.45, 1)LV_ANIM_SET_EASE_IN_OUT_CIRC
#define LV_ANIM_SET_EASE_IN_OUT_CIRC(a) \
_PARA(a, 0.85, 0, 0.15, 1)LV_ANIM_SET_EASE_IN_BACK
#define LV_ANIM_SET_EASE_IN_BACK(a) \
_PARA(a, 0.36, 0, 0.66, -0.56)LV_ANIM_SET_EASE_OUT_BACK
#define LV_ANIM_SET_EASE_OUT_BACK(a) \
_PARA(a, 0.34, 1.56, 0.64, 1)LV_ANIM_SET_EASE_IN_OUT_BACK
#define LV_ANIM_SET_EASE_IN_OUT_BACK(a) \
_PARA(a, 0.68, -0.6, 0.32, 1.6)LV_ANIM_OFF
#define LV_ANIM_OFF falseCan be used to indicate if animations are enabled or disabled in a case
LV_ANIM_ON
#define LV_ANIM_ON trueDependencies
How is this guide?
Last updated on