【TI 技术资料分享】+基于MSP430F149的触摸手写程序
2019-07-30 18:26发布
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
基于MSP430F149的触摸手写程序
基于MSP430F149的触摸手写程序.zip
(539.48 KB, 下载次数: 7)
2015-3-10 17:01 上传
点击文件名下载附件
- #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;
- }
- }
- }
复制代码
一周热门 更多>