主函数如下:
创建的按钮要按很多次才偶尔有一次两次成功完成动作的,并不是每次都可以,不知道为什么,哪位高手指点一下,在此先感谢了。
比如:我按下button1的时候会改变button2的文字显示,然后我一直按button1,button1会变亮一些(按了其它地方之后会变暗),读出来的Button_State.Pressed也是等于1的(屏幕上有显示),
GUI_DispDecAt(Button_State.x,500,100,4);
GUI_DispDecAt(Button_State.y,500,140,4);
这两个函数显示的数值也是对的,就是偶尔才会会执行if(KeyNum == GUI_ID_OK)里面的函数,不知道为什么。
int main(void)
{
u16 tpx1,tpy1;
BUTTON_Handle hButton1;
FRAMEWIN_Handle hFrame;
FRAMEWIN_Handle hFrame2;
BUTTON_Handle hButton2;
GUI_PID_STATE Button_State;
int temp = 1,KeyNum;
delay_init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
EX
tiX_Init();
KEY_Init();
i2c_init();
GUI_Init();
GUI_SetBkColor(GUI_BLACK);
GUI_SetColor(GUI_WHITE );
GUI_Clear();
hFrame = FRAMEWIN_Create("test",0,WM_CF_SHOW,0,0,250,250);
WM_Paint(hFrame);
GUI_DrawCircle(100,100,50);
GUI_DispStringAt("huankaiweishengwu",300,220);
hButton2 = BUTTON_Create(500,300,100,60,GUI_ID_YES,WM_CF_SHOW);
BUTTON_SetText(hButton2,"OK");
hButton1 = BUTTON_Create(100,300,100,60,GUI_ID_OK,WM_CF_SHOW);
BUTTON_SetText(hButton1,"Button1");
while(1)
{
delay_ms(7);
GUI_TOUCH_Exec();
GUI_TOUCH_GetState(&Button_State);
GUI_TOUCH_StoreStateEx(&Button_State);
GUI_DispDecAt(Button_State.x,500,100,4);
GUI_DispDecAt(Button_State.y,500,140,4);
GUI_DispDecAt(Button_State.Pressed,300,400,4);
// GUI_Exec();
KeyNum = GUI_GetKey();
GUI_Exec();
if(KeyNum == GUI_ID_OK)
{
if(temp == 1)
{
temp = 0;
BUTTON_SetText(hButton2,"yes");
}
else
{
temp = 1;
BUTTON_SetText(hButton2,"no");
}
FRAMEWIN_SetBarColor(hFrame2,0,GUI_YELLOW);
KeyNum = 0;
}
if(KeyNum == GUI_ID_YES)
{
BUTTON_SetText(hButton1,"OK");
hFrame2 = FRAMEWIN_Create("test",0,WM_CF_SHOW,600,0,150,150);
WM_Paint(hFrame2);
KeyNum = 0;
}
}
}