#include "led.h"
#include "delay.h"
#include "sys.h"
#include "key.h"
#include "button.h"
#include "timer.h"
#include "my_lcd.h"
#include "gui.h"
#include "lcd.h"
#include "touch.h"
#include "LCD_Protected.h"
//旺宝
GUI_PID_STATE STATE; //该变量为GUI触屏的x y位置存储坐标(内部已将其换算为屏幕坐标了)
BUTTON_Handle hButton0;
BUTTON_Handle hButton1;
u8 Key = 0;
int main(void)
{
SystemInit();
delay_init(72);
LED_Init();
KEY_Init();
Timerx_Init(100,7199);
StartTouch();
GUI_Init();
GUI_SetBkColor(GUI_RED);
GUI_SetColor(GUI_WHITE);
GUI_Clear();
GUI_SetFont(&GUI_Font8x16);
GUI_DispStringHCenterAt("Click on button...",160,0);
hButton0 = BUTTON_Create(110, 20, 100, 40, GUI_ID_BUTTON0, WM_CF_SHOW);
hButton1 = BUTTON_Create(110, 80, 100, 40, GUI_ID_BUTTON1, WM_CF_SHOW);
BUTTON_SetBkColor(hButton0, 1, GUI_RED);
BUTTON_SetBkColor(hButton1, 1, GUI_BLUE);
BUTTON_SetText(hButton0,"Click me...");
BUTTON_SetText(hButton1,"my love...");
WM_Paint(hButton0);
WM_Paint(hButton1);
while(1)
{
GUI_TOUCH_GetState(&STATE);
GUI_DispStringAt("x:", 0, 200);
GUI_DispDec(STATE.x, 3);
GUI_DispStringAt("y:", 0, 250);
GUI_DispDec(STATE.y, 3);
if (STATE.Pressed == 1)
{
GUI_CURSOR_SetPosition(STATE.x, STATE.y);
GUI_CURSOR_Show();
}
delay_ms(1);
Key = GUI_WaitKey();
//// Key=GUI_GetKey();
// switch(GUI_GetKey())
// {
// case GUI_ID_BUTTON0:
// GUI_DispStringAt("my love",0,240);
// GUI_Delay(500); //GUI_Exec();
// break;
// case GUI_ID_BUTTON1:
// GUI_DispStringAt("my hate",0,200);
// GUI_Delay(500); // GUI_Exec();
// break;
// }
// GUI_Exec();
// Key=GUI_GetKey();
if(Key==GUI_ID_BUTTON0)
{
GUI_DispStringAt("my love",0,240);
GUI_Delay(500);
}
if(Key==GUI_ID_BUTTON1)
{
GUI_DispStringAt("my hate",0,240);
GUI_Delay(500);
}
}
}
void TIM3_IRQHandler(void) //TIM3中断
{
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查指定的TIM中断发生与否:TIM 中断源
{
GUI_TOUCH_Exec();
TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //清除TIMx的中断待处理位:TIM 中断源
}
}
按键的动态效果很好,只是不执行相应的功能,大家帮忙看下这是怎么回事!
|