做了一个简单的触摸按钮界面, 按下后,按钮上的字变为OK。 一旦把背景色设置为黑色,就没反应。
[mw_shl_code=c,true]//??????????
void system_init(void)
{
FRESULT res;
delay_init(168); //???±??????
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //????·?×é????
uart_init(115200); //?®???¨?????è??
TFTLCD_Init(); //LCD??????
TP_Init(); //????????????
FSMC_SRAM_Init(); //SRAM??????
W25QXX_Init(); //flash??????
exfuns_init(); //??????????????
Io_Init(); //IO????????
BEEP_Init(); //·??ù?÷??????
mem_init(SRAMIN); //????????????????
mem_init(SRAMCCM); //??????CCM??????
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC,ENABLE); //????CRC?±?? // WM_SetCreateFlags(WM_CF_MEMDEV); //·???????????
GUI_Init(); //STemWin ??????
res = f_mount(fs[1],"1:",1); //????FLASH.
USBH_Init(&USB_OTG_Core,USB_OTG_FS_CORE_ID,&USB_Host,&USBH_MSC_cb,&USR_Callbacks); //usb ?÷?ú??????
//??????????
GUI_SetBkColor(GUI_BLACK); //?è??±??°????
GUI_SetColor(GUI_WHITE); //?è??????
GUI_Clear();
GUI_SetFont(&GUI_FontIcpFont48B); //×??í23
GUI_DispStringAt("Ph Technologies",10,200); //20??×?·?
GUI_DispStringAt("A",100,400); //12
GUI_DispStringAt("B",160,500); //7
GUI_DispStringAt("Init...",160,600); //7
GUI_Delay(2000);
}
//?÷????
int main(void)
{
system_init(); //??????????
OSInit(); //??????UCOS
OSTaskCreate(start_task,(void*)0,(OS_STK*)&START_TASK_STK[START_STK_SIZE-1],START_TASK_PRIO); //start_task???? ???? ???????????? ??????????
OSStart(); //????UCOS
}
//????????
void start_task(void *pdata)
{
OS_CPU_SR cpu_sr;
OSStatInit(); //??????????????
OS_ENTER_CRITICAL(); //??????????,??±?????
OSTaskCreate(main_task,(void *)0,(OS_STK*)&MAIN_TASK_STK[MAIN_STK_SIZE-1],MAIN_TASK_PRIO); //??????3 ?÷????
OSTaskSuspend(OS_PRIO_SELF); //????start????
OS_EXIT_CRITICAL(); //??????????,??????
}
//?÷????
void main_task(void *pdata)
{
int t; //°????ì??ID
OS_CPU_SR cpu_sr;
GUI_Clear();
first_screen_button(); //???¨°???
GUI_Delay(2000);
GUI_DispStringAt("ABCDE",160,700); //7
while(1)
{
GUI_TOUCH_Exec(); //???????é??
t = GUI_GetKey(); //????ID
LCD_ShowxNum(200,780,OSCPUUsage,3,16,0); //????CPU??????
if(t==21)
{
BUTTON_SetFont(Zero_Button,&GUI_FontIcpFont48B);
BUTTON_SetText(Zero_Button, "OK");
}
if(t==22)
{
BUTTON_SetFont(Rom_Button,&GUI_FontIcpFont48B);
BUTTON_SetText(Rom_Button, "OK");
}
if(t==23)
{
BUTTON_SetFont(Input_Button,&GUI_FontIcpFont48B);
BUTTON_SetText(Input_Button, "OK");
}
GUI_Delay(65);
}
}
//????????°???????
void first_screen_button(void)
{
//???¨°??? zero
Zero_Button=BUTTON_Create(100,250,300,100,21,WM_CF_SHOW);
BUTTON_SetFont(Zero_Button,&GUI_FontIcpFont48B);
BUTTON_SetText(Zero_Button, "Zero");
//???¨°??? read from rom
Rom_Button=BUTTON_Create(100,400,300,100,22,WM_CF_SHOW);
BUTTON_SetFont(Rom_Button,&GUI_FontIcpFont48B);
BUTTON_SetText(Rom_Button, "Rom");
//???¨°???manual input
Input_Button=BUTTON_Create(100,550,300,100,23,WM_CF_SHOW);
BUTTON_SetFont(Input_Button,&GUI_FontIcpFont48B);
BUTTON_SetText(Input_Button, "Manual");
}
[/mw_shl_code]
|