(原文件名:图片 001[1].jpg)
(原文件名:图片 003[1].jpg)
(原文件名:图片 005[1].jpg)
以下是我源程序:
#define uint unsigned int
#define uchar unsigned char
#define __LCD_CS RE0 //片选 高电平有效 单片LCD使用时可固定高电平
#define __LCD_SID RE1 //数据
#define __LCD_CLK RE2 //时钟
const uchar num[]={"0123456789"};
const uchar welcom0[]={0xbb,0xb6,0xd3,0xad,0xb9,0xe2,0xc1,0xd9,0xCE,0xF7,0xB0,0xB2,0xC8,0xAB,0xC2,0xB7};//"欢迎光临西安全路";//
const uchar welcom1[]={0xCD,0xA8,0xBA,0xC5,0xC6,0xF7,0xB2,0xC4,0xD1,0xD0,0xBE,0xBF,0xCB,0xF9,0xA3,0xA1}; //"通号器材研究所!";//
const uchar welcom5[]={0xD6, 0xD0 ,0xB9 ,0xFA ,0xCD ,0xA8 ,0xBA ,0xC5 ,0xBC ,0xAF ,0xCD ,0xC5 ,0xB9 ,0xAB ,0xCB ,0xBE };//="中国通号集团公司"
const uchar welcom3[]={0xC7,0xEB,0xCA,0xE4,0xC8,0xEB,0xB5,0xC0,0xB2,0xED,0xBA,0xC5,0xA3,0xBA} ;//"请输入道岔号:";
const uchar welcom4[]={0xCA,0xE4,0xC8,0xEB,0xB5,0xC4,0xB5,0xC0,0xB2,0xED,0xBA,0xC5,0xA3,0xBA }; //"输入的道岔号:";//
uchar show[2];//按键数据存储
uchar count;//按键次数计数器
uchar SendFlag;//发送标志位
/**************延时***************/
void delayus(uchar a)
{
uchar i;
for(i=a;i>0;i--)
NOP();
}
void delayms(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=110;b>0;b--);
}
/*************写一个字节*******************************/
void WriteByte(uchar sdata)
{
uchar i,d;
for(i=0;i<8;i++)
{
d=sdata&0x80;
if(d)
__LCD_SID=1;
else
__LCD_SID=0;
__LCD_CLK=0;
asm("nop");
__LCD_CLK=1;
sdata=sdata<<1;
}
}
/**************LCD写入函数***************/
//dat_comm为1表示数据是显示数据,为0表示数据是控制指令
void LCD_write(uchar dat_comm,uchar content) //写指令或数据
{
__LCD_CLK=0;
if(dat_comm==1)
WriteByte(0xfa);
else
WriteByte(0xf8);
asm("nop");
WriteByte(content&0xf0);
WriteByte(content<<4);
}
/**************初始化函数***************/
void LCD_init(void) //初始化LCD
{
__LCD_CS=1;
LCD_write(0,0x30); //8 位介面,基本指令集
LCD_write(0,0x01); //清屏,将DDRAM的地址计数器归零
delayus(100);
LCD_write(0,0x06); //光标的移动方向
LCD_write(0,0x0c); //显示打开,光标关,反白关
}
/*-----------------------------------------------------
LCD_set_xy : 设置LCD显示的起始位置,X为行,Y为列
输入参数:x、y : 显示字符串的位置,X:0-3,Y:0-7
LCD第一行显示寄存器地址:0X80-0X87
---------------------------------------------------------*/
void LCD_set_xy( unsigned char x, unsigned char y )
{
unsigned char address;
switch (x)
{
case 0 : address=0x80+y; break;
case 1 : address=0x90+y; break;
case 2 : address=0x88+y; break;
case 3 : address=0x98+y; break;
default: address=0x80+y; break;
}
LCD_write(0,address);
}
/************显示单个字符*********/
void LCD_display_one_char(unsigned char x, unsigned char y,unsigned char ddata)
{
LCD_write(0,0x30);
LCD_set_xy(x,y);
LCD_write(1,ddata);
}
/************显示一串字符*********/
void LCD_display_string(unsigned char x,unsigned char y,uchar numb, unsigned char *s)
{
unsigned char i;
i=0;
LCD_write(0,0x30);
LCD_set_xy(x,y);
while(i<2*numb)
{
LCD_write(1,s
);
i++;
}
}
/***************************数字显示函数*******************************/
void LCD_Write_number(unsigned char s)//
{
LCD_write(1,num);
delayms(1);
}
/************************清屏********************************/
void clrram(void)
{
LCD_write(0,0x30);
LCD_write(0,0x01);
delayus(180);
}
大家帮我看看,那里的问题了!
2·适当降低对比度
3·屏质量不好,导电介质绝源电阻过低
一周热门 更多>