pengtaoABC 发表于 2013-3-9 21:57 ![](static/image/common/back.gif)
能上程序方便大家的吗?应该是2块屏参数有些不同,修改下延时应该可以的吧。 ...
//******查忙****///
void busy()
{
p_di=0;
p_rw=1;
while(1)
{
p_e=1;
if(Data<0x80)break;
p_e=0;
}
p_e=0;
}
///*****初始化******///
void Init()
{
//开显示;
p_di=0;
p_rw=0;
Data=0x3f;
p_cs1=0;
p_cs2=1;
p_e=1;
p_e=0;
p_cs1=1;
p_cs2=0;
p_e=1;
p_e=0;
//0行开始显示
busy();
p_cs1=0;
p_cs2=1;
Data=0xc0;
p_e=1;
p_e=0;
p_cs1=1;
p_cs2=0;
p_e=1;
p_e=0;
}
void setxy(unsigned char x,unsigned char y)
{
if(y<64)
{
//***写行地址l**//
busy();
p_di=p_rw=p_cs1=0;
p_cs2=1;
Data=0xb8|x;
p_e=1;
p_e=0;
///***写列地址l**//
busy();
p_di=p_rw=p_cs1=0;
p_cs2=1;
Data=0x40|y;
p_e=1;
p_e=0;
}
else
{
//***写行地址r**//
busy();
p_di=p_rw=p_cs2=0;
p_cs1=1;
Data = 0xb8|x;
p_e=1;
p_e=0;
///***写列地址r**//
busy();
p_di=p_rw=p_cs2=0;
p_cs1=1;
Data=0x40|y;
p_e=1;
p_e=0;
}
}
//****写数据****//
void whitedata(unsigned char x,unsigned char y)
{
busy();
setxy(x,y);//set x,y address address
if(y<64)
{
p_rw=p_cs1=0;
p_cs2=1;
}
else
{
p_rw=p_cs2=0;
p_cs1=1;
}
p_di=1;
Data=0x00;
p_e=1;
p_e=0;
}
/*---------------------------------------------*/
void LCD_write_ASCII(unsigned char page,unsigned char row, unsigned char c) //row:列 page:页 dd:字符
{
unsigned char i,j,k;
k=row*8;
for(i=0;i<2;i++)
{
for(j=0;j<8;j++)
{
busy();
setxy(i+page,(j+k));// 页,列
if(k<64)
{
p_rw=p_cs1=0;
p_di=1;
p_cs2=1;
}
else
{
p_rw=p_cs2=0;
p_di=1;
p_cs1=1;
}
Data=ASCII[c*16+(i*8+j)];
p_e=1;
p_e=0;
}
}
}
/*----------------------------------------------*/
void LCD_write_shu(unsigned char page,unsigned char row, unsigned char c) //row:列 page:页 dd:字符
{
unsigned char i,j,k;
k=row*16;
for(i=0;i<4;i++)
{
for(j=0;j<16;j++)
{
busy();
setxy(i+page,(j+k));// 页,列
if(k<64)
{
p_rw=p_cs1=0;
p_di=1;
p_cs2=1;
}
else
{
p_rw=p_cs2=0;
p_di=1;
p_cs1=1;
}
Data=shuzi[(c*64)+(i*16+j)];
p_e=1;
p_e=0;
}
}
}
///******* 显示16点阵汉字******///
void white_hanzi_16(unsigned char page,unsigned char row, unsigned char c) //row:列 page:页 dd:字符
{
unsigned char i,j,k;
k=row*16;
for(i=0;i<2;i++)
{
for(j=0;j<16;j++)
{
busy();
setxy(i+page,(j+k));// 页,列
if(k<64)
{
p_rw=p_cs1=0;
p_di=1;
p_cs2=1;
}
else
{
p_rw=p_cs2=0;
p_di=1;
p_cs1=1;
}
Data=HZK_16[(c*32)+(i*16+j)];
p_e=1;
p_e=0;
}
}
}
void LCD_clr_row(unsigned char num)
{
unsigned char j;
busy();
for(j=0;j<128;j++)
whitedata(num,j);
}
///****清屏***//
void clear()
{
unsigned char i,j;
busy();
for(i=0;i<8;i++)
for(j=0;j<128;j++)
whitedata(i,j);
}
/****写图像数据****/
void whitedata_BMP(unsigned char x,unsigned char y)
{
busy();
setxy(x,y);//set x,y address address
if(y<64)
{
p_rw=p_cs1=0;
p_cs2=1;
}
else
{
p_rw=p_cs2=0;
p_cs1=1;
}
p_di=1;
Data=BMP1[x*128+y];
p_e=1;
p_e=0;
}
/******显示图像******/
void DIS_BMP (void)
{
unsigned char i,j;
for(i=0;i<8;i++)
for(j=0;j<128;j++)
whitedata_BMP(i,j);
}
|