static void GUI_Proc(void *p_arg)
{
CppEntry();
while(1)
{
OSSemPend(LvglTaskHandleMutex, 0, &g_lvglTaskHandleMutexErr);
lv_task_handler();
OSSemPost(LvglTaskHandleMutex);
OSTimeDly(3);
}
}
static void Touch_Proc(void *p_arg)
{
while(1)
{
Bsp_IncubTempControl();
USBH_Process_OS();
OSTimeDly(5); //延时1000ms
}
}
``这边是按键事件回调,按键按下后,会调用动画显示,然后在另外一个线程加载数据,数据加载完成后,另外一个线程发送事件结束动画
void CReagentSetupWnd::DefWindowProc(lv_obj_t* obj,lv_event_t e)
{
if(obj == m_setupTab)
{
switch(e)
{
case G_EVENT_WAIT_START:
{
if(m_oReagentModel.m_taskType == 1)
{
m_pWaitPromptDlg->m_strWaitText = "Delete operation in progress,\n please do not shutdown...";
}
m_pWaitPromptDlg->OnInitDialog();
}break;
case G_EVENT_WAIT_END:
{
if(m_oReagentModel.m_taskType == 0)
{
DelayInit();
m_pWaitPromptDlg->EndWait();
}
else if(m_oReagentModel.m_taskType == 1)
{
ChangeWnd(WND_MAIN_MENU,1,0);
}
}break;
}
}
}
这边是动画的初始化
void CWaitPromptDlg::OnInitDialog(lv_obj_t* obj,lv_event_t e)
{
CPopUpBaseDlg::OnInitDialog(obj,e);
m_waitConntent = lv_obj_create(GetPopUpBaseObj(),NULL);
lv_obj_set_size(m_waitConntent,LV_HOR_RES / 2,150);
lv_obj_align(m_waitConntent,NULL,LV_ALIGN_CENTER,0,0);
string t_strTitle = "Attention";
AddTitle(m_waitConntent,t_strTitle);
lv_obj_t * arc = lv_arc_create(m_waitConntent, NULL);
lv_arc_set_bg_angles(arc, 0, 360);
lv_arc_set_value(arc,80);
lv_obj_set_size(arc, 50, 50);
m_tipsTextObj = addLabel(m_waitConntent,NULL,m_strWaitText.c_str());
lv_obj_align(m_tipsTextObj,NULL,LV_ALIGN_CENTER,0,30);
lv_obj_align(arc,m_tipsTextObj,LV_ALIGN_OUT_TOP_MID,0,-10);
lv_anim_t a;
lv_anim_init(&a);
a.repeat_cnt = LV_ANIM_REPEAT_INFINITE;
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_arc_set_rotation);
lv_anim_set_values(&a, 0, 360);
lv_anim_set_time(&a, 1000);
lv_anim_set_var(&a, arc);
//lv_anim_set_ready_cb(&a, end_cb);
lv_anim_start(&a);
printf(" Wait prompt Dlg lv_anim_start \r\n");
}
这边是另外一个线程的处理
void CReagentSetupModel::ThreadFunc()
{
printf("=====Satrt CReagentSetupModel ThreadFunc m_taskType %d m_notifyObj %x======\r\n", m_taskType, m_notifyObj);
switch(m_taskType)
{
case 0:
{
if(m_notifyObj != NULL)
{
lv_event_send(m_notifyObj, G_EVENT_WAIT_END, NULL);
}
}
break;
case 1:
{
if(m_notifyObj != NULL)
{
lv_event_send(m_notifyObj, G_EVENT_WAIT_START, NULL);
}
m_pData->DelTest(m_curTest);
if(m_notifyObj != NULL)
{
lv_event_send(m_notifyObj, G_EVENT_WAIT_END, NULL);
}
}
break;
}
printf("=====End CReagentSetupModel ThreadFunc m_taskType %d ======\r\n", m_taskType);
}
线程执行完成以后,发送事件,通知lvgl结束动画调用,并刷新屏幕,具体函数如下
void CWaitPromptDlg::EndWait()
{
m_retValue = value;
ReleaseOBJPtr(m_curDlgObj);
lv_event_send(m_notifyObj, m_notifyEvent, NULL); //阻塞式调用
m_retValue = -1;
m_notifyObj = NULL;
printf(" Wait prompt Dlg OnClose \r\n");
if(LvglTaskHandleMutex != NULL)
{
OSSemPend(LvglTaskHandleMutex, 0, &g_lvglTaskHandleMutexErr);
}
lv_obj_invalidate(lv_scr_act());
if(LvglTaskHandleMutex != NULL)
{
OSSemPost(LvglTaskHandleMutex);
}
printf(" Wait prompt Dlg lv_obj_invalidate End\r\n");
}