1在lcd_read_cmd()中的dat=P2前加入P2=0xff
2将判大仿断忙滚悄纤(lcd_read_cmd()&&0x80)!=0改成lcd_read_cmd==0
#include <stdio.h>#include <math.h>
#include <reg52.h>
#include <string.h>
sbit RS=P2^3 //注意:一定要看12864液晶模块的资蔽租料,来确定怎样 *** 作
sbit WRD=P2^4
sbit E=P2^5
sbit PSB=P2^0
sbit RES=P2^2
void TransferData(char data1,bit DI)
void delayms(unsigned int n)
void delay(unsigned int m)
void lcd_mesg(unsigned char code *addr1)
//下面来定义要显示的汉字,8*4
unsigned char code IC_DAT[]={
"陈 "
""
""
""
}
unsigned char code IC_DAT2[]={
"爱一个人难却还爱"
"交结朋友可路更宽"
"诚实守信宏知兆加油努力"
"成功做人成功做事"
}
void initinal(void) //初始化,12864有要求的要写猛缓上
{
delay(40)
PSB=1 //并口工作模式
delay(1)
RES=0//复位
delay(1)
RES=1 //复位置高
delay(10)
TransferData(0x30,0)
delay(100)
TransferData(0x30,0)
delay(37)
TransferData(0x08,0)
delay(100)
TransferData(0x10,0)
delay(100)
TransferData(0x0C,0)
delay(100)
TransferData(0x01,0)
delay(10)
TransferData(0x06,0)
delay(100)
}
void main(void)//分两屏来不断显示上面定义的IC_DAT和IC_DAT2汉字
{
while(1)
{
initinal()//调用LCD字库初始化程序
delay(100)
lcd_mesg(IC_DAT)
delayms(240) //延时程序必要的,长与短,自己调节
delayms(240)
initinal()
delay(100)
lcd_mesg(IC_DAT2)
delayms(240)
delayms(240)
}
}
void lcd_mesg(unsigned char code *addr1) //显示汉字函数,8*4=32
{
unsigned char i
TransferData(0x80,0)
delay(100)
for(i=0i<32i++)
{
TransferData(*addr1,1)
addr1++
}
TransferData(0x90,0)
delay(100)
for(i=32i<64i++)
{
TransferData(*addr1,1)
addr1++
}
}
void TransferData(char data1,bit DI) //传送数据或是命令,当DI=0时,传送命令,当DI=1时,传送数据
{
WRD=0
RS=DI
delay(1)
P0=data1
E=1
delay(1)
E=0
}
void delayms(unsigned int n)//延时子程序
{
unsigned int i,j
for(i=0i<ni++)
for(j=0j<2000j++)
}
void delay(unsigned int m)
{
unsigned int i,j
for(i=0i<mi++)
for(j=0j<10j++)
}
/****************打点******************/void point(uchar x,uchar y)
{
uchar y1,hang,lie,msb_data,lsb_data,temp=0x01
if(y1!=y)
{
msb_data=0
lsb_data=0
}
y1=y
if(y<32)
{
hang=0x80+y
lie=0x80
}
if(y>31)
{
hang=0x80+y-32
lie=0x88
}
if(y>63)//return
{
lcm_com(0x80)
_nop_()
hanzi("温度超出显示范轿扰围")
while(1)
flash()
}
lie=lie+x/16
if(x%16==0)
{
msb_data=0
lsb_data=0
}
if(x%16<8)
{
msb_data=msb_data|(temp<<(7-x%16))
lsb_data=0x00|lsb_data
}//保留以前的数据,把第x个点亮闹陪
if(x%16==8)
{
msb_data=msb_data|0x00
lsb_data=lsb_data|0x80
}
if(x%16>8)大于24小于32
{
msb_data=msb_data|0x00
lsb_data=lsb_data|(temp<<(15-x%16))
}
lcm_com(0x34)//扩闭弯旦充指令集
lcm_com(hang)
lcm_com(lie)
lcm_dat(msb_data)
lcm_dat(lsb_data)
lcm_com(0x36)//绘图显示开
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)