//************* Start Initial Sequence **********//
Write_Cmd_Data(0x00,0x0001); //Set the OSC bit as ‘1’ to start the internal oscillator
Write_Cmd_Data(0x01,0x0100); // set SS and SM bit
Write_Cmd_Data(0x02,0x0700); // set 1 line inversion
Write_Cmd_Data(0x03,0x1030); //set GRAM Write direction and BGR=1
Write_Cmd_Data(0x04,0x0000); // Resize register
Write_Cmd_Data(0x08,0x0202); // set the back porch and front porch
Write_Cmd_Data(0x09,0x0000); // set non-display area refresh cycle ISC[3:0]
Write_Cmd_Data(0x0A,0x0000); // FMARK function
Write_Cmd_Data(0x0C,0x0000); // RGB interface setting
Write_Cmd_Data(0x0D,0x0000); // Frame marker Position
Write_Cmd_Data(0x0F,0x0000); // RGB interface polarity
delayms(30);
//*************Power On sequence ****************//
Write_Cmd_Data(0x10, 0x16b0); // SAP, BT[3:0], AP, DSTB, SLP, STB
delayms(30);
Write_Cmd_Data(0x11, 0x0007); //Write final user’s setting values to VC bit
Write_Cmd_Data(0x12, 0x013a); // set Internal reference voltage
Write_Cmd_Data(0x13, 0x1a00); // VDV[4:0] for VCOM amplitude
delayms(30);
Write_Cmd_Data(0x29, 0x000c); // Set VCM[5:0] for VCOMH
delayms(30); // Delay 50ms
//-------------- Display on ---------//
Write_Cmd_Data(0x07,0x0173);
}
else if(Device_code==0x1505 )
{
//************* Start Initial Sequence **********//
Write_Cmd_Data(0x00,0x0001); //Set the OSC bit as ‘1’ to start the internal oscillator
Write_Cmd_Data(0x01,0x0100); // set SS and SM bit
Write_Cmd_Data(0x02,0x0700); // set 1 line inversion
Write_Cmd_Data(0x03,0x1030); //set GRAM Write direction and BGR=1
Write_Cmd_Data(0x04,0x0000); // Resize register
Write_Cmd_Data(0x08,0x0202); // set the back porch and front porch
Write_Cmd_Data(0x09,0x0000); // set non-display area refresh cycle ISC[3:0]
Write_Cmd_Data(0x0A,0x0000); // FMARK function
Write_Cmd_Data(0x0C,0x0000); // RGB interface setting
Write_Cmd_Data(0x0D,0x0000); // Frame marker Position
Write_Cmd_Data(0x0F,0x0000); // RGB interface polarity
delayms(30);
//*************Power On sequence ****************//
Write_Cmd_Data(0x10, 0x16b0); // SAP, BT[3:0], AP, DSTB, SLP, STB
delayms(30);
Write_Cmd_Data(0x11, 0x0007); //Write final user’s setting values to VC bit
Write_Cmd_Data(0x12, 0x013a); // set Internal reference voltage
Write_Cmd_Data(0x13, 0x1a00); // VDV[4:0] for VCOM amplitude
delayms(30);
Write_Cmd_Data(0x29, 0x000c); // Set VCM[5:0] for VCOMH
delayms(30); // Delay 50ms
//-------------- Display on ---------//
Write_Cmd_Data(0x07,0x0173);
}
else if(Device_code==0x9328)
{
//************* Start Initial Sequence **********//
Write_Cmd_Data(0x0001,0x0100); //set SS and SM bit //设置扫描方向 100
Write_Cmd_Data(0x0002,0x0700); //EOR=1 and B/C=1 to set the line inversion //设置行反转
Write_Cmd_Data(0x0003,0x1030); //set Entry Mode //设置进入模式 1030
Write_Cmd_Data(0x0004,0x0000); //
Write_Cmd_Data(0x00A4,0x0001);
Write_Cmd_Data(0x0008,0x0202); // set the back porch and front porch
Write_Cmd_Data(0x0009,0x0000); // set non-display area refresh cycle ISC[3:0]
Write_Cmd_Data(0x000A,0x0000); // FMARK function
Write_Cmd_Data(0x000C,0x0000); // RGB interface setting
Write_Cmd_Data(0x000D, 0x0000); // Frame marker Position
Write_Cmd_Data(0x000F, 0x0000); // RGB interface polarity
/****************************************************************************************************
// 实现功能: 画点
// 输入参数: x,y 需要画点坐标
// color 点的颜色
****************************************************************************************************/
void Put_pixel(unsigned int x,unsigned int y,unsigned int color)
{
LCD_SetPos(x,x,y,y); //横屏这里要进行坐标变换,如果是竖屏,则直接是x0,x1,y0,y1做参数
Write_Data_U16(color); //在指定点写入颜色数据
}
```
TFT.H
```c
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef uint
#define uint unsigned int
#endif
unsigned char pic[];
void TFT_Initial(void);
void show_colour_bar (void);
void Write_Cmd_Data(unsigned char x, unsigned int y);
void Write_Cmd(unsigned char DH,unsigned char DL);
void Write_Data(unsigned char DH,unsigned char DL);
void delayms(unsigned int tt);
void show_photo(void);
void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color);
void Write_Data_U16(unsigned int y);
void CLR_Screen(unsigned int bColor);
void PutGB3232(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor);
void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor);
void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor);
void LCD_PutString24(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor);
void LCD_PutChar8x8(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor);
void Put16x16(unsigned short x, unsigned short y, unsigned char g[2], unsigned int fColor,unsigned int bColor);
void Put_pixel(unsigned int x,unsigned int y,unsigned int color);
void address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);
void LCD_SetPos(unsigned short x0,unsigned short x1,unsigned short y0,unsigned short y1);
void line(int x1,int y1,int x2,int y2,int color);
void draw_circle(int x, int y, int r, int color);
void LCD_PutSingleChar(unsigned int x, unsigned int y, char c, unsigned int fColor, unsigned int bColor);