我在屏幕上画了一个BUTTON,控制LED0的亮灭。
我出现的问题是,从程序复位开始,当第一次按下BUTTON时,LED0亮灭没有变化,BUTTON会多一个虚线框;
当我再次按下BUTTON时,LED0才亮起来,有没有谁知道这是什么原因?
上述的问题在有两个以上按键的情况下,按下第二个按键响应的有可能是第一个按键的内容。
关键代码:
void Touch_Task(void *pdata)
{
while(1)
{
GUI_TOUCH_Exec();
GUI_TOUCH_GetState(&TouchPoint);
delay_ms(5);
}
}
void Menu_Task(void *pdata)
{
BUTTON_Handle hButton0;
BUTTON_Handle hButton1;
BUTTON_Handle hButton2;
GUI_Init();
GUI_SetBkColor(GUI_WHITE);
GUI_SetColor(GUI_BLACK);
GUI_SetFont(&GUI_FontHZ_HZ_12);
GUI_Clear();
hButton0=BUTTON_Create(80,50,80,40,GUI_ID_BUTTON0,WM_CF_SHOW);
hButton1=BUTTON_Create(80,100,80,40,GUI_ID_BUTTON1,WM_CF_SHOW);
hButton2=BUTTON_Create(80,150,80,40,GUI_ID_BUTTON2,WM_CF_SHOW);
BUTTON_SetFont(hButton0,&GUI_FontHZ_HZ_12);
BUTTON_SetText(hButton0,"确定");
BUTTON_SetFont(hButton1,&GUI_FontHZ_HZ_12);
BUTTON_SetText(hButton1,"退出");
BUTTON_SetFont(hButton2,&GUI_FontHZ_HZ_12);
BUTTON_SetText(hButton2,"OK");
while(1)
{
if(TouchPoint.Pressed == 1)
{
switch(GUI_GetKey())
{
case GUI_ID_BUTTON0:
GUI_DispStringAt("button0 pressed",5,200);
LED0=!LED0;
break;
case GUI_ID_BUTTON1:
GUI_DispStringAt("button1 pressed",5,215);
LED1=!LED1;
break;
case GUI_ID_BUTTON2:
GUI_DispStringAt("button2 pressed",5,230);
LED0=!LED0;
LED1=!LED1;
break;
default:
break;
}
}
GUI_Exec();
delay_ms(100);
}
}
|