微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > TFT液晶屏C51控制

TFT液晶屏C51控制

时间:11-18 来源:互联网 点击:

//------------------ Set GRAM area ---------------//
LCD_Write_REG(0x0050); LCD_Write_DATA(0x0000); // Horizontal GRAM Start AddLCD_RSTs
LCD_Write_REG(0x0051); LCD_Write_DATA(0x00EF); // Horizontal GRAM End AddLCD_RSTs
LCD_Write_REG(0x0052); LCD_Write_DATA(0x0000); // Vertical GRAM Start AddLCD_RSTs
LCD_Write_REG(0x0053); LCD_Write_DATA(0x013F); // Vertical GRAM Start AddLCD_RSTs

//LCD_Write_REG(0x0060); LCD_Write_DATA(0xA700); // Gate Scan Line //影响扫描位置
LCD_Write_REG(0x0060); LCD_Write_DATA(0x2700); // Gate Scan Line nnnnnnnnnnnnn

LCD_Write_REG(0x0061); LCD_Write_DATA(0x0001); // NDL,VLE, REV
LCD_Write_REG(0x006A); LCD_Write_DATA(0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
LCD_Write_REG(0x0080); LCD_Write_DATA(0x0000);
LCD_Write_REG(0x0081); LCD_Write_DATA(0x0000);
LCD_Write_REG(0x0082); LCD_Write_DATA(0x0000);
LCD_Write_REG(0x0083); LCD_Write_DATA(0x0000);
LCD_Write_REG(0x0084); LCD_Write_DATA(0x0000);
LCD_Write_REG(0x0085); LCD_Write_DATA(0x0000);
//-------------- Panel Control -------------------//
LCD_Write_REG(0x0090); LCD_Write_DATA(0x0010);
LCD_Write_REG(0x0092); LCD_Write_DATA(0x0600);
//添加
LCD_Write_REG(0x0093); LCD_Write_DATA(0x0003);
LCD_Write_REG(0x0095); LCD_Write_DATA(0x0110);
LCD_Write_REG(0x0097); LCD_Write_DATA(0x0000);
LCD_Write_REG(0x0098); LCD_Write_DATA(0x0000);

//LCD_Write_REG(0x0007); LCD_Write_DATA(0x0133); // 262K color and display ON
LCD_Write_REG(0x0007); LCD_Write_DATA(0x0173); // 262K color and display ON nnnnnnnnnn
LCD_Clear(0);//设置底色为黑
}

/**********************************************
函数名:Lcd全屏擦除函数
功能:将Lcd整屏擦为指定颜色
入口参数:color 指定Lcd全屏颜色 RGB(5-6-5)
返回值:无
***********************************************/
void LCD_Clear(unsigned int Color)
{
unsigned long index = 0;

LCD_Write_REG_DATA(0x0020,0x0000);//GRAM水平起始位置
LCD_Write_REG_DATA(0x0021,00000);

LCD_Write_REG_DATA(0x0050,0x00);//水平 GRAM起始位置
LCD_Write_REG_DATA(0x0051,239);//水平GRAM终止位置
LCD_Write_REG_DATA(0x0052,0x00);//垂直GRAM起始位置
LCD_Write_REG_DATA(0x0053,319);//垂直GRAM终止位置
LCD_Write_REG(0x0022);

LCD_RD=1;
LCD_RS=1;
LCD_CS=0;
for(index = 0; index < 76800; index++)
{

LCD_WR=0;
LCD_DATA_PORT=Color>>8;
LCD_WR=1;
LCD_WR=0;
LCD_DATA_PORT=Color&0XFF;
LCD_WR=1;

}
LCD_CS=1;
}

////////////////////////////////////////////////////
void LCD_write_english(unsigned char data1,unsigned int color,unsigned int xcolor)//写字符
{

unsigned char avl,i,n;
LCD_Write_REG(0x0022);
for (i=0;i<16;i++)
{
avl=english[data1-32][i];
for (n=0;n<8;n++)
{
if(avl&0x80) LCD_Write_DATA(color);
else LCD_Write_DATA(xcolor);

avl<=1;
}
}
}
void LCD_write_english_string(unsigned int x,unsigned int y,unsigned char *s,unsigned int color,unsigned int xcolor)//英文字符串显示
{
unsigned int k=0;
while (*s)
{
Lcd_SetBox(y,x+k,15,8);
LCD_write_english( *s,color,xcolor);
k=k+8;
s++;

}

}

void Lcd_SetBox(unsigned int xStart,unsigned int yStart,unsigned int xLong,unsigned int yLong)
{

LCD_SetCursor(xStart,312-yStart+yLong-1);

LCD_Write_REG_DATA(0x0050,xStart);//水平 GRAM起始位置
LCD_Write_REG_DATA(0x0051,xStart+xLong-1);//水平GRAM终止位置
LCD_Write_REG_DATA(0x0052,312-yStart);//垂直GRAM起始位置
LCD_Write_REG_DATA(0x0053,312-yStart+yLong-1);//垂直GRAM终止位置
}

/*************************************************
函数名:Lcd光标起点定位函数
功能:指定320240液晶上的一点作为写数据的起始点
入口参数:x 坐标 0~239
y 坐标 0~319
返回值:无
*************************************************/
void LCD_SetCursor(unsigned int Xpos, unsigned int Ypos)
{
// CLR_RS;
LCD_Write_REG_DATA(0x20, Xpos);
LCD_Write_REG_DATA(0x21, Ypos);
}
////////////////显示图片///////////////////////////
void LCD_picture_diplay(void)
{
uint i,x1,y1,x2,y2;
uint temp1,temp2,temp;
x1=0;
y1=0;
x2=100;
y2=99;
LCD_Add_Set(x1,y1,x2,y2);

for (i=0;i<20000;i=i+2)
{
temp2=gImage[i];
temp1=gImage[i+1];
temp=(temp1*256)+temp2;
LCD_Write_DATA(temp);
}
}
////////////////显示彩条///////////////////////////
void LCD_caitiao_diplay(uchar x,uint color)
{
uint i,x1,y1,x2,y2;
x1=x;
y1=0;
x2=x+20;
y2=319;
LCD_Add_Set(x1,y1,x2,y2);

for (i=0;i<320*20;i++)
{
LCD_Write_DATA(color);
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top