How to update a text of a label with user data

first of all it seems that you wanted create timer like

lv_timer_t * timer = lv_timer_create(label_refresher_task, 1000, &user_data);

what about type cast from 'void*' to 'uint32_t*' it depend from used compiler. try to use explicit cast

 uint32_t * user_data = (uint32_t *)timer->user_data;

you don’t have to do anything about it. this line of doc tells about first arg of lv_timer_create(). first arg have type lv_timer_cb_t. as described here lv_timer_cb_t defined as

typedef void (*lv_timer_cb_t)(struct _lv_timer_t*)
Timers execute this type of functions.

so your callback function should be defined as

void cb_function_name(struct _lv_timer_t*)
{
}

as it done in your code. you didn’t need to redefine already defined type. just remove this line void (*lv_timer_cb_t)(lv_timer_t *); from your user code. this typedef is described inside the library

1 Like