`#include
#include"LCD_driver.h"
#include"picture.h"
main()
{
int j;
LCD_Init(); //TFT初始化
Pant( colors[2]>>8 , colors[2]);
LCD_CS =0; //打开片选使能
Address_set(0,0,180,240); //设置坐标
for (j=0;j<60000/2;j++) //显示 60552个像素点
{
LCD_Write_DATA(Image[j*2+1],Image[j*2]);
}
LCD_CS =1;
while(1)
{
}
}
#include
#include"LCD_driver.h"
uint colors[]=
{
0xf800,0x07e0,0x001f,0xffe0,0x0000,0x07ff,0xf81f,0xffff
};
void LCD_Init(void)
{
LCD_REST=1;
delayms(50);
LCD_REST=0;
delayms(50);
LCD_REST=1;
delayms(5);
LCD_CS =0; //打开片选使能
/********************** 以下初始化代码 每个命令下带有不同数量的参数**************************/
LCD_Write_COM(0XF0); //参考S6D04H0驱动IC手册.pdf 文档的 220页 //LCD_Write_COM函数 发送命令 LCD_Write_Para函数 传递该命令下的参数
LCD_Write_Para(0X5A);
LCD_Write_Para(0X5A);
//APON CONTROL
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
//SLEEP OUT
LCD_Write_COM(0X11); //参考S6D04H0驱动IC手册.pdf 文档的 165页
delayms(10);
//POWER CONTROL VC = "0111"
LCD_Write_COM(0XF4); //参考S6D04H0驱动IC手册.pdf 文档的 228页
LCD_Write_Para(0X07);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X21);
LCD_Write_Para(0X47);
LCD_Write_Para(0X01);
LCD_Write_Para(0X02);
LCD_Write_Para(0X3F);
LCD_Write_Para(0X66);
LCD_Write_Para(0X05);
//POWER CONTROL VC = "0111"
LCD_Write_COM(0XF4); //参考S6D04H0驱动IC手册.pdf 文档的 228页 带有20个参数
LCD_Write_Para(0X07);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X21);
LCD_Write_Para(0X47);
LCD_Write_Para(0X04);
LCD_Write_Para(0X02);
LCD_Write_Para(0X2A);
LCD_Write_Para(0X7d);
LCD_Write_Para(0X05);
LCD_Write_COM(0XF2); //参考S6D04H0驱动IC手册.pdf 文档的 221页
LCD_Write_Para(0X28);
LCD_Write_Para(0X60);
LCD_Write_Para(0X03);
LCD_Write_Para(0X04);
LCD_Write_Para(0X04);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X15);
LCD_Write_Para(0X48);
LCD_Write_Para(0X00);
LCD_Write_Para(0X07);
LCD_Write_Para(0X01);
LCD_Write_COM(0XF5); //参考S6D04H0驱动IC手册.pdf 文档的 235页
LCD_Write_Para(0X00);
LCD_Write_Para(0X1d);
LCD_Write_Para(0X4f);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X06);
//POWER CONTROL
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0X03);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
delayms(5);
//POWER CONTROL
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0X0F);
LCD_Write_Para(0X09);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
delayms(5);
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0X0F);
LCD_Write_Para(0X01);
delayms(10);
//POWER CONTROL
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0X1F);
delayms(20);
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0X3F);
delayms(10);
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0X3F);
LCD_Write_Para(0X03);
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0X7F);
delayms(30);
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0XFF);
/*LCD_Write_COM(0XFD);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X10);
LCD_Write_Para(0X14);
LCD_Write_Para(0X12);
LCD_Write_Para(0X00); */
delayms(20);
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X00);
LCD_Write_Para(0XFF);
LCD_Write_Para(0X1F);
LCD_Write_Para(0X00);
LCD_Write_Para(0X02);
delayms(20);
LCD_Write_COM(0XF3); //参考S6D04H0驱动IC手册.pdf 文档的 227页
LCD_Write_Para(0X01);
LCD_Write_COM(0XF0);
LCD_Write_Para(0Xa5);
LCD_Write_Para(0Xa5);
LCD_Write_COM(0X36); //参考S6D04H0驱动IC手册.pdf 文档的 189页
LCD_Write_Para(0X48);
LCD_Write_COM(0X3a); //参考S6D04H0驱动IC手册.pdf 文档的 195页
LCD_Write_Para(0X55); //16bit (66 18bit)
//gamma
//red
/* LCD_Write_COM(0Xf9);
LCD_Write_Para(0X04);
LCD_Write_COM(0XFA);
LCD_Write_Para(0x0a);
LCD_Write_Para(0x08);
LCD_Write_Para(0X18);
LCD_Write_Para(0X1d);
LCD_Write_Para(0X1e);
LCD_Write_Para(0X20);
LCD_Write_Para(0X15);
LCD_Write_Para(0X3E);
LCD_Write_Para(0X2e);
LCD_Write_Para(0X1c);
LCD_Write_Para(0X0a);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_COM(0XFB);
LCD_Write_Para(0x00);
LCD_Write_Para(0x00);
LCD_Write_Para(0X1F);
LCD_Write_Para(0X1d);
LCD_Write_Para(0X1e);
LCD_Write_Para(0X20);
LCD_Write_Para(0X15);
LCD_Write_Para(0X3E);
LCD_Write_Para(0X2f);
LCD_Write_Para(0X1c);
LCD_Write_Para(0X0a);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
//green
/* LCD_Write_COM(0XF9);
LCD_Write_Para(0X02);
LCD_Write_COM(0XFA);
LCD_Write_Para(0x0a);
LCD_Write_Para(0x08);
LCD_Write_Para(0X1f);
LCD_Write_Para(0X1d);
LCD_Write_Para(0X1e);
LCD_Write_Para(0X20);
LCD_Write_Para(0X15);
LCD_Write_Para(0X3E);
LCD_Write_Para(0X2e);
LCD_Write_Para(0X1c);
LCD_Write_Para(0X0a);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_COM(0XFB);
LCD_Write_Para(0x00);
LCD_Write_Para(0x00);
LCD_Write_Para(0X1F);
LCD_Write_Para(0X1d);
LCD_Write_Para(0X1e);
LCD_Write_Para(0X20);
LCD_Write_Para(0X15);
LCD_Write_Para(0X3E);
LCD_Write_Para(0X2f);
LCD_Write_Para(0X1c);
LCD_Write_Para(0X0a);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_COM(0XF9);
LCD_Write_Para(0X01);
//blue
LCD_Write_COM(0XFA);
LCD_Write_Para(0x0a);
LCD_Write_Para(0x08);
LCD_Write_Para(0X1f);
LCD_Write_Para(0X1d);
LCD_Write_Para(0X1e);
LCD_Write_Para(0X20);
LCD_Write_Para(0X15);
LCD_Write_Para(0X3E);
LCD_Write_Para(0X2e);
LCD_Write_Para(0X1c);
LCD_Write_Para(0X0a);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
/* LCD_Write_COM(0XFB);
LCD_Write_Para(0x00);
LCD_Write_Para(0x00);
LCD_Write_Para(0X1F);
LCD_Write_Para(0X1d);
LCD_Write_Para(0X1e);
LCD_Write_Para(0X20);
LCD_Write_Para(0X15);
LCD_Write_Para(0X3E);
LCD_Write_Para(0X2f);
LCD_Write_Para(0X1c);
LCD_Write_Para(0X0a);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00);
LCD_Write_Para(0X00); */
delayms(120);
LCD_Write_COM(0x29); //显示打开 //参考S6D04H0驱动IC手册.pdf 文档的 173页
LCD_Write_COM(0x2c); //写数据到RAM中 //参考S6D04H0驱动IC手册.pdf 文档的 270页
LCD_CS =1; //关闭使能
}
void LCD_Write_COM(char VL) //发送命令
{
LCD_RS=0;
LCD_DataPortL=VL; //低位P0口
LCD_WR=0;
LCD_WR=1;
}
void LCD_Write_Para(char VL) //发送数据
{
LCD_RS=1;
LCD_DataPortL=VL; //低位P0口
LCD_WR=0;
LCD_WR=1;
}
void delayms(int count) // /* X1ms */
{
int i,j;
for(i=0;i
for(j=0;j<100;j++);
}
void LCD_Writ_Bus(char VH,char VL) //并行数据写入函数
{
LCD_DataPortH=VH;
LCD_DataPortL=VL;
LCD_WR=0;
LCD_WR=1;
}
void LCD_Write_DATA(char VH,char VL) //发送数据
{
LCD_RS=1;
LCD_Writ_Bus(VH,VL);
}
void Pant(char VH,char VL)
{
int i,j;
LCD_CS =0; //打开片选使能
Address_set(0,0,240,320);
for(i=0;i<320;i++)
{
for (j=0;j<240;j++)
{
LCD_Write_DATA(VH,VL);
}
}
LCD_CS =1; //关闭片选使能
}
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
LCD_Write_COM(0X2A); //设置X坐标地址 //参考S6D04H0驱动IC手册.pdf 文档的 174页
LCD_Write_Para(x1>>8); //开始X
LCD_Write_Para(x1); //开始X
LCD_Write_Para(x2>>8); //结束X
LCD_Write_Para(x2); //结束X
LCD_Write_COM(0X2B); //设置Y坐标地址 //参考S6D04H0驱动IC手册.pdf 文档的 176页
LCD_Write_Para(y1>>8); //开始Y
LCD_Write_Para(y1); //开始Y
LCD_Write_Para(y2>>8); //结束Y
LCD_Write_Para(y2); //结束Y
//LCD_Write_COM(0x13);
LCD_Write_COM(0x29); //显示打开 //参考S6D04H0驱动IC手册.pdf 文档的 173页
LCD_Write_COM(0x2c); //写数据到RAM中 //参考S6D04H0驱动IC手册.pdf 文档的 270页
}
怎样设置图片,怎样可以显示全屏图片,寄存器是什么意思?????????、
求救给位大神
`
|