📄 main.c
字号:
/*----------------------------------------------------------------------------
QQ: 958664258
21IC用户名:banhushui
交流平台:http://blog.21ic.com/user1/5817/index.html
淘宝店铺:http://shop58559908.taobao.com
旺旺:半壶水电子
编译器版本:MDK3.5
*---------------------------------------------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#define SYS_GLOBALS
#include "include.h"
//#include <absacc.h>
void Delay(unsigned long time)
{unsigned long i,j;
for(j=0; j<time; j++)
{
for(i=0;i<12000;i++);
}
}
__task void Led1(void)
{
while(1)
{
PC8=0; PC9=0; PC10=0; PC11=0;
//os_dly_wait(100/OS_TIME);//100ms
Delay(100);
PC8=1; PC9=1; PC10=1; PC11=1;
//os_dly_wait(300/OS_TIME);//100ms
Delay(300);
}
}
///*
//箭头光标
//8*8点阵
//
//*/
//uint8 TableCursor1[8]={0x00,0x7C,0x70,0x78,0x5C,0x4E,0x06,0x00};
///*
//十字光标
//8*8点阵
// ..
// ..
// ....
// ........
// ........
// ....
// ..
// ..
//*/
//uint8 TableCursor2[8]={0x18,0x18,0x3C,0xFF,0xFF,0x3C,0x18,0x18};
///*
//十字光标
//8*8点阵
// ..
// ..
// ..
// ........
// ........
// ..
// ..
// ..
//*/
//uint8 TableCursor3[8]={0x18,0x18,0x18,0xFF,0xFF,0x18,0x18,0x18};
///*
//点显示,近似圆点
//8*8点阵
// ..
// ....
// ....
// ..
//*/
//uint8 TableTouchDot[8]={0x00,0x00,0x18,0x3C,0x3C,0x18,0x00,0x00};
/*
200,380 710,340 1338,380
162,1258 544,1260 820,1225
135,2200 430,2150 535,2045
*/
POINT LCDSample[3] = { { 240/10, 320/10 }, { 240-240/10, 320/2 },//{ 120+4, 160+4 },//{ 200, 160 }, { 240/2, 320-320/10 },//{ 200+4, 270+4 }, //{ 50, 270},
//{ 240/10, 320-320/10 }, } ;
POINT TouchSample[3];
//POINT LCDSample[3] = { { 5, 5 },// { 235, 160 },//{ 120+4, 160+4 },//{ 200, 160 },// { 5, 315 },//{ 200+4, 270+4 }, //{ 50, 270},// } ;
//POINT TouchSample[3]={ {200,380}, {820,1225}, {135,2200}};
//MATRIX matrix;
////POINT display;
//
//__task void Dlg_Main(void)
//{
// setCalibrationMatrix( &LCDSample[0], &TouchSample[0], &matrix );
// while(1)
// {
// getDisplayPoint( &display, &TouchSample[0], &matrix );
//
// getDisplayPoint( &display, &TouchSample[1], &matrix );
//
// getDisplayPoint( &display, &TouchSample[2], &matrix );
// }
//}
//校正参数
MATRIX matrix=
{0x0000F900, 0xFFFFFDC0, 0xFFE714B0, 0x00000280, 0x00017700, 0xFFC219C0, 0x0002887A };
POINT display;
void Dlg_Main(void)
{uint16 xt,yt;
// uint8 buf[32];
uint16 i;
uint8 flag;
//FillSolidRect(0, 0, 240, 320, GREY);
//FillSolidRect(0, 0, 240, 32, BLUE);
FillSolidRect(0, 0, 240, 320, BLUE);
//os_tsk_delete_self ();
i=0;
DrawIcon(LCDSample[i].x, LCDSample[i].y, RED, CURSOR_CROSS);
do
{
//os_dly_wait(100/OS_TIME);//100ms
Delay(100);
flag=TP_GetAdXY2(&xt, &yt, 300);
if(flag==0)//无触摸
;
else
{
DrawIcon(LCDSample[i].x, LCDSample[i].y, GREEN, CURSOR_CROSS);
TouchSample[i].x = xt/4;
TouchSample[i].y = yt/4;
//等待抬起
//os_dly_wait(500/OS_TIME);//1000ms
Delay(500);
while( flag )
{
flag=TP_GetAdXY(&xt, &yt);
}
i++;
DrawIcon(LCDSample[i].x, LCDSample[i].y, RED, CURSOR_CROSS);
}
}while(i<3);
FillSolidRect(0, 0, 240, 320, BLUE);
setCalibrationMatrix( &LCDSample[0], &TouchSample[0], &matrix );
//TouchDotON(6, 6, RED);
//TouchDotOFF();
//TouchDotON(100, 100, RED);
//TouchDotOFF();
//InitCursor(CURSOR_ARROW, RED, BLUE);
InitCursor(CURSOR_ARROW, WHITE, BLUE);
//InitCursor(CURSOR_CROSS, WHITE, BLUE);
SetCursor(240/2-1, 320/2-1, 1);
while(1)
{
flag=TP_GetAdXY2(&xt, &yt, 0);
if(flag)
{
TouchSample[0].x=xt/4; TouchSample[0].y=yt/4;
getDisplayPoint( &display, &TouchSample[0], &matrix );
SetCursor(display.x, display.y, 1);
}
}
}
/*******************************************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{//uint8 i=0;
#ifdef DEBUG
debug();
#endif
//ReStart:
/* System Clocks Configuration */
RCC_Configuration();
GPIO_Configuration();
SPI_Configuration();
/* NVIC configuration */
NVIC_Configuration();
//DebugSendBuf("abcdefgh\r\n", 10);
LCD_Initialize();
TP_Init();
Dlg_Main();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -