📄 tchscr.c
字号:
//about touchScr#include "..\startup\44b.h"#include "..\inc\drv\LCD320.h"#include "..\inc\drv\tchScr.h"#include "..\inc\maro.h"#include "..\inc\drv\flash.h"#include "..\inc\drv\file.h"#define ADS7843_CMD_X (ADS7843_CTRL_START|ADS7843_GET_X|ADS7843_CTRL_12MODE|ADS7843_CTRL_DFR|ADS7843_CTRL_ENPWD)#define ADS7843_CMD_Y (ADS7843_CTRL_START|ADS7843_GET_Y|ADS7843_CTRL_12MODE|ADS7843_CTRL_DFR|ADS7843_CTRL_ENPWD)int TchScr_Xmax=1840,TchScr_Xmin=176, TchScr_Ymax=195,TchScr_Ymin=1910;extern U32 ConfigSysdata[];extern U8 isConfigsysLoad;void LoadAxisMax(){ if(!isConfigsysLoad) return; TchScr_Xmax=ConfigSysdata[0]; TchScr_Xmin=ConfigSysdata[1]; TchScr_Ymax=ConfigSysdata[2]; TchScr_Ymin=ConfigSysdata[3]; if(TchScr_Xmax==TchScr_Xmin || TchScr_Ymax==TchScr_Ymin){ TchScr_Xmax=1846;//1840 TchScr_Xmin=230;//176 TchScr_Ymax=195; TchScr_Ymin=1910; Uart_Printf("\nerror touch screen data!"); LCD_printf("error touch screen data!\n"); return; } Uart_Printf("\nLoad touch screen data OK!\n"); LCD_printf("Load touch screen data OK!\n");}void TchScr_init(){ /*7 6 5 4 3 2 1:0 */ /*Internal clock,MSB mode,Transmit/Receive mode,falling edge clock,No action,Non hand-shaking mode,SIO interrupt mode*/ /*0 0 1 0 0 0 01*/ rSIOCON=0x21;//0x31; rSBRDR=15;//15;//band rate = 60MHz/2/(15+1)=1.875MHz rIVTCNT=7;//7;//Intervals=60MHz/4/(7+1)=1.875MHz LoadAxisMax();}void TchScr_GetScrXY(int *x, int *y){ unsigned int temp; rPDATC&=~ADS7843_PIN_CS; SendSIOData(ADS7843_CMD_X); SendSIOData(0); temp=ReadSIOData(); SendSIOData(ADS7843_CMD_X); temp<<=8; temp|=ReadSIOData(); *x=(temp>>4); SendSIOData(0); temp=ReadSIOData(); SendSIOData(ADS7843_CMD_X); temp<<=8; temp|=ReadSIOData(); *x+=(temp>>4); SendSIOData(0); temp=ReadSIOData(); SendSIOData(ADS7843_CMD_X); temp<<=8; temp|=ReadSIOData(); *x+=(temp>>4); SendSIOData(0); temp=ReadSIOData(); SendSIOData(ADS7843_CMD_Y); temp<<=8; temp|=ReadSIOData(); *x+=(temp>>4); *x>>=2; //x=x/4; SendSIOData(0); temp=ReadSIOData(); SendSIOData(ADS7843_CMD_Y); temp<<=8; temp|=ReadSIOData(); *y=(temp>>4); SendSIOData(0); temp=ReadSIOData(); SendSIOData(ADS7843_CMD_Y); temp<<=8; temp|=ReadSIOData(); *y+=(temp>>4); SendSIOData(0); temp=ReadSIOData(); SendSIOData(ADS7843_CMD_Y); temp<<=8; temp|=ReadSIOData(); *y+=(temp>>4); SendSIOData(0); temp=ReadSIOData(); SendSIOData(0); temp<<=8; temp|=ReadSIOData(); *y+=(temp>>4); *y>>=2; //y=y/4; rPDATC|=ADS7843_PIN_CS; *x=(*x-TchScr_Xmin)*LCDWIDTH/(TchScr_Xmax-TchScr_Xmin); *y=(*y-TchScr_Ymin)*LCDHEIGHT/(TchScr_Ymax-TchScr_Ymin);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -