ucgui下怎么实现AD转换值的实时刷新

2019-08-21 13:24发布

  我想请教各位大侠,正在做一个ucgui+ucos的系统,但是现在在现实AD转换值的过程中,AD转换值不能实现实时刷新,我如果向while(1)加的话,它就死机不能退出当前的界面。怎么才能实现实时刷新AD转换值,
uint16_t AD_value[4]; /**********************************************************************************************************
** Function name:      Task_FileBrowser
** Descriptions:       文件浏览器任务
** input parameters:   void *pdata
** output parameters:  无
** Returned value:     无
**********************************************************************************************************/
void Task_ADC(void *pdata)
{   BUTTON_Handle hButton_else;
 TEXT_Handle   hTextelse;
// ROGBAR_Handle ahProgBar[2];
  char buf[25] = {0};
 int i;
  SingleList   pos   = NULL;
 Menu_ID = FileBrowseMenu_ID;
 OtherMenu_pHead = SingleListNodeCreate();        /* 创建单向链表表头节点    */
 pos = OtherMenu_pHead;
hTextelse[0] = TEXT_Create(5,20,200, 20, 2, WM_CF_SHOW, "ADC Value ",TEXT_CF_LEFT);//创建文本
 TEXT_SetFont(hTextelse[0],&GUI_Font24_ASCII);//设置用于一个指定的文本控件的字体
 
 hTextelse[1] = TEXT_Create(5,50,100, 25, 3, WM_CF_SHOW, "sensor 1:",TEXT_CF_LEFT);
 TEXT_SetFont(hTextelse[1],&GUI_Font24_ASCII);  hTextelse[2] = TEXT_Create(5,80,100, 25, 4, WM_CF_SHOW, "sensor 2:",TEXT_CF_LEFT);
 TEXT_SetFont(hTextelse[2],&GUI_Font24_ASCII);
 
 hTextelse[3] = TEXT_Create(5,110,100, 25, 5, WM_CF_SHOW, "sensor 3:",TEXT_CF_LEFT);
 TEXT_SetFont(hTextelse[3],&GUI_Font24_ASCII);
 
 hTextelse[4] = TEXT_Create(5,140,100, 25, 6, WM_CF_SHOW, "humiture:",TEXT_CF_LEFT);
 TEXT_SetFont(hTextelse[4],&GUI_Font24_ASCII);  hTextelse[5] = TEXT_Create(5,220,200, 25, 7, WM_CF_SHOW, "MainMenu",TEXT_CF_LEFT);
 TEXT_SetFont(hTextelse[5],&GUI_Font24_ASCII);
     sprintf(buf,"%dV",AD_value[0]);
 hTextelse[6] = TEXT_Create(101,50,100, 25, 8, WM_CF_SHOW, buf,TEXT_CF_HCENTER);
 TEXT_SetFont(hTextelse[6],&GUI_Font24_ASCII);
 
  sprintf(buf,"%dV",AD_value[1]);
  hTextelse[7] = TEXT_Create(101,80,100, 25, 9, WM_CF_SHOW, buf,TEXT_CF_HCENTER);
 TEXT_SetFont(hTextelse[7],&GUI_Font24_ASCII);
 
  sprintf(buf,"%dV",AD_value[2]);
  hTextelse[8] = TEXT_Create(101,110,100, 25, 10, WM_CF_SHOW, buf,TEXT_CF_HCENTER);
 TEXT_SetFont(hTextelse[8],&GUI_Font24_ASCII);
 
  sprintf(buf,"%dC",AD_value[3]/10);
  hTextelse[9] = TEXT_Create(101,140,100, 25, 11, WM_CF_SHOW, buf,TEXT_CF_HCENTER);
 TEXT_SetFont(hTextelse[9],&GUI_Font24_ASCII);
  
 for (i = 0;i < 10;i++) {
  TEXT_SetTextColor(hTextelse,GUI_WHITE);//设置文本的颜 {MOD}
//    TEXT_SetBkColor(hTextelse,GUI_BLACK);
  pos = SingleListInsert(OtherMenu_pHead,pos,hTextelse);//将所有文本框句柄插入链表
 }
 hButton_else = BUTTON_Create (5, 260,70, 25, Button_ID8, WM_CF_SHOW);//创建Button_ID0的按键
  
 BUTTON_SetTextColor(hButton_else,0,GUI_WHITE);//设置文本的颜 {MOD}
   BUTTON_SetBkColor  (hButton_else,0,ThemeColor);//设置背景的颜 {MOD}
    BUTTON_SetBkColor  (hButton_else,1,GUI_GRAY);
   pos = SingleListInsert(OtherMenu_pHead,pos,hButton_else);//将所有文本框句柄插入链表
 BUTTON_SetText(hButton_else,"MainMenu");
 //OtherMenu_Info.FirstHandle = hTextelse[0];
 OtherMenu_Info.EndHandle = hButton_else;//设置文本
 
 
 /*******************************************************************************************************/
 while(1)
{
 if(TouchCmd == 1)
  {
   TouchCmd = 0; 
    switch(GUI_GetKey())
   {
    case Button_ID8:
     Out_OtherMenu();            //退出设置界面
      Go_MainMenu();              //进入主界面
      OSTaskDel(OS_PRIO_SELF);    //删除自己
     break;
    default : 
     TouchCmd = 1;
     break;
    }
   }
   OSTimeDly(10);   //保证50Hz的执行频率
 
}
}下面是代码:
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。