基于C8051F的金鵬LCD19264(帶字庫)程序
//********************************************
//寫數(shù)據(jù)
//********************************************
void send_d (uchar up,uchar down,uchar dat)
{
chk_busy (up,down);
rs=1; //data
rw=0; //write
if(up==1)
{
P1 = Math_Subwith(dat); //output data
//e1=1;
P4 = P4|0x01;
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
//e1=0;
P4 = P4&0xfe;
}
if(down==1)
{
P1 = Math_Subwith(dat); //outputdata
e2=1;
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
e2=0;
}
}
/*------------------初始化-----------------*/
void init_lcd (void)
{本文引用地址:http://m.butianyuan.cn/article/201612/324201.htm
send_c (1,1,0x30); /*30---基本指令動作*/
send_c (1,1,0x01); /*清屏,地址指針指向00H*/
send_c (1,1,0x06); /*光標的移動方向*/
send_c (1,1,0x0c); /*開顯示,關游標*/
}
/*---------------顯示漢字或字符----------------*/
/*void chn_disp (uchar code *chn)
{
uchar i;
send_c (1,1,0x30); //第一行
send_c (1,0,0x80);
for (i=0;i<24;i++)
send_d (1,0,chn[i]);
send_c (1,0,0x90); //第二行
for (i=0;i<24;i++)
send_d (1,0,chn[24+i]);
send_c (0,1,0x80); //第三行
for (i=0;i<24;i++)
send_d (0,1,chn[48+i]);
send_c (0,1,0x90); //第四行
for (i=0;i<24;i++)
send_d (0,1,chn[72+i]);
}*/
/*---------------任意位置顯示漢字或字符----------------*/
void string_disp (uchar up,uchar down,uchar addr,uchar length,uchar code *pp)//地址,長度,數(shù)據(jù)
{
uchar i;
send_c (1,1,0x30);
send_c (up,down,addr); //第一行
for (i=0;i
}
void number_disp (uchar up,uchar down,uchar addr,uchar length,uchar number1,uchar number2)//地址,長度,數(shù)據(jù)
{
uchar i;
send_c (1,1,0x30);
send_c (up,down,addr); //第一行
for (i=0;i
for(i=1;i<(length+1);i++)
send_d (up,down,number2);
}
/*--------------清DDRAM------------------*/
void clrram (void)
{
send_c (1,1,0x30);
send_c (1,1,0x01);
}
評論