Description
update label text with timer causes crash
I’m new here, could you please tell me how to change label text?I have tried event(pressed),it worked.But i want to change label text when it meets certain conditions,so i tried to use a timer.But when it meets a certain condition(a==20),it crashed.
What MCU/Processor/Board and compiler are you using?
STM32 and PC Simulator
What LVGL version are you using?
8.0.2
What do you want to achieve?
change label text
What have you tried so far?
add "lv_label_set_text(btn_label,“byebye”); " in loop;
Code to reproduce
lv_obj_t * btn_label;
int a=0;
void freshlabel(lv_timer_t * labeltimer){
a++;
if(a==20)lv_label_set_text(btn_label,"byebye");
}
void helloworld(void)
{
lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, 100, 50);
lv_obj_center(btn);
lv_obj_t * btn_label = lv_label_create(btn);
lv_label_set_text(btn_label,"hello");
lv_obj_center(btn_label);
lv_timer_t * labeltimer =lv_timer_create(freshlabel, 500, NULL);
lv_timer_ready(labeltimer);
}
/**********************
* GLOBAL FUNCTIONS
**********************/
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{
/*Initialize LittlevGL*/
lv_init();
/*Initialize the HAL for LittlevGL*/
lv_win32_init(hInstance, SW_SHOWNORMAL, 800, 480, NULL);
/*Run the demo*/
helloworld();
while(!lv_win32_quit_signal) {
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
lv_task_handler();
usleep(10000); /*Just to let the system breath*/
}
return 0;
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.