新聞中心

AM12864測試C語言程序

作者: 時(shí)間:2013-01-15 來源:網(wǎng)絡(luò) 收藏

/*------------------延時(shí)子程序-----------------------------*/
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0;it;i++) ;
for(j=0;j10;j++) ;
}
/*------------------寫命令到LCD------------------------------*/
void write_com(unsigned char cmdcode)
{
do{delay(0);}while(P0^7==1);
Di=0;
RW=0;
Lcd_Bus=cmdcode;
delay(0); //原來是delay(0)
Enable=1;
delay(0);
Enable=0;

}
/*-------------------寫數(shù)據(jù)到LCD----------------------------*/
void write_data(unsigned char Dispdata)
{ do{delay(10);}while(P0^7==1);
Di=1;
RW=0;
Lcd_Bus=Dispdata;
delay(0);
Enable=1;
delay(0);
Enable=0;
}
/*-------------------讀LCD數(shù)據(jù)----------------------------*/
unsigned char read_data()
{ //do{delay(100);}while(P0^7==1);
unsigned char tmpin;
Di=1;
RW=1;
delay(0);
Enable=1;
delay(0);
Enable=0;do{delay(100);}while(P0^7==1);
tmpin=Lcd_Bus;
return tmpin;
}
/*------------------顯示邊框-------------------------------*/
void frame()
{
unsigned char i;
Mcs=1;
Scs=1;
write_com(Page_Add+0);
write_com(Col_Add+0);
for(i=0;i64;i++) write_data(0x01);
write_com(Page_Add+7);
write_com(Col_Add+0);
for(i=0;i64;i++) write_data(0x80);
for(i=0;i8;i++)
{
Mcs=0;
Scs=1;
write_com(Page_Add+i);
write_com(Col_Add+63);
write_data(0x55);
Mcs=1;
Scs=0;
write_com(Page_Add+i);
write_com(Col_Add+0);
write_data(0x55);
}
}
/*------------------清除內(nèi)存程序---------------*/
void Clr_Scr()
{
unsigned char j,k;
Mcs=1;Scs=1;
write_com(Page_Add+0);
write_com(Col_Add+0);
for(k=0;k8;k++){
write_com(Page_Add+k);
for(j=0;j64;j++)write_data(0x00);
}
}
/*------------------顯示12864圖片---------------------------*/
void Disp_Img(unsigned char code *img)
{
unsigned char j,k;
for(k=0;k8;k++){
Mcs=1;Scs=0;delay(0);
write_com(Page_Add+k);
write_com(Col_Add+0);

for(j=0;j64;j++) write_data(img[k*128+j]);
Mcs=0;Scs=1; delay(0);
write_com(Page_Add+k);
write_com(Col_Add+0);
for(j=64;j128;j++) write_data(img[k*128+j]);
}
}
/*------------------顯示橫--------------程序-------------*/
void Disp_H_Line()
{
unsigned char i,j;
Mcs=1;
Scs=1;
write_com(Disp_On);
write_com(Page_Add);
write_com(Start_Line);
write_com(Col_Add);
for(j=0;j8;j++)
{
write_com(Page_Add+j);
write_com(Col_Add+0);
// write_com(Start_Line+0);
for(i=0;i64;i++)write_data(0x00);
}
}

/*------------------顯示列-----------------------------*/
void Disp_V_Line()
{
unsigned char i,j;
write_com(Disp_On);
write_com(Page_Add);
write_com(Start_Line);
write_com(Col_Add);
for(j=0;j8;j++)
{
write_com(Page_Add+j);
write_com(Col_Add+0);
write_com(Start_Line+0);
for(i=0;i32;i++)
{
write_data(0x00);
write_data(0x55);
}
}
}



關(guān)鍵詞: AM12864測試 C語言 顯示漢字

評論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉