#include <msp430x14x.h>
#include "BCS_TIMER.h"
#include "TFT24.h"
#include "Display_TFT24.h"
#include "Touch.h"
typedef unsigned int uint;
typedef unsigned char uchar;
/***************触摸接口的宏定义*********************/
#define tchIRQ P6IN & BIT5 //触屏中断
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
/*下面六行关闭所有的IO口*/
P1DIR = 0XFF; P1OUT = 0XFF;
P2DIR = 0XFF; P2OUT = 0XFF;
P3DIR = 0XFF; P3OUT = 0XFF;
P4DIR = 0XFF; P4OUT = 0XFF;
P5DIR = 0XFF; P5OUT = 0XFF;
P6DIR = 0XFF; P6OUT = 0XFF;
uint TFT_X, TFT_Y, k, h;
Init_Touch(); //初始化触屏
Init_TFT24(); //初始化TFT24液晶
Init_BCS();
TFT_Clear(Red); //清屏
Put_String(0, 0, "GOOD", 0, 0xffff); //显示字符串
while(1)
{
if(!(tchIRQ))
{
Read_Touch(); //读取坐标
P2OUT = 0xfe;
Put_String(0, 296, "X:", Red, Black); //显示X坐标
Put_Touch(32, 296, Touch_X, Blue, Black);
Put_String(120, 296, "Y:", Red, Black); //显示Y坐标
Put_Touch(152, 296, Touch_Y, Blue, Black);
TFT_X = ((Touch_X - 220) / 15);
TFT_Y = 320 - ((Touch_Y - 300) / 11);
if(TFT_Y < 160)
{
P2OUT = 0xf0;
}
else
{
P2OUT = 0x0f;
}
Put_String(0, 272, "X:", Red, Black); //显示X坐标
Put_Touch(32, 272, TFT_X, Blue, Black);
Put_String(120, 272, "Y:", Red, Black); //显示Y坐标
Put_Touch(152, 272, TFT_Y, Blue, Black);
LCD_CS_L;
for(k=0; k<5; k++)
{
for(h=0; h<5; h++)
{
Set_Posi(TFT_X+h, TFT_Y+k, TFT_X+1, TFT_Y+1);
Lcd_Write_Data(Blue);
}
}
LCD_CS_H;
}
}
}