山东群英会开奖结果

(玩电子) 电子技术学习与研究
当前位置:单片机教程网 >> MCU设计实例 >> 浏览文章

LCD12864带中文字库图形显示-单片机程序(多图)

作者:佚名   来源:本站原创   点击数:x  更新时间:2014年08月21日   【字体:

代码:

#include <reg52.h>
#define uchar unsigned char
 
sbit rs=P2^2;//写指令/数据
sbit rw=P2^3;//读状态/写
sbit e=P2^4;//使能端
sbit psb=P2^5;//串/并输入
 
 
//校徽
unsigned char code image[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x1F,0xFF,0x80,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0xFC,0xFF,0xF8,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x07,0xF4,0xFC,0x7E,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x0D,0xF0,0xFC,0xFF,0x80,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x13,0xF0,0x78,0x7F,0xC0,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x75,0xF7,0xFF,0xFC,0xE0,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0xF8,0xF8,0x00,0xF9,0x78,0x00,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0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 
 
 
 
};
 
void delay(int i)
{
uchar j;
while(i--)
for(j=110;j>0;j--);
}
//读状态,检测忙
void check_busy()
{
rs=0;
rw=1;
e=1;
P0=0xff;
while((P0&0x80)==0x80);
e=0;
}
//写指令
void write_com(uchar com)
{
check_busy();
rs=0;
rw=0;
e=1;
P0=com;
delay(5);
e=0;
delay(5);
}
//写数据
void write_data(uchar _data)
{
check_busy();
rs=1;
rw=0;
e=1;
P0=_data;
delay(5);
e=0;
delay(5);
}
//初始化lcd
void init()
{
rw=0;
psb=1;//选择为并行输入
delay(50);
write_com(0x30);//基本指令操作
delay(5);
write_com(0x0c);//显示开,关光标
delay(5);
write_com(0x06);//写入一个字符,地址加1
delay(5);
write_com(0x01);
delay(5);
 
}
 
void wstring(uchar *str)
{
while(*str)
{
write_data(*str);
delay(5);
str++;
}
}
void lcd_draw(unsigned char code *pic)
{
unsigned i,j,k;
write_com(0x34);//扩充指令集
 
for(i=0;i<2;i++)//上半屏和下半屏
{
for(j=0;j<32;j++)//上下半屏各32行
{
write_com(0x80+j);//写行地址(y地址)
if(i==0)
{
write_com(0x80);//写列地址(x地址),上半屏列地址为0x80,下半屏列地址为0x88
}
else
{
write_com(0x88);
}
for(k=0;k<16;k++)//写入列数据
{
write_data(*pic++);
}
}
}
 
 
write_com(0x36);//显示图形
write_com(0x30);//基本指令集
 
}
 
 
 
void main()
{
init();
write_com(0x80);//第一行地址
wstring("北京理工大学珠海");
 
 
write_com(0x90);//第二行地址
wstring("学院");
 
 
write_com(0x98);//第三行地址
wstring("www.zhbit.com");/**/
 
delay(5000);
write_com(0x01);
 
write_com(0x80);
wstring("ZHUHAI CAMPUS,");
 
write_com(0x90);
wstring("BEIJING ");
 
write_com(0x88);
wstring("INSTITUTE OF ");
 
write_com(0x98);
wstring("TECHNOLOGY");
 
 
delay(5000);
write_com(0x01);
 
lcd_draw(image);
 
write_com(0x98+5);
wstring("ZHBIT");
 
while(1);
 
 
}

lcd比数码管好玩多

效果:
校徽弄得不太好







绘图更好的一个算法:(可以绘分块,也可绘全屏)
void lcd_block(char num,char flag)
{
//x1:列数,yl:行数,x:列坐标,
//sx:该图形距离第一幅图的距离
//此函数也可以用来画全屏图
unsigned i,j,k,xl,yl,x,y,sx;
unsigned char code *pic;
 
switch(num)
{
case 0: j=0; pic=image0;xl=5;yl=12;sx=3;x=0x80|sx;break;
case 1: j=13;pic=image4;xl=4;yl=37;sx=0;x=0x80|sx;break;
case 2: j=13;pic=image4;xl=4;yl=37;sx=3;x=0x80|sx;break;
case 3: j=13;pic=image4;xl=4;yl=12;sx=6;x=0x80|sx;break;
case 4: j=7; pic=image4;xl=4;yl=31;sx=0;x=0x88|sx;break;
case 5: j=7; pic=image5;xl=4;yl=31;sx=3;x=0x88|sx;break;
case 6: j=7; pic=image5;xl=4;yl=31;sx=6;x=0x88|sx;break;
case 7: j=0; pic=image7;xl=16;yl=64;sx=0;x=0x80|sx;break;
}
write_com(0x34);
for(j;j<yl;j++)
{
if(j>31) {y=j-32;x=0x88|sx;}
else y=j;
write_com(0x80+y);
write_com(x);
for(k=0;k<xl;k++)
{
if(flag)
write_data(*pic++);
else write_data(~(*pic++));
}
}
/* for(j;j<yl;j++)
{
write_com(0x80+j);
write_com(x);
for(k=0;k<xl;k++)
{
if(flag)
write_data(*pic++);
else write_data(~(*pic++));
}
}*/
 
write_com(0x36); //显示图形
write_com(0x30); //基本指令集
}

文章评论

北京赛车pk10玩法 北京赛车pk10玩法 湖北快3 北京赛车pk10玩法 智慧彩票投注开奖 上海11选五 智慧彩票投注开奖 北京赛车怎么玩 北京赛车怎么玩 极速快乐8