12864液晶简单显示程序(带字库)
x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x30,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x7C,0x20,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x1E,0x78,0x00,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x1E,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xDA,0x3C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF2,0x30,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF1,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x78,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x72,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x40,0x04,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0C,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
void Delay_us(uint i)//i=10,time=100us
{
for(;i>0;i--);
}
void Delay_ms(uint i)//i=10,time=10ms
{
while(i--)
Delay_us(100);
}
//向12864液晶写数据或命令
void Lcd_wcd(uchar dat_comm,uchar Lcd_da
{
if(dat_comm)
RS=1; //数据
else RS=0; //命令
Lcd_IO=Lcd_da
RW=0;
EN=1;
Delay_us(30);
EN=0;
}
void Lcd_init()//液晶初始化
{
RST=0;
Delay_us(10); //外部复位
RST=1;
PSB=1;
Lcd_wcd(comm,0x30); //基本指令格式
Delay_us(30);
Lcd_wcd(comm,0x01); //液晶清屏
Delay_ms(30);
Lcd_wcd(comm,0x06); //设置显示格式,光标位置
Lcd_wcd(comm,0x0c);
}
void Lcd_pst(uchar xx,uchar yy)//设置显示坐标
{
uint line;
switch(yy)
{
case 0:line=0x00;break;
case 1:line=0x10;break;
case 2:line=0x08;break;
case 3:line=0x18;break;
default :break;
}
Lcd_wcd(comm,0x80+line+xx);
}
void Lcd_str(uchar *str) //显示字符串和汉字
{
while(*str!=\0)
{
Lcd_wcd(dat,*str);
str++;
}
}
//液晶自定义显示
void Lcd_define(uchar *str)
{
uint m,n;
Lcd_wcd(comm,0x34);//设置位扩展指令格式
for(m=0;m<32;m++)
{
for(n=0;n<8;n++)
{
Lcd_wcd(comm,0x80+m);//写纵坐标,00H--1FH
Lcd_wcd(comm,0x80+n);//写横坐标,00H--07H
Lcd_wcd(dat,str[m*16+n*2]);
Lcd_wcd(dat,str[m*16+n*2+1]);//连续写两个数据
}
}
for(m=32;m<64;m++)
{
for(n=0;n<8;n++)
{
Lcd_wcd(comm,0x80+m-32); //写纵坐标,00H--1FH
Lcd_wcd(comm,0x88+n);//写横坐标,08H--0FH
Lcd_wcd(dat,str[m*16+n*2]);
Lcd_wcd(dat,str[m*16+n*2+1]); //连续写两个数据
}
}
Lcd_wcd(comm,0x30); //基本指令格式
Lcd_wcd(comm,0x01); //清屏
Delay_ms(30);
Lcd_wcd(comm,0x34); //扩展指令格式
Lcd_wcd(comm,0x36); //显示自定义图形
}
//主函数
void main()
{
P0=0xff;
P2=0xff;
Lcd_init();
Lcd_pst(
12864液晶显示程序字 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)