如果你这个需求就是不同页面切换的话,可以在一开始把所有界面创建完,然后添加隐藏的flag,在定时把他们清除flag。
[C] 纯文本查看 复制代码 void Lvgl_start(void)
{
int time1=0;
int time2=0;
/*LED1-LED2*/
GPIO_Congif(LED1_PORT,LED1_PIN,GPIO_Mode_OUT,GPIO_PuPd_NOPULL);
GPIO_Congif(LED2_PORT,LED2_PIN,GPIO_Mode_OUT,GPIO_PuPd_NOPULL);
/*lvgl tick*/
Sys_Timer1_Init();
/*lvgl 初始化*/
lv_init();
lv_port_disp_init();
lv_port_indev_init();
lv_obj_t* base_obj;
lv_obj_t* base1_obj;
lv_obj_t* base2_obj;
lv_obj_t* base3_obj;
lv_obj_t* base4_obj;
Show_AC(base_obj);
Show_DC(base1_obj);
Show_pri(base2_obj);
Show_HYD_TEST(base3_obj);
M_gui(base4_obj);
while(1)
{
lv_task_handler();
lv_obj_add_flag(base_obj, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(base1_obj, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(base2_obj, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(base3_obj, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(base4_obj, LV_OBJ_FLAG_HIDDEN);
//STATUS注释此模块
//30s切换一个界面
if(Read_time_ms()>0&&Read_time_ms()<200)
{
lv_obj_clear_flag(base_obj, LV_OBJ_FLAG_HIDDEN);
}
else if(Read_time_ms()>30000&&Read_time_ms()<30200)
{
lv_obj_clear_flag(base1_obj, LV_OBJ_FLAG_HIDDEN);
}
else if(Read_time_ms()>60000&&Read_time_ms()<60200)
{
lv_obj_clear_flag(base2_obj, LV_OBJ_FLAG_HIDDEN);
}
else if(Read_time_ms()>90000&&Read_time_ms()<90200)
{
lv_obj_clear_flag(base3_obj, LV_OBJ_FLAG_HIDDEN);
}
else if(Read_time_ms()>120000&&Read_time_ms()<120200)
{
lv_obj_clear_flag(base4_obj, LV_OBJ_FLAG_HIDDEN);
}
else if(Read_time_ms()>150000&&Read_time_ms()<150200)
{
display();
}
else if(Read_time_ms()>180000&&Read_time_ms()<180200)
{
Reset_time();
}
lcd_double_buffer_update();
/*LED1*/
if((Read_time_ms()-time1)>500)
{
time1=Read_time_ms();
GPIO_SET(LED1_PORT,LED1_PIN);
}
else if((Read_time_ms()-time1)>250)
{
GPIO_RESET(LED1_PORT,LED1_PIN);
}
/*LED2*/
if((Read_time_ms()-time2)>1000)
{
time2=Read_time_ms();
GPIO_SET(LED2_PORT,LED2_PIN);
}
else if((Read_time_ms()-time2)>500)
{
GPIO_RESET(LED2_PORT,LED2_PIN);
}
/*delay*/
delay_us(10);
}
}
|