我做了一个lcd12864做了一个液晶显示,
时间:10-02
整理:3721RD
点击:
//我做了一个lcd12864做了一个液晶显示,为什么字能正确显示,图片就不能正确显示呢?求大神解答
//下面是我的程序,上传的图片分别为我的电路图和想在液晶显示的图片
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit LCD_RS=P3^5;//数据和命令端
sbit LCD_EN=P3^4;//使能端
sbit LCD_RW=P3^3;
sbit CS1=P2^1;
sbit CS2=P2^2;
uchar code a[]={
//静夜思
/*-- 文字: 静 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x22,0xAA,0xAA,0xBF,0xAA,0xAA,0x22,0x80,0xA8,0xA7,0xF4,0xAC,0xA4,0xE0,0x80,0x00,
0x00,0xFF,0x0A,0x4A,0x8A,0x7F,0x00,0x00,0x42,0x82,0x7F,0x02,0x02,0x03,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 床 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xFC,0x44,0x44,0x44,0x44,0xC5,0xFE,0x44,0x44,0x44,0x44,0x44,0x04,0x00,
0x80,0x60,0x1F,0x40,0x20,0x18,0x06,0x01,0xFF,0x01,0x02,0x04,0x08,0x30,0x10,0x00,
/*-- 文字: 前 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x08,0x08,0xE8,0xA8,0xA9,0xAE,0xEA,0x08,0x08,0xC8,0x0C,0x0B,0xEA,0x08,0x08,0x00,
0x00,0x00,0x7F,0x04,0x24,0x44,0x3F,0x00,0x00,0x1F,0x40,0x80,0x7F,0x00,0x00,0x00,
/*-- 文字: 明 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,
0x00,0x03,0x02,0x02,0x02,0x43,0x20,0x18,0x07,0x01,0x01,0x41,0x81,0x7F,0x00,0x00,
/*-- 文字: 月 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,0x00,0x00,
0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x01,0x01,0x21,0x41,0x3F,0x00,0x00,0x00,0x00,
/*-- 文字: 光 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x40,0x42,0x44,0x5C,0xC8,0x40,0x7F,0x40,0xC0,0x50,0x4E,0x44,0x60,0x40,0x00,
0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x78,0x00,
/*-- 文字: 夜 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x04,0x84,0xC4,0x3C,0x14,0x85,0x66,0xBC,0x24,0x24,0x24,0xE4,0x24,0x04,0x00,
0x02,0x01,0x00,0xFF,0x00,0x82,0x41,0x22,0x14,0x09,0x14,0x23,0x40,0xC0,0x40,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 疑 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xC0,0x9F,0xA4,0xA2,0xA2,0x98,0x22,0x22,0x2A,0xF2,0x2A,0x26,0xA2,0x60,0x00,
0x86,0x45,0x24,0x1C,0x0F,0x94,0x44,0x30,0x0F,0x10,0x3F,0x22,0x42,0xC2,0x40,0x00,
/*-- 文字: 是 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x80,0x80,0x80,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x80,0x80,0x80,0x00,
0x00,0x40,0x20,0x10,0x0E,0x10,0x20,0x3F,0x44,0x44,0x44,0x44,0x44,0x40,0x40,0x00,
/*-- 文字: 地 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0x10,0xFE,0x10,0x50,0x40,0xFE,0x20,0x20,0xFF,0x10,0x10,0xF8,0x10,0x00,
0x20,0x20,0x10,0x1F,0x08,0x08,0x00,0x3F,0x40,0x40,0x4F,0x42,0x44,0x43,0x70,0x00,
/*-- 文字: 上 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00,
0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x40,0x60,0x40,0x00,
/*-- 文字: 霜 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x0C,0x04,0x55,0xD5,0x55,0x05,0x7F,0x05,0x55,0x55,0x55,0x05,0x0C,0x04,0x00,
0x00,0x22,0x1A,0x06,0xFF,0x06,0x0A,0x00,0xFF,0x55,0x55,0x55,0xFF,0x00,0x00,0x00,
/*-- 文字: 思 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x20,0x38,0x00,0x00,0x3C,0x40,0x40,0x42,0x4C,0x40,0x40,0x70,0x04,0x18,0x30,0x00,
/*-- 文字: 李 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x84,0x44,0xC4,0xA4,0x94,0x8C,0xFF,0x8C,0x94,0xA4,0x24,0x44,0xC4,0x40,0x00,
0x00,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x05,0x04,0x04,0x04,0x04,0x04,0x04,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 举 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0x11,0x92,0x5C,0x31,0x12,0xDC,0x10,0x30,0x58,0x97,0x12,0x10,0x10,0x00,
0x04,0x02,0x09,0x08,0x09,0x09,0x09,0xFF,0x09,0x09,0x09,0x08,0x09,0x02,0x02,0x00,
/*-- 文字: 头 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x12,0x64,0x2C,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,0x05,0x19,0x31,0xE1,0x41,0x01,0x00,
/*-- 文字: 望 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x04,0xFC,0x85,0x46,0x24,0x04,0x80,0x7E,0x2A,0x2A,0xAA,0xAA,0xFE,0x00,0x00,
0x00,0x40,0x42,0x4A,0x4A,0x4A,0x4A,0x7E,0x4A,0x4A,0x4A,0x4A,0x4A,0x42,0x40,0x00,
/*-- 文字: 明 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,
0x00,0x03,0x02,0x02,0x02,0x43,0x20,0x18,0x07,0x01,0x01,0x41,0x81,0x7F,0x00,0x00,
/*-- 文字: 月 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,0x00,0x00,
0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x01,0x01,0x21,0x41,0x3F,0x00,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 白 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xF8,0x08,0x08,0x0C,0x0B,0x08,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,0x00,
0x00,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 低 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x20,0xF0,0x0C,0x07,0x02,0xFC,0x44,0x44,0x42,0xFE,0x43,0x43,0x42,0x40,0x00,
0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x20,0x10,0x28,0x43,0x0C,0x10,0x20,0x78,0x00,
/*-- 文字: 头 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x12,0x64,0x2C,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,0x05,0x19,0x31,0xE1,0x41,0x01,0x00,
/*-- 文字: 思 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x20,0x38,0x00,0x00,0x3C,0x40,0x40,0x42,0x4C,0x40,0x40,0x70,0x04,0x18,0x30,0x00,
/*-- 文字: 故 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x90,0x90,0xFF,0x90,0x90,0x10,0x80,0xF0,0x1F,0x12,0x10,0xF0,0x10,0x10,0x00,
0x00,0x3F,0x10,0x10,0x10,0x5F,0x41,0x20,0x20,0x13,0x0C,0x13,0x20,0x60,0x20,0x00,
/*-- 文字: 乡 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x20,0x30,0x28,0xAC,0xA7,0x62,0x20,0x30,0x1C,0xC8,0x80,0x00,0x00,
0x00,0x40,0x40,0x42,0x47,0x23,0x22,0x22,0x12,0x11,0x09,0x07,0x01,0x00,0x00,0x00,
};
void xunhuan (uint x) //相当于延时
{
int y,z;
for(y=x;y>0;y--)
for (z=120;z>0;z--);
}
void write_c(uchar c) //写指令端
{
LCD_RW=0; //P3^3 R/W R/W=“H”,E=“H”,数据被读到DB7——DB0 R/W=“L”,E=“H→L”,DB7——DB0的数据被写到IR或DR
LCD_RS=0; //P3^5 RS RS=“H”,表示DB7——DB0为显示数据RS=“L”,表示DB7——DB0为显示指令数据
LCD_EN=1; //p3^4 E
P1=c; // D0~D7
LCD_EN=0;
xunhuan(1);
LCD_EN=1;
//xunhuan(5);
}
void write_d(uchar d)//写数据
{
LCD_RW=0; //P3^3 R/W R/W=“H”,E=“H”,数据被读到DB7——DB0 R/W=“L”,E=“H→L”,DB7——DB0的数据被写到IR或DR
LCD_RS=1; //P3^5 RS RS=“H”,表示DB7——DB0为显示数据RS=“L”,表示DB7——DB0为显示指令数据
LCD_EN=1; //E
P1=d;
LCD_EN=0;
xunhuan(1);
LCD_EN=1;
//xunhuan(5);
}
void pianxuan(screen) //片选
{
switch(screen)
{
case 0:
CS1=0;
CS2=0;
break;
case 1:
CS1=1;
CS2=0;
break;
case 2:
CS1=0;
CS2=1;
break;
case 3:
CS1=1;
CS2=1;
break;
}
}
void qinping(screen)//清屏,从第一行第一列开始
{
uint x,y; //页的设置位
pianxuan(screen);//选择哪个屏
for(x=0xb8;x<0xc0;x++)
{
write_c(x);//页初始值为0XB8到0xc0共八页
write_c(0x40);//列的初始地址为0x40,共64列
for(y=0;y<64;y++)
{
write_d(0x00);//选择全部清屏
}
}
}
/*
LCD显示汉字字库函数
*/
void lcd_display_hanzi(uchar screen,uchar page,uchar lie,uint mun)
{ //screen:选择屏幕参数,page:选择页参数0-3,lie列参数0-3,mun:显示第几个汉字的参数
int i; //page页其实就是行,是行计数器页指针 共九位计数器,高三位为X,低六位为Y
mun=mun*32;
pianxuan(screen) ; //片选看哪个段
write_c(0xb8+(page*2)); //一个字节显示
write_c(0x40+(lie*16)); //一个汉字占用两个字节
for ( i=0;i<16;i++)
{
write_d(a[mun++]);
}
write_c(0x40+(lie*16));
write_c(0xb8+(page*2)+1);
for (i=0;i<16;i++)
{
write_d(a[mun++]);
}
}
void LCD_init()
{
write_c(0x0f);// 显示开启
write_c(0xc0); //显示起始行,从第一位开始 ,从0到63
write_c(0xb8);// 设置页得地址从0到7
write_c(0x40); //设置列的地址,从第一位开始 ,从0到63
}
void main()
{
LCD_init();
qinping(0);
lcd_display_hanzi(2,0,0,0); //LCD显示汉字
lcd_display_hanzi(2,0,1,1); //LCD显示汉字
lcd_display_hanzi(2,0,2,2); //LCD显示汉字
lcd_display_hanzi(2,0,3,3); //LCD显示汉字
lcd_display_hanzi(1,0,0,4); //LCD显示汉字
lcd_display_hanzi(1,0,1,5); //LCD显示汉字
lcd_display_hanzi(1,0,2,6); //LCD显示汉字
lcd_display_hanzi(1,0,3,7); //LCD显示汉字
lcd_display_hanzi(2,1,0,8); //LCD显示汉字
lcd_display_hanzi(2,1,1,9); //LCD显示汉字
lcd_display_hanzi(2,1,2,10);
lcd_display_hanzi(2,1,3,11);
lcd_display_hanzi(1,1,0,12);
lcd_display_hanzi(1,1,1,13);
lcd_display_hanzi(1,1,2,14);
lcd_display_hanzi(1,1,3,15);
lcd_display_hanzi(2,2,0,16);
lcd_display_hanzi(2,2,1,17);
lcd_display_hanzi(2,2,2,18);
lcd_display_hanzi(2,2,3,19);
lcd_display_hanzi(1,2,0,20);
lcd_display_hanzi(1,2,1,21);
lcd_display_hanzi(1,2,2,22);
lcd_display_hanzi(1,2,3,23);
lcd_display_hanzi(2,3,0,24);
lcd_display_hanzi(2,3,1,25);
lcd_display_hanzi(2,3,2,26);
lcd_display_hanzi(2,3,3,27);//LCD显示汉字
lcd_display_hanzi(1,3,0,28);
lcd_display_hanzi(1,3,1,29);
lcd_display_hanzi(1,3,2,30);
lcd_display_hanzi(1,3,3,31);
//LCD显示汉字*/
while(1);
}
//下面是我的程序,上传的图片分别为我的电路图和想在液晶显示的图片
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit LCD_RS=P3^5;//数据和命令端
sbit LCD_EN=P3^4;//使能端
sbit LCD_RW=P3^3;
sbit CS1=P2^1;
sbit CS2=P2^2;
uchar code a[]={
//静夜思
/*-- 文字: 静 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x22,0xAA,0xAA,0xBF,0xAA,0xAA,0x22,0x80,0xA8,0xA7,0xF4,0xAC,0xA4,0xE0,0x80,0x00,
0x00,0xFF,0x0A,0x4A,0x8A,0x7F,0x00,0x00,0x42,0x82,0x7F,0x02,0x02,0x03,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 床 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xFC,0x44,0x44,0x44,0x44,0xC5,0xFE,0x44,0x44,0x44,0x44,0x44,0x04,0x00,
0x80,0x60,0x1F,0x40,0x20,0x18,0x06,0x01,0xFF,0x01,0x02,0x04,0x08,0x30,0x10,0x00,
/*-- 文字: 前 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x08,0x08,0xE8,0xA8,0xA9,0xAE,0xEA,0x08,0x08,0xC8,0x0C,0x0B,0xEA,0x08,0x08,0x00,
0x00,0x00,0x7F,0x04,0x24,0x44,0x3F,0x00,0x00,0x1F,0x40,0x80,0x7F,0x00,0x00,0x00,
/*-- 文字: 明 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,
0x00,0x03,0x02,0x02,0x02,0x43,0x20,0x18,0x07,0x01,0x01,0x41,0x81,0x7F,0x00,0x00,
/*-- 文字: 月 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,0x00,0x00,
0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x01,0x01,0x21,0x41,0x3F,0x00,0x00,0x00,0x00,
/*-- 文字: 光 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x40,0x42,0x44,0x5C,0xC8,0x40,0x7F,0x40,0xC0,0x50,0x4E,0x44,0x60,0x40,0x00,
0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x78,0x00,
/*-- 文字: 夜 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x04,0x84,0xC4,0x3C,0x14,0x85,0x66,0xBC,0x24,0x24,0x24,0xE4,0x24,0x04,0x00,
0x02,0x01,0x00,0xFF,0x00,0x82,0x41,0x22,0x14,0x09,0x14,0x23,0x40,0xC0,0x40,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 疑 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xC0,0x9F,0xA4,0xA2,0xA2,0x98,0x22,0x22,0x2A,0xF2,0x2A,0x26,0xA2,0x60,0x00,
0x86,0x45,0x24,0x1C,0x0F,0x94,0x44,0x30,0x0F,0x10,0x3F,0x22,0x42,0xC2,0x40,0x00,
/*-- 文字: 是 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x80,0x80,0x80,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x80,0x80,0x80,0x00,
0x00,0x40,0x20,0x10,0x0E,0x10,0x20,0x3F,0x44,0x44,0x44,0x44,0x44,0x40,0x40,0x00,
/*-- 文字: 地 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0x10,0xFE,0x10,0x50,0x40,0xFE,0x20,0x20,0xFF,0x10,0x10,0xF8,0x10,0x00,
0x20,0x20,0x10,0x1F,0x08,0x08,0x00,0x3F,0x40,0x40,0x4F,0x42,0x44,0x43,0x70,0x00,
/*-- 文字: 上 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00,
0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x40,0x60,0x40,0x00,
/*-- 文字: 霜 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x0C,0x04,0x55,0xD5,0x55,0x05,0x7F,0x05,0x55,0x55,0x55,0x05,0x0C,0x04,0x00,
0x00,0x22,0x1A,0x06,0xFF,0x06,0x0A,0x00,0xFF,0x55,0x55,0x55,0xFF,0x00,0x00,0x00,
/*-- 文字: 思 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x20,0x38,0x00,0x00,0x3C,0x40,0x40,0x42,0x4C,0x40,0x40,0x70,0x04,0x18,0x30,0x00,
/*-- 文字: 李 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x84,0x44,0xC4,0xA4,0x94,0x8C,0xFF,0x8C,0x94,0xA4,0x24,0x44,0xC4,0x40,0x00,
0x00,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x05,0x04,0x04,0x04,0x04,0x04,0x04,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 举 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0x11,0x92,0x5C,0x31,0x12,0xDC,0x10,0x30,0x58,0x97,0x12,0x10,0x10,0x00,
0x04,0x02,0x09,0x08,0x09,0x09,0x09,0xFF,0x09,0x09,0x09,0x08,0x09,0x02,0x02,0x00,
/*-- 文字: 头 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x12,0x64,0x2C,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,0x05,0x19,0x31,0xE1,0x41,0x01,0x00,
/*-- 文字: 望 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x04,0xFC,0x85,0x46,0x24,0x04,0x80,0x7E,0x2A,0x2A,0xAA,0xAA,0xFE,0x00,0x00,
0x00,0x40,0x42,0x4A,0x4A,0x4A,0x4A,0x7E,0x4A,0x4A,0x4A,0x4A,0x4A,0x42,0x40,0x00,
/*-- 文字: 明 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,
0x00,0x03,0x02,0x02,0x02,0x43,0x20,0x18,0x07,0x01,0x01,0x41,0x81,0x7F,0x00,0x00,
/*-- 文字: 月 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,0x00,0x00,
0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x01,0x01,0x21,0x41,0x3F,0x00,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 白 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xF8,0x08,0x08,0x0C,0x0B,0x08,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,0x00,
0x00,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
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,
/*-- 文字: 低 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x20,0xF0,0x0C,0x07,0x02,0xFC,0x44,0x44,0x42,0xFE,0x43,0x43,0x42,0x40,0x00,
0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x20,0x10,0x28,0x43,0x0C,0x10,0x20,0x78,0x00,
/*-- 文字: 头 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x12,0x64,0x2C,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,0x05,0x19,0x31,0xE1,0x41,0x01,0x00,
/*-- 文字: 思 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
0x20,0x38,0x00,0x00,0x3C,0x40,0x40,0x42,0x4C,0x40,0x40,0x70,0x04,0x18,0x30,0x00,
/*-- 文字: 故 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x90,0x90,0xFF,0x90,0x90,0x10,0x80,0xF0,0x1F,0x12,0x10,0xF0,0x10,0x10,0x00,
0x00,0x3F,0x10,0x10,0x10,0x5F,0x41,0x20,0x20,0x13,0x0C,0x13,0x20,0x60,0x20,0x00,
/*-- 文字: 乡 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x20,0x30,0x28,0xAC,0xA7,0x62,0x20,0x30,0x1C,0xC8,0x80,0x00,0x00,
0x00,0x40,0x40,0x42,0x47,0x23,0x22,0x22,0x12,0x11,0x09,0x07,0x01,0x00,0x00,0x00,
};
void xunhuan (uint x) //相当于延时
{
int y,z;
for(y=x;y>0;y--)
for (z=120;z>0;z--);
}
void write_c(uchar c) //写指令端
{
LCD_RW=0; //P3^3 R/W R/W=“H”,E=“H”,数据被读到DB7——DB0 R/W=“L”,E=“H→L”,DB7——DB0的数据被写到IR或DR
LCD_RS=0; //P3^5 RS RS=“H”,表示DB7——DB0为显示数据RS=“L”,表示DB7——DB0为显示指令数据
LCD_EN=1; //p3^4 E
P1=c; // D0~D7
LCD_EN=0;
xunhuan(1);
LCD_EN=1;
//xunhuan(5);
}
void write_d(uchar d)//写数据
{
LCD_RW=0; //P3^3 R/W R/W=“H”,E=“H”,数据被读到DB7——DB0 R/W=“L”,E=“H→L”,DB7——DB0的数据被写到IR或DR
LCD_RS=1; //P3^5 RS RS=“H”,表示DB7——DB0为显示数据RS=“L”,表示DB7——DB0为显示指令数据
LCD_EN=1; //E
P1=d;
LCD_EN=0;
xunhuan(1);
LCD_EN=1;
//xunhuan(5);
}
void pianxuan(screen) //片选
{
switch(screen)
{
case 0:
CS1=0;
CS2=0;
break;
case 1:
CS1=1;
CS2=0;
break;
case 2:
CS1=0;
CS2=1;
break;
case 3:
CS1=1;
CS2=1;
break;
}
}
void qinping(screen)//清屏,从第一行第一列开始
{
uint x,y; //页的设置位
pianxuan(screen);//选择哪个屏
for(x=0xb8;x<0xc0;x++)
{
write_c(x);//页初始值为0XB8到0xc0共八页
write_c(0x40);//列的初始地址为0x40,共64列
for(y=0;y<64;y++)
{
write_d(0x00);//选择全部清屏
}
}
}
/*
LCD显示汉字字库函数
*/
void lcd_display_hanzi(uchar screen,uchar page,uchar lie,uint mun)
{ //screen:选择屏幕参数,page:选择页参数0-3,lie列参数0-3,mun:显示第几个汉字的参数
int i; //page页其实就是行,是行计数器页指针 共九位计数器,高三位为X,低六位为Y
mun=mun*32;
pianxuan(screen) ; //片选看哪个段
write_c(0xb8+(page*2)); //一个字节显示
write_c(0x40+(lie*16)); //一个汉字占用两个字节
for ( i=0;i<16;i++)
{
write_d(a[mun++]);
}
write_c(0x40+(lie*16));
write_c(0xb8+(page*2)+1);
for (i=0;i<16;i++)
{
write_d(a[mun++]);
}
}
void LCD_init()
{
write_c(0x0f);// 显示开启
write_c(0xc0); //显示起始行,从第一位开始 ,从0到63
write_c(0xb8);// 设置页得地址从0到7
write_c(0x40); //设置列的地址,从第一位开始 ,从0到63
}
void main()
{
LCD_init();
qinping(0);
lcd_display_hanzi(2,0,0,0); //LCD显示汉字
lcd_display_hanzi(2,0,1,1); //LCD显示汉字
lcd_display_hanzi(2,0,2,2); //LCD显示汉字
lcd_display_hanzi(2,0,3,3); //LCD显示汉字
lcd_display_hanzi(1,0,0,4); //LCD显示汉字
lcd_display_hanzi(1,0,1,5); //LCD显示汉字
lcd_display_hanzi(1,0,2,6); //LCD显示汉字
lcd_display_hanzi(1,0,3,7); //LCD显示汉字
lcd_display_hanzi(2,1,0,8); //LCD显示汉字
lcd_display_hanzi(2,1,1,9); //LCD显示汉字
lcd_display_hanzi(2,1,2,10);
lcd_display_hanzi(2,1,3,11);
lcd_display_hanzi(1,1,0,12);
lcd_display_hanzi(1,1,1,13);
lcd_display_hanzi(1,1,2,14);
lcd_display_hanzi(1,1,3,15);
lcd_display_hanzi(2,2,0,16);
lcd_display_hanzi(2,2,1,17);
lcd_display_hanzi(2,2,2,18);
lcd_display_hanzi(2,2,3,19);
lcd_display_hanzi(1,2,0,20);
lcd_display_hanzi(1,2,1,21);
lcd_display_hanzi(1,2,2,22);
lcd_display_hanzi(1,2,3,23);
lcd_display_hanzi(2,3,0,24);
lcd_display_hanzi(2,3,1,25);
lcd_display_hanzi(2,3,2,26);
lcd_display_hanzi(2,3,3,27);//LCD显示汉字
lcd_display_hanzi(1,3,0,28);
lcd_display_hanzi(1,3,1,29);
lcd_display_hanzi(1,3,2,30);
lcd_display_hanzi(1,3,3,31);
//LCD显示汉字*/
while(1);
}
好东西 正想要好东西 正想要好东西 正想要好东西 正想要好东西 正想要好东西 正想要
挺不错的 感谢分享
你这液晶显示屏元件能分享给我不
好东西,谢谢小编分享。