📄 main.c
字号:
WriteData(0x00);
Delay(50);
WriteComm(0x00);
WriteComm(0x71);
WriteData(0x00);
WriteData(0x40);
Delay(50);
WriteComm(0x00);
WriteComm(0x10);
WriteData(0x24);
WriteData(0x70);
WriteComm(0x00);
WriteComm(0x07);
WriteData(0x00);
WriteData(0x05);
Delay(50);
WriteComm(0x00);
WriteComm(0x07);
WriteData(0x00);
WriteData(0x25);
WriteComm(0x00);
WriteComm(0x07);
WriteData(0x00);
WriteData(0x27);
Delay(50);
WriteComm(0x00);
WriteComm(0x07);
WriteData(0x00);
WriteData(0x37);
}
void T0_CTRL(unsigned char i)
{
TMOD=0x01; // T0:16位定时器
PT0 = 1; // IP: 中断优先级为1
TH0=0x00;
TL0=0x00;
ET0 = 1;
TR0 = i; // 1-T0 打开; 0-T0 关闭
//EA = 1; // 1-所有中断有效;0-关闭所有中断
}
void INT0_CTRL(unsigned char i)
{
//IE: EX0 1-外部INT0 打开;0-外部INT0 关闭
PX0 = 0; // IP:中断优先级为0
IT0 = 0; // TCON:低电平触发
EX0 = i; // 1-外部INT0 打开 0-外部INT0 关闭
//EA = 1; // 1-所有中断有效;0-关闭所有中断
}
void INT0_FUN(void) interrupt 0 // P3.2
{
EX0 = 0; //外部0关闭
EA=0; //所有中断无效
TP_IRQ=1;
StartTPTest();
if(FG_DISP_POS) DispPos(TP_X,TP_Y);
//tp test point 1
if(((TP_X>=1700)&&(TP_X<=0x2000))&&((TP_Y>=1700)&&(TP_Y<=0x2000))&&(FG_STEP_1))
{
FillIconWindow(COL/2-15,ROW/2-15,0xffff);
//DrawGird(0x2410);
WriteIconWindow(COL-30,0,cursorIcon);
FG_STEP=FG_STEP<<1;Delay(50);
}
//tp test point 2
if(((TP_X>=3000)&&(TP_X<=3800))&&((TP_Y>=3000)&&(TP_Y<=3800))&&(FG_STEP_2))
{
FillIconWindow(COL-30,0,0xffff);
//DrawGird(0x2410);
WriteIconWindow(0,0,cursorIcon);
FG_STEP=FG_STEP<<1;Delay(50);
}
//tp test point 3
if(((TP_X>=100)&&(TP_X<=800))&&((TP_Y>=3000)&&(TP_Y<=3800))&&(FG_STEP_3))
{
FillIconWindow(0,0,0xffff);
//DrawGird(0x2410);
WriteIconWindow(0,ROW-30,cursorIcon);
FG_STEP=FG_STEP<<1;Delay(50);
}
//tp test point 4
if(((TP_X>=100)&&(TP_X<=800))&((TP_Y>=100)&&(TP_Y<=800))&&(FG_STEP_4))
{
FillIconWindow(0,ROW-30,0xffff);
//DrawGird(0x2410);
WriteIconWindow(COL-30,ROW-30,cursorIcon);
FG_STEP=FG_STEP<<1;Delay(50);
}
//tp test point 5
if(((TP_X>=3000)&&(TP_X<=3800))&&((TP_Y>=100)&&(TP_Y<=800))&&(FG_STEP_5))
{
FillIconWindow(COL-30,ROW-30,0xffff);
//DrawGird(0x2410);
WriteIconWindow(COL/2-15,ROW/2-15,goodIcon);
FG_STEP=0x01;Delay(300);
FG_STEP=FG_STEP<<1;
}
// draw line test
if(FG_STEP_6)
{
WritePixel(ConvPosX(TP_X),ConvPosY(TP_Y),0xf800);
DispPos(ConvPosX(TP_X),ConvPosY(TP_Y));
}
BlockWrite(0,COL-1,0,ROW-1);
EX0 = 1; //外部0 打开
EA=1; //所有中断有效
}
void T0_FUN(void) interrupt 1
{
ET0 = 0; // T0无效
TR0 = 0; // T0关断
KEY2 = 1;
KEY3 = 1;
KEY4 = 1;
TH0=0x00;
TL0=0x00;
/*
if(KEY2==0)
{
if(G_STEP_VALUE<G_STEP_VALUE_MAX)
{
G_STEP_VALUE ++;
}
else
{
G_STEP_VALUE = 0;
}
DispByStep(G_STEP_VALUE);
}
*/
//KEY3,KEY4,
if( KEY3==0 ) //
{
EnterSLP();
}
if( KEY4==0 ) //
{
ExitSLP();
}
ET0 = 1; // T0有效
TR0 = 1; // T0开启
}
void ALL_INT_CTRL(unsigned char i)
{
EA = i; // 1-所有中断有效;0-关闭所有中断
}
/*****************************************************************************
MAIN TEST PROGRAM
*****************************************************************************/
void main(void)
{
ResetChip();
InitLCD();
ALL_INT_CTRL(1);
//T0_CTRL(1); //T0中断有效
while(1)
{
DispBand(); //band
//DispID();
WaitKey();
//Delay(50);
//DispColor(0xf800); //red
//WaitKey();
//Delay(50);
//EnterSLP();
//WaitKey();
//Delay(50);
//ExitSLP();
//WaitKey();
//Delay(50);
DispColor(0x07e0); //green
WaitKey();
//Delay(50);
DispColor(0x001f); //blue
WaitKey();
//Delay(50);
DispColor(0xffff); //white
WaitKey();
//Delay(50);
//DispColor(0x0000); //black
//WaitKey();
//Delay(50);
DispFrame();
WaitKey(); //black
//Delay(50);
DispRGBGray();
WaitKey();
//Delay(50)
BlockWrite(0,COL-1,0,ROW-1);
DispPic(pic_eval);
DispPic(pic_eval);
WaitKey();
//Delay(50);
//FillGrayRGB(R_Bar_L,R_Bar_R,G_Bar_L,G_Bar_R,B_Bar_L,B_Bar_R);
//WaitKey();
//Delay(50);
//FillGraphic16(graphic16_1,0xffff,0x0000);
//WaitKey();
//Delay(50);
//FillGraphic8(graphic8_5,0x001f,0xffff);
//WaitKey();
//Delay(50);
//FillColorLine(pic_green_l);
//FillColorLine(pic_green_r);
//WaitKey();
//Delay(50);
//DispSnow(); // snow
//WaitKey();
//Delay(50);
//------------------------------------------------------
//touch panel test,5 point,使用外部中断0
//外部中断0设置: EX0=1-外部INT0 打开;EX0=9-外部INT0 关闭
INT0_CTRL(1); //OPEN INT0
DispColor(0xffff);
DrawGird(0xef5d);//0x2410
//FillGraphic16(graphic16_2,0x0000,0xffff);
P0=0xff; P1=0xff;P2=0xff;P3=0xff;
TP_X=0x0000;TP_Y=0x0000;
WriteIconWindow(COL/2-15,ROW/2-15,cursorIcon);
FG_STEP=0x01;FG_STEP=FG_STEP<<1;FG_DISP_POS=1;
while(FG_STEP_1);
while(1)
{
WaitKey();
FG_DISP_POS=0;
FG_STEP=0x01;FG_STEP=FG_STEP<<6;
DispColor(0xffff);
//FillGraphic16(graphic16_2,0x0000,0xffff);
DrawGird(0x551f);
WaitKey();
FG_DISP_POS=1;
DispColor(0xffff);
DrawGird(0x2410);
//FillGraphic16(graphic16_2,0x0000,0xffff);
WriteIconWindow(COL/2-15,ROW/2-15,cursorIcon);
FG_STEP=0x01;FG_STEP=FG_STEP<<1;
}
/*
//touch panel test, 5 point,使用查询方式
DispColor(0xffff);
P0=0xff; P1=0xff;P2=0xff;P3=0xff;
TP_X=0x0000;TP_Y=0x0000;
FG_STEP=0x01;FG_STEP=FG_STEP<<1;
//tp test point 1
WriteIconWindow(0x0069,0x0091,cursorIcon);
while(FG_STEP_1)
{
//TP_IRQ=1;
StartTPTest();
DispPos(TP_X,TP_Y);
Delay(10);
if(((TP_X>=1800)&&(TP_X<=0x2300))&&((TP_Y>=1900)&&(TP_Y<=0x2300)))
{
FillIconWindow(0x0069,0x0091,0xffff);
FG_STEP=FG_STEP<<1;
}
}
//tp test point 2
WriteIconWindow(0x00d2,0x0000,cursorIcon);
while(FG_STEP_2)
{
//TP_IRQ=1;
StartTPTest();
DispPos(TP_X,TP_Y);
Delay(10);
if(((TP_X>=3000)&&(TP_X<=4100))&&((TP_Y>=300)&&(TP_Y<=800)))
{
FillIconWindow(0x00d2,0x0000,0xffff);
FG_STEP=FG_STEP<<1;
}
}
//tp test point 3
WriteIconWindow(0x0000,0x0000,cursorIcon);
while(FG_STEP_3)
{
//TP_IRQ=1;
StartTPTest();
DispPos(TP_X,TP_Y);
Delay(10);
if(((TP_X>=300)&&(TP_X<=800))&&((TP_Y>=300)&&(TP_Y<=800)))
{
FillIconWindow(0x0000,0x0000,0xffff);
FG_STEP=FG_STEP<<1;
}
}
//tp test point 4
WriteIconWindow(0x0000,0x0122,cursorIcon);
while(FG_STEP_4)
{
//TP_IRQ=1;
StartTPTest();
DispPos(TP_X,TP_Y);
Delay(10);
if(((TP_X>=300)&&(TP_X<=800))&((TP_Y>=3000)&&(TP_Y<=3800)))
{
FillIconWindow(0x0000,0x0122,0xffff);
FG_STEP=FG_STEP<<1;
}
}
//tp test point 5
WriteIconWindow(0x00d2,0x0122,cursorIcon);
while(FG_STEP_5)
{
//TP_IRQ=1;
StartTPTest();
DispPos(TP_X,TP_Y);
Delay(10);
if(((TP_X>=3000)&&(TP_X<=4100))&&((TP_Y>=3000)&&(TP_Y<=4100)))
{
FillIconWindow(0x00d2,0x0122,0xffff);
WriteIconWindow(0x0069,0x0091,goodIcon);
FG_STEP=FG_STEP<<1;
DispColor(0xffff);
DrawGird(0x2410);
}
}
// draw line test
while(FG_STEP_6)
{
//TP_IRQ=1;
StartTPTest();
WritePixel(ConvPosX(TP_X),ConvPosY(TP_Y),0xf800);
DispPos(ConvPosX(TP_X),ConvPosY(TP_Y));
}
*/
}
}
/*****************************************************************************
ARRAY DIFINE
*****************************************************************************/
unsigned char code goodIcon[]={
// tp test ok icon,Image size:30 X 30 X 16BPP=1800 bytes. 4 bytes=P(x,y)+P(x+1,y) Data format: 4 bytes(2 pixels)=RRRRRGGG,GGGBBBBB,RRRRRGGG,GGGBBBBB
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xcf,0xf9,0x8f,0xf1,
0x3f,0xe6,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x3f,0xe6,0x8f,0xf1,0xcf,0xf9,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xbf,0xf7,0x3f,0xe6,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x3f,0xe6,0xbf,0xf7,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x6f,0xec,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x6f,0xec,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xfd,0x4f,0xe8,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x4f,0xe8,0xef,0xfd,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0x3f,0xe6,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x1f,0xe2,
0x8f,0xf1,0xef,0xfd,0xff,0xff,0xff,0xff,0xef,0xfd,0x8f,0xf1,0x1f,0xe2,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x4f,0xe8,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xee,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x5f,0xea,0xef,0xfd,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xfd,0x5f,0xea,0x0f,0xe0,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x7f,0xee,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0xff,0xdf,0xfb,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,
0x0f,0xe0,0x6f,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x6f,0xec,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0xdf,0xfb,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0xff,0x6f,0xec,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x2f,0xe4,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0x2f,0xe4,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,
0x6f,0xec,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xef,0xfd,0x1f,0xe2,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0xaf,0xf5,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0x9f,0xf3,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x1f,0xe2,0xef,0xfd,
0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xaf,0xf5,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,
0x0f,0xe0,0x1f,0xe2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x1f,0xe2,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0xaf,0xf5,0xff,0xff,0x00,0x00,
0x00,0x00,0xff,0xff,0x8f,0xf1,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x5f,0xea,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4f,0xe8,0x0f,0xe0,
0x0f,0xe0,0x0f,0xe0,0x0f,0xe0,0x8f,0xf1,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -