Problems encountered in debugging CCD

LVGL switching interface output warning

insert image description here
Turn on a timer to refresh the image source in real time, output a warning once the interface is switched, and the warning disappears after blocking lv_img_set_src

static void timer_event_handler(lv_timer_t * timer)
{
    
    
    //lv_img_set_src(guider_ui.main_img_1, &image_256x80);/*设置图片源 From variable*/
}

static void lv_timer_test()
{
    
    
    static uint32_t user_data = 10;
    lv_timer_t * timer1 = lv_timer_create(timer_event_handler,100,(void *)&user_data);
}

void GUI_APP(void)
{
    
    

    setup_ui(&guider_ui);
    lv_timer_test();
}

Solution

Keil encountered the following error

insert image description here

Solution

method 1

Switch the engineering encoding format to GB2312

Method 2

Click the magic wand icon, switch to the C/C++ option bar, and add compilation options to Misc Controls:

--no-multibyte-chars

insert image description here

How to batch convert keil file encoding to utf-8

insert image description here

The page switching of the interface with animation is stuck

insert image description here
In the main interface, the animation display is realized through anim. If you click the setting to switch the page, the machine will crash.

//目标刷新
static void tag_anim_event_handler(void *var, int32_t v)
{
    
    

}
//图片和label刷新
static void img_anim_event_handler(void *var, int32_t v)
{
    
    
    lv_ui *ui = (lv_ui *)var;

    lv_img_set_src(ui->main_img_1, &image_256x80);/*设置图片源 From variable*/
    lv_label_set_text_fmt(ui->main_label,"%d",v);
}

static void lv_anim_test(lv_ui *ui)
{
    
    
    lv_anim_t a;

    lv_anim_init(&a);
    lv_anim_set_var(&a, ui);
    lv_anim_set_exec_cb(&a, img_anim_event_handler);
    lv_anim_set_values(&a, 0, 10);					//设置开始和结束值
    lv_anim_set_time(&a, 2000);
    lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
    lv_anim_start(&a);

    lv_anim_set_exec_cb(&a, tag_anim_event_handler);
    lv_anim_set_time(&a, 2000);
    lv_anim_start(&a);
}
void setup_scr_main(lv_ui *ui)
{
    
    
    ui->main = lv_obj_create(NULL);

	lv_anim_test(ui);

	//Init events for screen
	events_init_main(ui);
}

Solution

Analyzing the above program, after switching pages, the component structure space of the main page will be released, causing ui->main_img_1, ui->main_label to become wild pointers, but the img_anim_event_handler callback function will still be called regularly to refresh the picture, resulting in a crash, so when using Before ui->main_img_1, ui->main_label pointer judges whether it is a wild pointer, through the function lv_obj_is_valid(ui->main_img_1).

static void img_anim_event_handler(void *var, int32_t v)
{
    
    
    lv_ui *ui = (lv_ui *)var;

    if(!lv_obj_is_valid(ui->main_img_1)) return;			//如果是野指针,则退出

    lv_img_set_src(ui->main_img_1, &image_256x80);/*设置图片源 From variable*/
    lv_label_set_text_fmt(ui->main_label,"%d",v);
}

Guess you like

Origin blog.csdn.net/m0_37187962/article/details/125784961