/******************************************************************* * * _DemoButton */ static void _DemoButton(void) { BUTTON_Handle hButton; int Stat = 0; GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Click on phone button...", 160,80); GUI_Delay(500); /* Create the button */ hButton = BUTTON_Create(142, 100, 36, 40, GUI_ID_OK, WM_CF_SHOW); /* Modify the button attributes */ BUTTON_SetBkColor(hButton, 1, GUI_RED); BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4); /* Loop until button is pressed */ while(GUI_GetKey() != GUI_ID_OK) { if (Stat ^= 1) { BUTTON_SetState(hButton, BUTTON_STATE_HASFOCUS | BUTTON_STATE_INACTIVE); } else { BUTTON_SetState(hButton, BUTTON_STATE_HASFOCUS | BUTTON_STATE_PRESSED); } GUI_Delay(500); } /* Delete button object */ BUTTON_Delete(hButton); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(1750); }
void GUIDEMO_Touch(void) { #define ID_KEYBOARD 1 #define ID_TESTCAL 2 #define ID_CALIBRATE 3 int i, r; int XSize = LCD_GetXSize(); int YSize = LCD_GetYSize(); int XMid = XSize / 2; int YMid = YSize / 2; //GUIDEMO_NotifyStartNext(); GUIDEMO_HideInfoWin(); do { GUI_RECT rText;/*= {0, 80, XSize, 120};*/ BUTTON_Handle ahButton[3]; rText.x0=0; rText.y0=50; rText.x1=XSize; rText.y1=90; GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_DrawBitmap(&bmMicriumLogo, (XSize - 1 - bmMicriumLogo.XSize) / 2, 15); GUI_SetFont(&GUI_Font16B_1); GUI_DispStringInRect("µC/GUI Touch screen demo", &rText, GUI_TA_HCENTER | GUI_TA_VCENTER); ahButton[0] = BUTTON_Create( XMid - 50, YMid - 30, 100, 50, ID_CALIBRATE,BUTTON_CF_SHOW ); ahButton[1] = BUTTON_Create( XMid - 90, YMid + 30, 80, 30, ID_KEYBOARD, BUTTON_CF_SHOW ); ahButton[2] = BUTTON_Create( XMid + 10, YMid + 30, 80, 30, ID_TESTCAL,BUTTON_CF_SHOW ); BUTTON_SetText (ahButton[0], "Calibrate"); BUTTON_SetBkColor(ahButton[0], 0, GUI_RED); BUTTON_SetText (ahButton[1], "Keyboard"); BUTTON_SetText (ahButton[2], "Test calibration"); BUTTON_SetFont(ahButton[0], &GUI_FontComic18B_ASCII); r = GUIDEMO_WaitKey(); if (r==0) { r = ID_KEYBOARD; BUTTON_SetState(ahButton[1],BUTTON_STATE_PRESSED); GUIDEMO_Delay(500); } for (i=0; i< countof(ahButton); i++) { BUTTON_Delete(ahButton[i]); } switch (r) { case ID_KEYBOARD: init_uart0(); send_press_key(); break; case ID_CALIBRATE: _ExecCalibration(); break; case ID_TESTCAL: _TestCalibration(); break; } } while (r && (r!='n') && (r!='N')); }