大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
第11周上机程序-LCD12864显示-操作示范
结果展示
取模软件
软件图片
软件下载
百度网盘下载
链接: link.
提取码:houh
钉钉群下载
软件使用方法(文字取模)
点击C51后字符便会自动生成。
保存为记事本形式,如下所示
软件使用方法(字符取模)
一样的操作,输入学号,生成16进制数组,保存于桌面即可。
程序修改
导入原本程序
keil
proteus
修改原程序
修改文字
将下面这段子函数内的16进制替换为刚刚生成的文字代码(!!一定是文字,不是字符,注意,注意)
uchar code table_hz[ ]={
//*-- 文字: 电 --*/
0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00,
0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00,
//*-- 文字: 子 --*/
0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xE2,0x12,0x0A,0x06,0x02,0x00,0x80,0x00,0x00,
0x01,0x01,0x01,0x01,0x01,0x41,0x81,0x7F,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
//*-- 文字: 设 --*/
0x40,0x41,0xCE,0x04,0x00,0x80,0x40,0xBE,0x82,0x82,0x82,0xBE,0xC0,0x40,0x40,0x00,
0x00,0x00,0x7F,0x20,0x90,0x80,0x40,0x43,0x2C,0x10,0x10,0x2C,0x43,0xC0,0x40,0x00,
//*-- 文字: 计 --*/
0x20,0x21,0x2E,0xE4,0x00,0x00,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x00,
0x00,0x00,0x00,0x7F,0x20,0x10,0x08,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
//*-- 文字: 与 --*/
0x00,0x00,0x00,0x00,0x7E,0x48,0x48,0x48,0x48,0x48,0x48,0x48,0x48,0xCC,0x08,0x00,
0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x24,0x46,0x44,0x20,0x1F,0x00,0x00,
//*-- 文字: 创 --*/
0x40,0x20,0xD0,0x4C,0x43,0x44,0x48,0xD8,0x30,0x10,0x00,0xFC,0x00,0x00,0xFF,0x00,
0x00,0x00,0x3F,0x40,0x40,0x42,0x44,0x43,0x78,0x00,0x00,0x07,0x20,0x40,0x3F,0x00,
//*-- 文字: 新 --*/
0x20,0x24,0x2C,0x35,0xE6,0x34,0x2C,0x24,0x00,0xFC,0x24,0x24,0xE2,0x22,0x22,0x00,
0x21,0x11,0x4D,0x81,0x7F,0x05,0x59,0x21,0x18,0x07,0x00,0x00,0xFF,0x00,0x00,0x00,
//*-- 文字: 的 --*/
0x00,0xF8,0x8C,0x8B,0x88,0xF8,0x40,0x30,0x8F,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,
0x00,0x7F,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x03,0x26,0x40,0x20,0x1F,0x00,0x00,
//*-- 文字: 最 --*/
0x40,0x40,0xC0,0x5F,0x55,0x55,0xD5,0x55,0x55,0x55,0x55,0x5F,0x40,0x40,0x40,0x00,
0x20,0x20,0x3F,0x15,0x15,0x15,0xFF,0x48,0x23,0x15,0x09,0x15,0x23,0x61,0x20,0x00,
//*-- 文字: 佳 --*/
0x40,0x20,0xF0,0x1C,0x47,0x4A,0x48,0x48,0x48,0xFF,0x48,0x48,0x4C,0x68,0x40,0x00,
0x00,0x00,0xFF,0x00,0x40,0x44,0x44,0x44,0x44,0x7F,0x44,0x44,0x46,0x64,0x40,0x00,
//*-- 文字: 平 --*/
0x00,0x01,0x05,0x09,0x71,0x21,0x01,0xFF,0x01,0x41,0x21,0x1D,0x09,0x01,0x00,0x00,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
//*-- 文字: 台 --*/
0x00,0x00,0x40,0x60,0x50,0x48,0x44,0x63,0x22,0x20,0x20,0x28,0x70,0x20,0x00,0x00,
0x00,0x00,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00,0x00
};
替换结果为
uchar code table_hz[ ]={
/*-- 文字: 我 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,0x20,0xFF,0x20,0x22,0x2C,0xA0,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x41,0x40,0x20,0x13,0x0C,0x14,0x22,0x41,0xF8,0x00,
/*-- 文字: 是 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x7F,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0x7F,0x00,0x00,0x00,0x00,
0x81,0x41,0x21,0x1D,0x21,0x41,0x81,0xFF,0x89,0x89,0x89,0x89,0x89,0x81,0x81,0x00,
/*-- 文字: _ --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 洛 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x60,0x02,0x8C,0x00,0x10,0x08,0x14,0xA7,0x44,0xA4,0x14,0x0C,0x00,0x00,0x00,
0x04,0x04,0x7E,0x01,0x02,0x02,0xFD,0x45,0x44,0x44,0x44,0x45,0xFD,0x02,0x02,0x00,
/*-- 文字: 阳 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x02,0x22,0xDA,0x06,0x00,0xFC,0x04,0x04,0x04,0x04,0x04,0xFC,0x00,0x00,
0x00,0xFF,0x08,0x10,0x08,0x07,0x00,0xFF,0x41,0x41,0x41,0x41,0x41,0xFF,0x00,0x00,
/*-- 文字: 理 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x84,0x84,0xFC,0x84,0x84,0x00,0xFE,0x92,0x92,0xFE,0x92,0x92,0xFE,0x00,0x00,
0x20,0x60,0x20,0x1F,0x10,0x10,0x40,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x40,0x00,
/*-- 文字: 工 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
/*-- 文字: 学 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,
/*-- 文字: 院 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x22,0x5A,0x86,0x10,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x14,0x0C,0x00,
0x00,0xFF,0x04,0x08,0x07,0x80,0x41,0x31,0x0F,0x01,0x01,0x3F,0x41,0x41,0x71,0x00,
/*-- 文字: _ --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 侯 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x80,0x60,0xF8,0x07,0x10,0x92,0xF2,0x92,0x92,0x92,0x92,0x9E,0x10,0x10,0x00,
0x01,0x00,0x00,0xFF,0x84,0x85,0x44,0x24,0x14,0x0F,0x14,0x24,0x44,0x84,0x84,0x00,
/*-- 文字: 永 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x40,0x40,0x48,0x48,0xC8,0x09,0xFA,0xC4,0x00,0x80,0x40,0x20,0x10,0x00,0x00,
0x20,0x20,0x10,0x08,0x06,0x41,0x80,0x7F,0x00,0x03,0x04,0x08,0x10,0x20,0x20,0x00,
/*-- 文字: 琪 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x84,0x84,0xFC,0x84,0x84,0x00,0x04,0xFF,0x24,0x24,0x24,0x24,0xFF,0x04,0x00,0x00,
0x10,0x30,0x1F,0x08,0x08,0x00,0x88,0x4F,0x29,0x09,0x09,0x29,0x4F,0x88,0x08,0x00,
};
运行看下仿真的效果
emmmmmm……少个琪,我们来看下原因
如下代码导致我们显示错误,下面仔细剖析代码组成
void display(void)
{
select(1);
display_zf(0,40,3,0);
display_hz(2,0,4,0);
display_hz(4,32,2,8);
select(2);
display_zf(0,0,4,3);
display_hz(2,0,4,4);
display_hz(4,0,2,10);
}
想要看某一段程序具体的作用,最快捷的方法便是将其注释,查看仿真器的显示结果,便可确定其作用。
我们注释掉两行代码
//在LCD上显示
void display(void)
{
select(1);
display_zf(0,40,3,0);
display_hz(2,0,4,0);
//display_hz(4,32,2,8);
select(2);
display_zf(0,0,4,3);
display_hz(2,0,4,4);
//display_hz(4,0,2,10);
}
查看显示结果
显然最下面一行文字消失了,所以这两行就是显示最下面文字的作用。
为更加确定其作用,以及方便修改,下面我们详细看一下display_hz(2,0,4,0);
这个子函数.
void display_hz(uchar c_page,uchar c_column,uchar num,uchar offset)
{
uchar c1,c2,c3;
for(c1=0;c1<num;c1++)
{
for(c2=0;c2<2;c2++)
{
for(c3=0;c3<16;c3++)
{
send_cmd(lcdpage+c_page+c2);
send_cmd(lcdcolumn+c_column+c1*16+c3);
send_data(table_hz[(c1+offset)*32+c2*16+c3]);
}
}
}
}
//c_page为当前页,c_column为当前列,num为字符数,
//offset为所取汉字在显示缓冲区中的偏移单位
我们得以知道,实参c_page
为当前页,形参4我们就能明白表示的是第四页。
如下图所示,分别为0,2,4行。
同理,num
表示需要出现的字符数、select(1);
便是左半个屏幕显示、select(2);
便是右半个屏幕显示。
于是,我们得以明白,之所以琪不显示,因为我们设置的num
参数为2,但是我们的文字比原程序多了一位,所以参数应为3.
修改如下:
void display(void)
{
select(1);
display_zf(0,40,3,0);
display_hz(2,0,4,0);
display_hz(4,32,2,8);
select(2);
display_zf(0,0,4,3);
display_hz(2,0,4,4);
display_hz(4,0,3,10);//~!!!!!!2改为3
}
结果:
修改学号
原程序
uchar code table_zf[]={
//*-- 文字: P --*/
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,
//*-- 文字: R --*/
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,
//*-- 文字: O --*/
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,
//*-- 文字: T --*/
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,
//*-- 文字: E --*/
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,
//*-- 文字: U --*/
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,
//*-- 文字: S --*/
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00
};
修改为:
uchar code table_zf[]={
/*-- 文字: B --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,
/*-- 文字: 8 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
/*-- 文字: 8 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
};
仿真结果为:
少两个数,嗯???仿照文字修改方式,将num中的4改为6(因为用4学号少两位,所以4+2=6)
将文字适应程序:在这里插入代码片
void display(void)
{
select(1);
display_zf(0,40,3,0);//学号
display_hz(2,0,4,0);//汉字
display_hz(4,32,2,8);
select(2);
display_zf(0,0,4,3);
display_hz(2,0,4,4);
display_hz(4,0,3,10);
}
修改为:
void display(void)
{
select(1);
display_zf(0,40,3,0);
display_hz(2,0,4,0);
display_hz(4,32,2,8);
select(2);
display_zf(0,0,6,3);
display_hz(2,0,4,4);
display_hz(4,0,3,10);
}
成了,不过有一个问题,学号没有居中,我们可以修改一下:
void display(void)
{
select(1);
display_zf(0,25,5,0);/(第二个参数改成24,24是列数,原来是40,太靠右,往左去一下)
display_hz(2,0,4,0);
display_hz(4,32,2,8);
select(2);
display_zf(0,1,4,5);/学号一共9位,select(1)显示5位,所以select(2)显示三位;注意此时display_zf函数第四个参数必须和上一个display_zf倒数第二位一样,也就是说:5=5.
display_hz(2,0,4,4);
display_hz(4,0,3,10);
}
完整程序
#include <reg51.h>
#define uchar signed char
#define uint unsigned int
// 常量定义
#define lcdrow 0xc0//设置起始行
#define lcdpage 0xb8//设置起始页
#define lcdcolumn 0x40//设置起始列
#define c_page_max 0x08//页数最大值
#define c_column_max 0x40//列数最大值
//端口定义
#define bus P0
sbit rst=P2^0;
sbit e=P2^2;
sbit rw=P2^3;
sbit rs=P2^4;
sbit cs1=P2^5;
sbit cs2=P2^6;
//函数申明
void delayms(uint); //延时n ms
void delayus10(void);//延时10us
void select(uchar); //选择屏幕
void send_cmd(uchar); //写命令
void send_data(uchar); //写数据
void clear_screen(void);//清屏
void initial(void); //LCD初始化
void display_zf(uchar,uchar,uchar,uchar); //显示字符
void display_hz(uchar,uchar,uchar,uchar); //显示汉字
void display(void); //在LCD上显示
//字符表
//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
//取模方式:纵向取模下高位,从上到下,从左到右取模
uchar code table_zf[]={
/*-- 文字: B --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,
/*-- 文字: 8 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
/*-- 文字: 1 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
/*-- 文字: 0 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
/*-- 文字: 8 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
};
//汉字表
//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
//取模方式:纵向取模下高位,从上到下,从左到右取模
uchar code table_hz[ ]={
/*-- 文字: 我 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,0x20,0xFF,0x20,0x22,0x2C,0xA0,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x41,0x40,0x20,0x13,0x0C,0x14,0x22,0x41,0xF8,0x00,
/*-- 文字: 是 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x7F,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0x7F,0x00,0x00,0x00,0x00,
0x81,0x41,0x21,0x1D,0x21,0x41,0x81,0xFF,0x89,0x89,0x89,0x89,0x89,0x81,0x81,0x00,
/*-- 文字: _ --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 洛 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x60,0x02,0x8C,0x00,0x10,0x08,0x14,0xA7,0x44,0xA4,0x14,0x0C,0x00,0x00,0x00,
0x04,0x04,0x7E,0x01,0x02,0x02,0xFD,0x45,0x44,0x44,0x44,0x45,0xFD,0x02,0x02,0x00,
/*-- 文字: 阳 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x02,0x22,0xDA,0x06,0x00,0xFC,0x04,0x04,0x04,0x04,0x04,0xFC,0x00,0x00,
0x00,0xFF,0x08,0x10,0x08,0x07,0x00,0xFF,0x41,0x41,0x41,0x41,0x41,0xFF,0x00,0x00,
/*-- 文字: 理 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x84,0x84,0xFC,0x84,0x84,0x00,0xFE,0x92,0x92,0xFE,0x92,0x92,0xFE,0x00,0x00,
0x20,0x60,0x20,0x1F,0x10,0x10,0x40,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x40,0x00,
/*-- 文字: 工 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
/*-- 文字: 学 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,
/*-- 文字: 院 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFE,0x22,0x5A,0x86,0x10,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x14,0x0C,0x00,
0x00,0xFF,0x04,0x08,0x07,0x80,0x41,0x31,0x0F,0x01,0x01,0x3F,0x41,0x41,0x71,0x00,
/*-- 文字: _ --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 侯 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x80,0x60,0xF8,0x07,0x10,0x92,0xF2,0x92,0x92,0x92,0x92,0x9E,0x10,0x10,0x00,
0x01,0x00,0x00,0xFF,0x84,0x85,0x44,0x24,0x14,0x0F,0x14,0x24,0x44,0x84,0x84,0x00,
/*-- 文字: 永 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x40,0x40,0x48,0x48,0xC8,0x09,0xFA,0xC4,0x00,0x80,0x40,0x20,0x10,0x00,0x00,
0x20,0x20,0x10,0x08,0x06,0x41,0x80,0x7F,0x00,0x03,0x04,0x08,0x10,0x20,0x20,0x00,
/*-- 文字: 琪 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x84,0x84,0xFC,0x84,0x84,0x00,0x04,0xFF,0x24,0x24,0x24,0x24,0xFF,0x04,0x00,0x00,
0x10,0x30,0x1F,0x08,0x08,0x00,0x88,0x4F,0x29,0x09,0x09,0x29,0x4F,0x88,0x08,0x00,
};
void main()
{
initial();
display();
clear_screen();
display();
while(1);
}
//延时10us
void delayus10(void)
{
uchar i=5;
while(--i);
}
//延时10ms
void delayms(uint j)
{
uchar i=250;
for(;j>0;j--){
while(--i); i=249;while(--i);i=250;}
}
//屏幕选择-cs=0选择双屏,cs=1选择左半屏,cs=2选择右半屏
void select(uchar cs)
{
if(cs==0)cs1=1,cs2=1;
else if(cs==1)cs1=1,cs2=0;
else cs1=0,cs2=1;
}
//写命令
void send_cmd(uchar cmd)
{
rs=0;rw=0; bus=cmd;delayus10();e=1;e=0;
}
//写数据
void send_data(uchar dat)
{
rs=1;rw=0; bus=dat;delayus10();e=1;e=0;
}
//清屏
void clear_screen(void)
{
uchar c_page,c_column;
select(0);
for(c_page=0;c_page<c_page_max;c_page++)
{
send_cmd(c_page+lcdpage);
send_cmd(lcdcolumn);
for(c_column=0;c_column<c_column_max;c_column++)
{
send_data(0X00);
}
}
}
//LCD初始化
void initial(void)
{
select(0);
rst=0;delayms(10);rst=1;
clear_screen();
send_cmd(lcdrow);
send_cmd(lcdcolumn);
send_cmd(lcdpage);
send_cmd(0x3f);
}
//写字符
//c_page为当前页,c_column为当前列,num为字符数,
//offset为所取字符在显示缓冲区中的偏移单位
void display_zf(uchar c_page,uchar c_column,uchar num,uchar offset)
{
uchar c1,c2,c3;
for(c1=0;c1<num;c1++)
{
for(c2=0;c2<2;c2++)
{
for(c3=0;c3<8;c3++)
{
send_cmd(lcdpage+c_page+c2);
send_cmd(lcdcolumn+c_column+c1*8+c3);
send_data(table_zf[(c1+offset)*16+c2*8+c3]);
}
}
}
}
//写汉字
//c_page为当前页,c_column为当前列,num为字符数,
//offset为所取汉字在显示缓冲区中的偏移单位
void display_hz(uchar c_page,uchar c_column,uchar num,uchar offset)
{
uchar c1,c2,c3;
for(c1=0;c1<num;c1++)
{
for(c2=0;c2<2;c2++)
{
for(c3=0;c3<16;c3++)
{
send_cmd(lcdpage+c_page+c2);
send_cmd(lcdcolumn+c_column+c1*16+c3);
send_data(table_hz[(c1+offset)*32+c2*16+c3]);
}
}
}
}
//在LCD上显示
void display(void)
{
select(1);
display_zf(0,25,5,0);
display_hz(2,0,4,0);
display_hz(4,32,2,8);
select(2);
display_zf(0,1,4,5);
display_hz(2,0,4,4);
display_hz(4,0,3,10);
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/184314.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...