AM12864測(cè)試C語言程序
/*------------------棋盤-----------------------------*/
void Disp_Cross_Line(unsigned char mode)
{
unsigned char i,j;
unsigned char data1,data2;
if(mode==0) {data1=0xaa;data2=0x55;}
else if(mode==1) {data1=0x55;data2=0xaa;}
else return;
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;i32;i++){
write_data(data1);
write_data(data2);
}
}
}
/*---------------------指定位置顯示漢字16*16-----------------------*/
void hz_disp16(unsigned char pag,unsigned char col, unsigned char code *hzk)
{
unsigned char j=0,i=0;
for(j=0;j2;j++){
write_com(Page_Add+pag+j);
write_com(Col_Add+col);
for(i=0;i16;i++) write_data(hzk[16*j+i]);
}
}
/*------------------初始化LCD屏--------------------------*/
void init_lcd()
{ Lcd_Rst=0;
delay(100);
Lcd_Rst=1;
delay(100);
Mcs=1;
Scs=1;/////////////////////////////////////////////////////////
delay(100);
write_com(Disp_Off); /////////////////////
write_com(Page_Add);
write_com(Start_Line);
write_com(Col_Add);
write_com(Disp_On);
}
/*------------------------------信息顯示------------------------*/
void Msg(int flg)
{
Clr_Scr();
frame();
if(flg==0){ //顯示"測(cè)試開始"
Mcs=1;Scs=0;
hz_disp16(3,32,ce);
delay(2000);
hz_disp16(3,48,shi);
delay(2000);
Mcs=0;Scs=1;
hz_disp16(3,0,kai);
delay(2000);
hz_disp16(3,16,shi2);
delay(2000);
}
else if(flg==1){ //顯示"測(cè)試完畢"
Mcs=1;Scs=0;
hz_disp16(0,32,ce);
hz_disp16(0,48,shi);
Mcs=0;Scs=1;
hz_disp16(0,0,wan);
hz_disp16(0,16,bi);
Mcs=1;Scs=0;
hz_disp16(3,0,yang);
hz_disp16(3,16,qi);
hz_disp16(3,32,nong);
hz_disp16(3,48,du);
Mcs=0;Scs=1;
hz_disp16(3,0,bai);
hz_disp16(3,16,fen);
hz_disp16(3,32,bi2);
hz_disp16(3,48,wei);
}
}
/*--------------------------------鍵盤掃描-------------------------*/
void Key_Scan()
{
while(Test_Key);
while(~Test_Key);
}
/*--------------------主程序-----------AM12864測(cè)試程序----------------------*/
main()
{
unsigned char i=0;
while(1){
// Key_Scan();
init_lcd();
//Disp_Img(FirstPage);
//delay(10000);
// Key_Scan();
Msg(0);
delay(10000);
Disp_H_Line();
delay(10000);
Disp_V_Line();
delay(10000);
Msg(1);
delay(10000);
Clr_Scr();
//while(1);
}
}
評(píng)論