Beispiel #1
0
//*************************************************************************************
__inline void TFT_SendData(int Data)
{
	int data1 = Data>>8;
	int data2 = Data&0xff;
	TFT_WriteData(data1);
	TFT_WriteData(data2);
}
Beispiel #2
0
void GUI_WriteASCII(uint x, uint y, uchar *p, uint wordColor, uint backColor)
{
	uchar j, wordByte,wordNum;
	uint color;
	while(*p != '\0')
	{
		wordNum = *p - 32;
		TFT_SetWindow(x,y,x+15, y+23);
		for (wordByte=0; wordByte<48; wordByte++)
		{
			color = ASCII16x24[wordNum][wordByte];
			for (j=0; j<8; j++) 
			{
				if ((color&0x80) == 0x80)
				{
					TFT_WriteData(wordColor);
				} 						
				else
				{
					TFT_WriteData(backColor);
				} 	
				color <<= 1;
			}
		}
		p++;
		x +=14;
	}
}
Beispiel #3
0
void GUI_Write14CnChar(uint x,uint y,uchar *cn,uint wordColor,uint backColor)	 
{  
	uchar i, j, wordNum;
	uint color;
	while (*cn != '\0')
	{
		TFT_SetWindow(x, y, x+23, y+18);
		for (wordNum=0; wordNum<20; wordNum++)
		{	//wordNum扫描字库的字数
			if ((CnChar19x24[wordNum].Index[0]==*cn)
			     &&(CnChar19x24[wordNum].Index[1]==*(cn+1)))
			{
				for(i=0; i<57; i++) 
				{	//MSK的位数
					color=CnChar19x24[wordNum].Msk[i];
					for(j=0;j<8;j++) 
					{
						if((color&0x80)==0x80)
						{
							TFT_WriteData(wordColor);
						} 						
						else
						{
							TFT_WriteData(backColor);
						} 
						color<<=1;
					}//for(j=0;j<8;j++)结束
				}    
			}
		} //for (wordNum=0; wordNum<20; wordNum++)结束 	
		cn += 2;
		x += 24;
	}
}
Beispiel #4
0
//*************************************************************************************
void TFT_ClearScreen(void)
{
	int i=0;
	TFT_SetCol(0, MAX_X);
	TFT_SetPage(0, MAX_Y);
	TFT_SendCMD(0x2c);                                                  /* start to write to display ra */
	/* m                            */
	for(i=0; i<38400; i++)
	{
		TFT_WriteData(~0);
		TFT_WriteData(~0);
		TFT_WriteData(~0);
		TFT_WriteData(~0);
	}
}
Beispiel #5
0
//*************************************************************************************
void TFT_SetOrientation(int orient)
{
	TFT_SendCMD(0x36);
	switch (orient)
	{
		case 0: TFT_WriteData(0x48);
				break;
		case 1: TFT_WriteData(0x28);
				break;
		case 2: TFT_WriteData(0x88);
				break;
		case 3: TFT_WriteData(0xE8);
				break;
	}
	if (orient == 0 || orient == 2)
	{ MAX_X = 239; MAX_Y = 319;	}
	else
	{ MAX_X = 319;	MAX_Y = 239;}
}
Beispiel #6
0
u8 GUI_Writeu16(uint x, uint y, u16 temp, uint wordColor, uint backColor)
{
	uchar i,j,i1=0, wordByte,wordNum;
	static uint color;
	static u8 wordNuma[6];
	u8 plus=0;
	wordNuma[0]=temp/10000;
	temp=temp%10000;
	wordNuma[1]=temp/1000;
	temp=temp%1000;
	wordNuma[2]=temp/100;
	temp=temp%100;
	wordNuma[3]=temp/10;
	wordNuma[4]=temp%10;
		while(wordNuma[i1]==0){i1++;}
    if(i1==5)i1=4;
	
    GUI_WriteASCII( x, y, "     ", 0xf800, 0x0000);
	for(i=i1;i<5;i++) 
	{
		wordNum = wordNuma[i] + 16;
		TFT_SetWindow(x,y,x+15, y+23);
		for (wordByte=0; wordByte<48; wordByte++)
		{
			color = ASCII16x24[wordNum][wordByte];
			for (j=0; j<8; j++) 
			{
				if ((color&0x80) == 0x80)
				{
					TFT_WriteData(wordColor);
				} 						
				else
				{
					TFT_WriteData(backColor);
				} 	
				color <<= 1;
			}
		}
		x +=14;
		plus++;
	}
	return  plus;
}
Beispiel #7
0
void GUI_Dot(uint x, uint y, uint color)
{  
	uchar i;

	TFT_SetWindow(x-1, y, x+2, y+2);  //单个像素

	for(i=0; i<16; i++)
	{
		TFT_WriteData(color);
	}
}
Beispiel #8
0
//*************************************************************************************
void TFT_FillScreen(int XL, int XR, int YU, int YD, int color)
{
	unsigned long  XY=0;
	unsigned long i=0;
	color = ~color;
	if(XL > XR)
	{
		XL = XL^XR;
		XR = XL^XR;
		XL = XL^XR;
	}
	if(YU > YD)
	{
		YU = YU^YD;
		YD = YU^YD;
		YU = YU^YD;
	}
	XL = constrain(XL, MIN_X,MAX_X);
	XR = constrain(XR, MIN_X,MAX_X);
	YU = constrain(YU, MIN_Y,MAX_Y);
	YD = constrain(YD, MIN_Y,MAX_Y);

	XY = (XR-XL+1);
	XY = XY*(YD-YU+1);

	TFT_SetCol(XL,XR);
	TFT_SetPage(YU, YD);
	TFT_SendCMD(0x2c);                                                  /* start to write to display ra */
	/* m                            */

	int Hcolor = color>>8;
	int Lcolor = color&0xff;
	for(i=0; i < XY; i++)
	{
		TFT_WriteData(Hcolor);
		TFT_WriteData(Lcolor);
	}

}
Beispiel #9
0
void GUI_ShowPicture(uint x, uint y, uchar wide, uint high)
{
	uint temp = 0, tmp = 0, num = 0;
	TFT_SetWindow(x, y, x+wide-1, y+high-1);
	num = wide * high * 2;
	do
	{  
		temp = pic[tmp + 1];
		temp = temp << 8;
		temp = temp | pic[tmp];
		TFT_WriteData(temp);//逐点显示
		tmp += 2;
	}
	while(tmp < num);	
}
Beispiel #10
0
//*************************************************************************************
void TFT_Init(int orient)
{
TFT_SendCMD  (0x01);
CyDelay(100);
//************* Start Initial Sequence **********//
//Power control A
TFT_SendCMD  (0xCB);
TFT_WriteData(0x39);
TFT_WriteData(0x2C);
TFT_WriteData(0x00);
TFT_WriteData(0x34);
TFT_WriteData(0x02);

//Power control B
TFT_SendCMD  (0xCF);
TFT_WriteData(0x00);
TFT_WriteData(0XC1);
TFT_WriteData(0X30);

//Driver timing control A
TFT_SendCMD  (0xE8);
TFT_WriteData(0x85);
TFT_WriteData(0x00);
TFT_WriteData(0x78);

//Driver timing control B
TFT_SendCMD  (0xEA);
TFT_WriteData(0x00);
TFT_WriteData(0x00);

//Power on sequence control
TFT_SendCMD(0xED);
TFT_WriteData(0x64);
TFT_WriteData(0x03);
TFT_WriteData(0X12);
TFT_WriteData(0X81);

//Pump ratio control
TFT_SendCMD (0xF7);
TFT_WriteData(0x20);

//Power Control 1
TFT_SendCMD  (0xC0);
TFT_WriteData(0x23);

//Power Control 2
TFT_SendCMD  (0xC1);
TFT_WriteData(0x10);

//VCOM Control 1
TFT_SendCMD(0xC5);
TFT_WriteData(0x2B);
TFT_WriteData(0x2B);

//Memory Access Control
TFT_SetOrientation(orient);

//Frame Rate Control (In Normal Mode/Full Colors)
TFT_SendCMD(0xB1);
TFT_WriteData(0x00);
TFT_WriteData(0x1B);	// 10

//Display Function Control
TFT_SendCMD(0xB6);
TFT_WriteData(0x0A);
TFT_WriteData(0x82);	// A2  (02 inverts display)

//Enable 3G
TFT_SendCMD(0xF2);
TFT_WriteData(0x02);  //off


//COLMOD: Pixel Format Set
TFT_SendCMD(0x3a);
TFT_WriteData(0x05);  // 0x03 for 19-bit

//Gamma Set
TFT_SendCMD(0x26);   //Gamma
TFT_WriteData(0x01);

//Positive Gamma Correction
TFT_SendCMD(0xE0);
TFT_WriteData(0x0F);
TFT_WriteData(0x31);
TFT_WriteData(0x2B);
TFT_WriteData(0x0C);
TFT_WriteData(0x0E);
TFT_WriteData(0x08);
TFT_WriteData(0x4E);
TFT_WriteData(0xF1);
TFT_WriteData(0x37);
TFT_WriteData(0x07);
TFT_WriteData(0x10);
TFT_WriteData(0x03);
TFT_WriteData(0x0E);
TFT_WriteData(0x09);
TFT_WriteData(0x00);

//Negative Gamma Correction
TFT_SendCMD(0XE1);
TFT_WriteData(0x00);
TFT_WriteData(0x0E);
TFT_WriteData(0x14);
TFT_WriteData(0x03);
TFT_WriteData(0x11);
TFT_WriteData(0x07);
TFT_WriteData(0x31);
TFT_WriteData(0xC1);
TFT_WriteData(0x48);
TFT_WriteData(0x08);
TFT_WriteData(0x0F);
TFT_WriteData(0x0C);
TFT_WriteData(0x31);
TFT_WriteData(0x36);
TFT_WriteData(0x0F);

// Sleep Out
TFT_SendCMD(0x11);
CyDelay(120);
//Display On
TFT_SendCMD(0x29);

}