资源说明:#include
#include "BroadConfig.h"
#include "INTRINS.H"
#define uint unsigned int
#define uchar unsigned char
#define DATA P4OUT //LCD12864数据线
#define RS_CLR P5OUT&=~BIT6
#define RS_SET P5OUT|=BIT6
#define RW_CLR P5OUT&=~BIT5
#define RW_SET P5OUT|=BIT5
#define EN_CLR P5OUT&=~BIT4
#define EN_SET P5OUT|=BIT4
#define cs1_CLR P5OUT&=~BIT1
#define cs1_SET P5OUT|=BIT1
#define cs2_CLR P5OUT&=~BIT2
#define cs2_SET P5OUT|=BIT2
//sbit RS=P2^2; // 数据\指令 选择
//sbit RW=P2^1; // 读\写 选择
//sbit EN=P2^0; // 读\写使能
//sbit cs1=P2^4; // 片选1
///sbit cs2=P2^3; // 片选2
void _nop_();
/********************************/
/* 定义中文字库 */
/********************************/
const uchar Hzk[]={
/*-- 文字: 各 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x20,0x20,0x10,0x08,0x8F,0xB4,0x44,0x44,0xA4,0x9C,0x04,0x00,0x00,0x00,0x00,
0x02,0x02,0x02,0x01,0x7F,0x42,0x42,0x42,0x42,0x42,0x42,0x7F,0x01,0x03,0x01,0x00,
/*-- 文字: 位 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xC0,0x30,0xEC,0x03,0x2A,0xC8,0x09,0x0A,0x0E,0x08,0xE8,0x48,0x08,0x00,0x00,
0x01,0x00,0x00,0x7F,0x20,0x20,0x20,0x27,0x20,0x30,0x2E,0x21,0x20,0x20,0x20,0x00,
/*-- 文字: 单 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xF8,0x28,0x29,0x2E,0x2A,0xF8,0x28,0x2C,0x2B,0x2A,0xF8,0x00,0x00,0x00,
0x08,0x08,0x0B,0x09,0x09,0x09,0x09,0xFF,0x09,0x09,0x09,0x09,0x0B,0x08,0x08,0x00,
/*-- 文字: 机 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x08,0x08,0xC8,0xFF,0x48,0x88,0x08,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,
0x04,0x03,0x00,0xFF,0x00,0x41,0x30,0x0C,0x03,0x00,0x00,0x00,0x3F,0x40,0x78,0x00,
/*-- 文字: 爱 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x40,0xB2,0x96,0x9A,0x92,0xF6,0x9A,0x93,0x91,0x99,0x97,0x91,0x90,0x30,0x00,
0x40,0x20,0xA0,0x90,0x4C,0x47,0x2A,0x2A,0x12,0x1A,0x26,0x22,0x40,0xC0,0x40,0x00,
/*-- 文字: 好 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0xF0,0x1F,0x10,0xF0,0x80,0x82,0x82,0x82,0xF2,0x8A,0x86,0x82,0x80,0x00,
0x80,0x43,0x22,0x14,0x0C,0x73,0x20,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 者 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x20,0x24,0x24,0x24,0x24,0xA4,0xBF,0x64,0x24,0x34,0x28,0x26,0x24,0x20,0x00,
0x04,0x04,0x04,0x02,0x02,0xFF,0x49,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,
/*-- 文字: 你 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
/*0x80,0x40,0xF0,0x2C,0x43,0x20,0x98,0x0F,0x0A,0xE8,0x08,0x88,0x28,0x1C,0x08,0x00,
0x00,0x00,0x7F,0x00,0x10,0x0C,0x03,0x21,0x40,0x3F,0x00,0x00,0x03,0x1C,0x08,0x00,*/
0x00, 0x80, 0x60, 0xF8, 0x07, 0x40, 0x20, 0x18, 0x0F, 0x08, 0xC8, 0x08, 0x08, 0x28, 0x18, 0x00,
0x01, 0x00, 0x00, 0xFF, 0x00, 0x10, 0x0C, 0x03, 0x40, 0x80, 0x7F, 0x00, 0x01, 0x06, 0x18, 0x00,//;"你",0
/*-- 文字: 们 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x40,0xF0,0x1C,0x03,0xF0,0x01,0x0E,0x04,0x00,0x04,0x04,0x04,0xFC,0x00,0x00,
0x00,0x00,0x7F,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x20,0x40,0x3F,0x00,0x00,
/*-- 文字: 辛 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x84,0x84,0x94,0xA4,0xC4,0x85,0x86,0x84,0xC4,0xA4,0x94,0x84,0x84,0x80,0x00,
0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,
/*-- 文字: 苦 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x44,0x44,0x44,0x44,0x5F,0x44,0xF4,0x44,0x44,0x5F,0x44,0x44,0x44,0x44,0x00,
0x00,0x00,0x00,0x7E,0x22,0x22,0x22,0x23,0x22,0x22,0x22,0x7E,0x00,0x00,0x00,0x00,
/*-- 文字: 了 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x02,0x02,0x02,0x02,0x02,0x02,0xF2,0x12,0x0A,0x0A,0x06,0x06,0x02,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 希 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x20,0x20,0x30,0x30,0xA9,0x6A,0x3A,0x24,0xE4,0x2A,0x29,0x30,0x20,0x20,0x20,0x00,
0x08,0x04,0x02,0x01,0x3F,0x01,0x01,0x01,0xFF,0x01,0x21,0x61,0x3F,0x00,0x00,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 --*/
0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00,
/*-- 文字: 家 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x18,0x04,0x14,0x94,0x94,0xD5,0xB6,0x14,0x14,0x94,0x04,0x14,0x0C,0x04,0x00,
0x00,0x29,0x29,0x15,0x14,0x4A,0x89,0x44,0x3F,0x06,0x09,0x09,0x10,0x30,0x10,0x00,
/*-- 文字: 能 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0xB8,0x97,0x92,0x90,0x94,0xB8,0x10,0x00,0x7F,0x48,0x48,0x44,0x74,0x20,0x00,
0x00,0xFF,0x0A,0x0A,0x4A,0x8A,0x7F,0x00,0x00,0x3F,0x44,0x44,0x42,0x72,0x20,0x00,
/*-- 文字: 多 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x20,0x90,0x88,0x54,0x53,0xA2,0x22,0x12,0x0A,0x06,0x00,0x00,0x00,
0x00,0x81,0x89,0x89,0x44,0x44,0x42,0x25,0x29,0x11,0x11,0x09,0x05,0x03,0x01,0x00,
/*-- 文字: 多 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x20,0x90,0x88,0x54,0x53,0xA2,0x22,0x12,0x0A,0x06,0x00,0x00,0x00,
0x00,0x81,0x89,0x89,0x44,0x44,0x42,0x25,0x29,0x11,0x11,0x09,0x05,0x03,0x01,0x00,
/*-- 文字: 交 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x08,0x88,0x48,0x38,0x28,0x09,0x0E,0x0C,0x08,0x98,0x28,0x68,0x48,0x08,0x00,
0x00,0x80,0x80,0x40,0x41,0x22,0x14,0x18,0x0C,0x16,0x23,0x61,0xC0,0x40,0x00,0x00,
/*-- 文字: 流 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x60,0x01,0x86,0x60,0x04,0x44,0x64,0x55,0x4E,0x44,0x64,0xC4,0x04,0x04,0x00,
0x04,0x04,0xFC,0x03,0x40,0x30,0x0F,0x00,0x00,0x7F,0x00,0x3F,0x40,0x40,0x70,0x00,
/*-- 文字: 学 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00,
0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00,
/*-- 文字: 习 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x02,0x02,0x0A,0x12,0x22,0x62,0x02,0x82,0x82,0x42,0x02,0xFE,0x00,0x00,
0x00,0x00,0x04,0x0C,0x04,0x02,0x02,0x01,0x01,0x00,0x20,0x40,0x80,0x7F,0x00,0x00,
/*-- 文字: 24 --*/
/*-- 宋体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,
};
/****************************************/
/* 定义ASCII字库8列*16行 */
/****************************************/
const uchar Ezk[]={
/*-- 文字: Q --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,
/*-- 文字: Q --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,
/*-- 文字: 3 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: 4 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: 4 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
/*-- 文字: 4 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,
/*-- 文字: 4 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
/*状态检查,LCD是否忙*/
void CheckState()
{
uchar dat;//状态信息(判断是否忙)
RS_CLR; // 数据\指令选择,D/I(RS)=“L” ,表示 DB7∽DB0 为显示指令数据
RW_SET; //R/W=“H” ,E=“H”数据被读到DB7∽DB0
do{
DATA=0x00;
EN_SET; //EN下降源
_nop_(); //一个时钟延时
dat=DATA;
EN_CLR;
dat=0x80 & dat; //仅当第7位为0时才可操作(判别busy信号)
}while(!(dat==0x00));
}
/*写命令到LCD中*/
int SendCommandToLCD(uchar com)
{
CheckState();//状态检查,LCD是否忙
RS_CLR; //向LCD发送命令。RS_CLR写指令,RS_SET写数据
RW_CLR;//R/W=“L” ,E=“H→L”数据被写到 IR 或 DR
DATA=com; //com :命令
EN_SET;//EN下降源
_nop_();
_nop_();
EN_CLR;
return 0;
}
/*设置页 0xb8是页的首地址*/
void SetLine(uchar page)
{
page=0xb8|page; //1011 1xxx 0<=page<=7 设定页地址--X 0-7,8行为一页64/8=8,共8页
SendCommandToLCD(page);
}
/*设定显示开始行,0xc0是行的首地址*/
void SetStartLine(uchar startline)
{
startline=0xc0|startline; //1100 0000
SendCommandToLCD(startline); //设置从哪行开始:0--63,一般从0 行开始显示
}
/*设定列地址--Y 0-63 ,0x40是列的首地址*/
void SetColumn(uchar column)
{
column=column &0x3f; //column最大值为64,越出 0=
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。