lv_timer.h
API reference for lv_timer.h
Functions
lv_timer_handler_set_resume_cb
Set the resume callback to the timer handler
void lv_timer_handler_set_resume_cb(lv_timer_handler_resume_cb_t cb, void *data)| Name | Type | Description |
|---|---|---|
cb | lv_timer_handler_resume_cb_t | the function to call when timer handler is resumed |
data | void * | pointer to a resume data May be NULL. |
lv_timer_set_cb
Set the callback to the timer (the function to call periodically)
void lv_timer_set_cb(lv_timer_t *timer, lv_timer_cb_t timer_cb)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a timer |
timer_cb | lv_timer_cb_t | the function to call periodically |
lv_timer_set_period
Set new period for a lv_timer
void lv_timer_set_period(lv_timer_t *timer, uint32_t period)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a lv_timer |
period | uint32_t | the new period |
lv_timer_set_repeat_count
Set the number of times a timer will repeat.
void lv_timer_set_repeat_count(lv_timer_t *timer, int32_t repeat_count)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a lv_timer. |
repeat_count | int32_t | -1 : infinity; 0 : stop ; n>0: residual times |
lv_timer_set_auto_delete
Set whether a lv_timer will be deleted automatically when it is called repeat_count times.
void lv_timer_set_auto_delete(lv_timer_t *timer, bool auto_delete)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a lv_timer. |
auto_delete | bool | true: auto delete; false: timer will be paused when it is called repeat_count times. |
lv_timer_set_user_data
Set custom parameter to the lv_timer.
void lv_timer_set_user_data(lv_timer_t *timer, void *user_data)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a lv_timer. |
user_data | void * | custom parameter May be NULL. |
lv_timer_set_external_data
Attaches external user data and destructor callback to a timer object.
Associates custom user data with an LVGL timer and specifies a destructor function that will be automatically invoked when the timer is deleted to properly clean up the associated resources.
void lv_timer_set_external_data(lv_timer_t *timer, void *data, void(*free_cb)(void *data))| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | Pointer to the timer object |
data | void * | User-defined data pointer to associate with the timer May be NULL. |
free_cb | void(*)(void *data) | Callback function for cleaning up ext_data when timer is deleted. Receives ext_data as parameter. May be NULL. When NULL no cleanup is performed. |
lv_timer_get_time_to_next
Calculate the time to the soonest LVGL timer.
uint32_t lv_timer_get_time_to_next(void)Returns: uint32_t — time till it needs to be run next timer (in ms)
lv_timer_get_idle
Get idle percentage
uint32_t lv_timer_get_idle(void)Returns: uint32_t — the lv_timer idle in percentage
lv_timer_get_time_until_next
Get the time remaining until the next timer will run
uint32_t lv_timer_get_time_until_next(void)Returns: uint32_t — the time remaining in ms
lv_timer_get_next
Iterate through the timers
lv_timer_t * lv_timer_get_next(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | the previous return value. May be NULL. When NULL the iteration starts from the first timer. |
Returns: lv_timer_t * — the next timer or NULL if there is no more timer
lv_timer_get_user_data
Get the user_data passed when the timer was created
void * lv_timer_get_user_data(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to the lv_timer |
Returns: void * — pointer to the user_data
lv_timer_get_paused
Get the pause state of a timer
bool lv_timer_get_paused(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a lv_timer |
Returns: bool — true: timer is paused; false: timer is running
lv_timer_handler
Call it periodically to handle lv_timers.
uint32_t lv_timer_handler(void)Returns: uint32_t — time till it needs to be run next (in ms)
lv_timer_handler_run_in_period
Call it in the super-loop of main() or threads. It will run lv_timer_handler() with a given period in ms. You can use it with sleep or delay in OS environment. This function is used to simplify the porting.
uint32_t lv_timer_handler_run_in_period(uint32_t period)| Name | Type | Description |
|---|---|---|
period | uint32_t | the period for running lv_timer_handler() |
Returns: uint32_t — the time after which it must be called again
lv_timer_periodic_handler
Call it in the super-loop of main() or threads. It will automatically call lv_timer_handler() at the right time. This function is used to simplify the porting.
void lv_timer_periodic_handler(void)lv_timer_create_basic
Create an "empty" timer. It needs to be initialized with at least lv_timer_set_cb and lv_timer_set_period
lv_timer_t * lv_timer_create_basic(void)Returns: lv_timer_t * — pointer to the created timer
lv_timer_create
Create a new lv_timer
lv_timer_t * lv_timer_create(lv_timer_cb_t timer_xcb, uint32_t period, void *user_data)| Name | Type | Description |
|---|---|---|
timer_xcb | lv_timer_cb_t | a callback to call periodically. (the 'x' in the argument name indicates that it's not a fully generic function because it not follows the func_name(object, callback, ...) convention) |
period | uint32_t | call period in ms unit |
user_data | void * | custom parameter May be NULL. |
Returns: lv_timer_t * — pointer to the new timer
lv_timer_delete
Delete a lv_timer
void lv_timer_delete(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to an lv_timer May be NULL. |
lv_timer_pause
Pause a timer. It is typically safe to call from an interrupt handler or a different thread.
void lv_timer_pause(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to an lv_timer |
lv_timer_resume
Resume a timer.
void lv_timer_resume(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to an lv_timer |
lv_timer_ready
Make a lv_timer ready. It will not wait its period.
void lv_timer_ready(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a lv_timer. |
lv_timer_reset
Reset a lv_timer. It will be called the previously set period milliseconds later.
void lv_timer_reset(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a lv_timer. |
lv_timer_enable
Enable or disable the whole lv_timer handling
void lv_timer_enable(bool en)| Name | Type | Description |
|---|---|---|
en | bool | true: lv_timer handling is running, false: lv_timer handling is suspended |
Typedefs
lv_timer_cb_t
typedef void(* lv_timer_cb_t) (lv_timer_t *)Timers execute this type of functions.
Used by 2 functions
lv_timer_create— paramtimer_xcblv_timer_set_cb— paramtimer_cb
lv_timer_handler_resume_cb_t
typedef void(* lv_timer_handler_resume_cb_t) (void *data)Timer handler resume this type of function.
Used by 1 function
lv_timer_handler_set_resume_cb— paramcb
Macros
LV_NO_TIMER_READY
#define LV_NO_TIMER_READY 0xFFFFFFFFDependencies
Last updated on