微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 128*64 LCD显示驱动程序

128*64 LCD显示驱动程序

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

lck = 0;
P1 = 0x22; //E = 1;R/W = 0;D/I = 0; CS1 = 0; CS2 = 1;
lck = 1;
P0 = cbyte;
lck = 0;
P1 = 0x00; //E = 0;
lck = 1;
}

//=========================================================
//LCD屏幕点定位函数
void Locate(uchar page,uchar col)
{
uchar com_page,com_col,right;
switch(col&0xc0)
{
case 0x00: //左半屏幕
{
right = 0;
break;
}
case 0x40: //右半屏幕
{
right = 1;
break;
}
default: break;
}
com_page = page&0x07|0xb8; //将页数据转换为页命令字
com_col = col&0x3f|0x40; //将列数据转换为列命令字

switch(right)
{
case 0x00: //左半屏幕
{
WrComL(com_page);
WrComL(com_col);
status = 0;
break;
}
case 0x01: //右半屏幕
{
WrComR(com_page);
WrComR(com_col);
status = 1;
break;
}
default: break;
}
}

//=========================================================
//写数据函数
void WrData(uchar databyte,uchar page,uchar col)
{
Locate(page,col);

P0 = databyte;

lck = 0;
if(status)
P1 = 0x26; //E = 1; R/W = 0; D/I = 1; CS1 = 0; CS2 = 1;
else
P1 = 0x25; //E = 1; R/W = 0; D/I = 1; CS1 = 1; CS2 = 0;
lck = 1;

//P0 = databyte;

lck = 0;
P1 = 0x00;
lck = 1;
}

//=========================================================
//图形函数,图像按页下移
/*void PicturePage(void)
{
uchar col,page;
uchar i = 0;
ClrLcd(0x00);
for(col=64;col<72;col++)
{
for(page=pagebyte;page{
WrData(A[i++],page++,col);
}
}
}*/

//=========================================================
//图形左移函数
void PictureCol(void)
{
uchar col,page;
uchar i = 0;
ClrLcd(0x00);
for(col=colbyte;(col=0);) //列控制
{
for(page=0;page<2;page++) //页控制
{
WrData(A[i++],page,col); //写数据,“i++”同步跟新数据
}
col++;
}
if(colbyte==0)
colbyte = 120;

}


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

网站地图

Top