专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
proteus
求助仿真公交报站器显示部分 12864仿真
2019-07-18 12:00
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
proteus
14252
5
1154
求助!!!对公交报站器的显示部分
仿真
按键2能顺序播放显示内容公交站名,按键3能停止,按键4能改变上下行播放顺序
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
5条回答
jgyan99
1楼-- · 2019-07-18 12:43
怎么没人回复呢
加载中...
jgyan99
2楼-- · 2019-07-18 17:34
自己找找实例吧
加载中...
WaitingAloneLi
3楼-- · 2019-07-18 18:50
jgyan99 发表于 2015-6-12 13:03
自己找找实例吧
有个程序可以显示第一个站名为什么后面的就是乱码了呢?
程序如下
#include <reg51.h>
#include <intrins.h>
#include<stdio.h>
#define uint unsigned int
#define uchar unsigned char
#define Port P0 //LCD12864数据线
sbit EN=P2^6; // 读写使能
sbit RW=P2^5; // 读写 选择
sbit RS=P2^4; // 数据指令 选择
sbit cs2=P2^2; // 片选2
sbit cs1=P2^1; // 片选1
int State_Count = 0 ;
int Run_Dir_P_Flag = 1;
int Run_Dir_N_Flag = 0;
int Next_Stat_Flag = 0 ;
sbit Key1 = P1^2;
sbit Key2 = P1^3;
sbit Key3 = P1^4;
/********************************/
/* 定义中文字库 */
/********************************/
uchar code Hzk[]={
/*-- 文字:站名: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xC8,0x08,0x09,0x0E,0xE8,0x08,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00,
0x10,0x30,0x17,0x10,0x0E,0x09,0x08,0xFF,0x41,0x41,0x41,0x41,0x41,0xFF,0x00,0x00,
0x00,0x20,0x20,0x10,0x08,0x14,0x67,0x84,0x44,0x24,0x14,0x0C,0x00,0x00,0x00,0x00,
0x04,0x04,0x04,0x02,0xFE,0x43,0x43,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x36,0x36,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,/*" ",0*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",1*/
/*-- 文字: 科技大学 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,
0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00,
0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00,/*"技",0*/
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,/*"大",1*/
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,/*"学",2*/
// 博物馆
0x20,0x20,0xFF,0x20,0x24,0xF4,0x54,0x54,0x54,0xFF,0x54,0x55,0x56,0xF4,0x04,0x00,
0x00,0x00,0xFF,0x00,0x08,0x0B,0x19,0x69,0x09,0x0B,0x49,0x89,0x7D,0x0B,0x08,0x00,/*"博",0*/
0x40,0x3C,0x10,0xFF,0x10,0x10,0x20,0x10,0x8F,0x78,0x08,0xF8,0x08,0xF8,0x00,0x00,
0x02,0x06,0x02,0xFF,0x01,0x01,0x04,0x42,0x21,0x18,0x46,0x81,0x40,0x3F,0x00,0x00,/*"物",1*/
0x40,0x30,0x8F,0x28,0x18,0x10,0x0C,0xE4,0x24,0x25,0x26,0x24,0xE4,0x14,0x0C,0x00,
0x00,0x00,0x7F,0x20,0x10,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0xF8,0x00,0x00,/*"馆",2*/
//火车站
0x00,0x00,0xC0,0x38,0x00,0x00,0x00,0xFF,0x00,0x00,0x40,0x20,0x18,0x00,0x00,0x00,
0x80,0x81,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,/*"火",0*/
0x00,0x08,0x88,0x48,0x28,0x18,0x0F,0xE8,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
0x08,0x08,0x09,0x09,0x09,0x09,0x09,0xFF,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x00,/*"车",1*/
0x00,0xC8,0x08,0x09,0x0E,0xE8,0x08,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00,
0x10,0x30,0x17,0x10,0x0E,0x09,0x08,0xFF,0x41,0x41,0x41,0x41,0x41,0xFF,0x00,0x00,/*"站",2*/
};
/****************************************/
/* 定义ASCII字库8列*16行 */
/****************************************/
uchar code Ezk[]={
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*"2",0*/
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: . --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,/*".",0*/
/*-- 文字: 7 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,/*"7",0*/
/*-- 文字: 摄氏单位 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x18,0x24,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,/*"C",0*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",0*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",1*/
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,/*":",2*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",3*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",4*/
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,/*":",5*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",6*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",7*/
};
/*状态检查,LCD是否忙*/
void Checkbusy()
{
uchar dat;//状态信息(判断是否忙)
RS=0; // 数据指令选择,D/I(RS)=“L” ,表示 DB7∽DB0 为显示指令数据
RW=1; //R/W=“H” ,E=“H”数据被读到DB7∽DB0
do
{
Port=0x00;
EN=1; //EN下降源
_nop_(); //一个时钟延时
dat=Port;
EN=0;
dat=(0x80 & dat);
}
while(!(dat==0x00)); //仅当第7位为0时才可操作(判别busy信号)
}
/*写命令到LCD中*/
Wcmd(uchar cmd)
{
Checkbusy();//状态检查,LCD是否忙
RS=0; //向LCD发送命令。RS=0写指令,RS=1写数据
RW=0;//R/W=“L” ,E=“H→L”数据被写到 IR 或 DR
Port=cmd; //com :命令
EN=1;//EN下降源
_nop_();
_nop_();
EN=0;
}
/*设置页 0xb8是页的首地址*/
void Setpage(uchar page)
{
page=0xb8|page; //1011 1xxx 0<=page<=7 设定页地址--X 0-7,8行为一页64/8=8,共8页
Wcmd(page);
}
/*设定显示开始行,0xc0是行的首地址*/
void Setx(uchar x)
{
x=0xc0|x; //1100 0000
Wcmd(x); //设置从哪行开始:0--63,一般从0 行开始显示
}
/*设定列地址--Y 0-63 ,0x40是列的首地址*/
void Sety(uchar y)
{
y=y&0x3f; //column最大值为64,越出 0=<column<=63
y= 0x40|y; //01xx xxxx
Wcmd(y);
}
/*开关显示,0x3f是开显示,0x3e是关显示*/
void SetOnOff(uchar onoff)
{
onoff=0x3e|onoff; //0011 111x,onoff只能为0或者1
Wcmd(onoff);
}
/*写显示数据 */
void Writedata(uchar dat)
{
Checkbusy();//状态检查,LCD是否忙
RS=1; //RS=0写指令,RS=1写数据
RW=0;////R/W=“L” ,E=“H→L”数据被写到 IR 或 DR
Port=dat;//dat:显示数据
EN=1; //EN下降源
_nop_();
_nop_();
EN=0;
}
/*选择屏幕screen: 0-全屏,1-左屏,2-右屏*/
void SelectScreen(uchar screen)
{
switch(screen)
{
case 0: cs1=0;//全屏
_nop_();
_nop_();
_nop_();
cs2=0;
_nop_();
_nop_();
_nop_();
break;
case 1: cs1=0;//左屏
_nop_();
_nop_();
_nop_();
cs2=1;
_nop_();
_nop_();
_nop_();
break;
case 2: cs1=1;//右屏
_nop_();
_nop_();
_nop_();
cs2=0;
_nop_();
_nop_();
_nop_();
break;
}
}
/*清屏screen: 0-全屏,1-左屏,2-右*/
void ClearScreen(uchar screen)
{
uchar i,j;
SelectScreen(screen);
for(i=0;i<8;i++) //控制页数0-7,共8页
{
Setpage(i);
Sety(0);
for(j=0;j<64;j++) //控制列数0-63,共64列
{
Writedata(0x00); //写点内容,列地址自动加1
}
}
}
/*延时程序*/
void delay(uint z)
{
uint i,j;
for(i=0; i<z; i++)
for(j = 0; j < 110; j++);
}
/*初始化LCD*/
void InitLCD()
{
Checkbusy();
SelectScreen(0);
SetOnOff(0); //关显示
SelectScreen(0);
SetOnOff(1); //开显示
SelectScreen(0);
ClearScreen(0);//清屏
Setx(0); //开始行:0
}
/*显示全角汉字*/
void Display(uchar ss,uchar page,uchar y,uchar number)
{
int i; //选屏参数,pagr选页参数,column选列参数,number选第几汉字输出
SelectScreen(ss);
y=y&0x3f;
Setpage(page); //写上半页
Sety(y); //控制列
for(i=0;i<16;i++) //控制16列的数据输出
{
Writedata(Hzk[i+32*number]); //i+32*number汉字的前16个数据输出
}
Setpage(page+1); //写下半页
Sety(y); //控制列
for(i=0;i<16;i++) //控制16列的数据输出
{
Writedata(Hzk[i+32*number+16]); //i+32*number+16汉字的后16个数据输出
}
}
/*显示半角汉字和数字和字母*/
void Displayen(uchar ss,uchar page,uchar y,uchar number)
{
uint i;//选屏参数,pagr选页参数,column选列参数,number选第几汉字输出
SelectScreen(ss);
y=y&0x3f;
Setpage(page); //写上半页
Sety(y);
for(i=0;i<8;i++)
{
Writedata(Ezk[i+16*number]);
}
Setpage(page+1); //写下半页
Sety(y);
for(i=0;i<8;i++)
{
Writedata(Ezk[i+16*number+8]);
}
}
//按键扫描及处理
void Key_Process(void)
{
if(Key1 == 0)
{
while(Key1==0);
Run_Dir_P_Flag = 1;
Run_Dir_N_Flag = 0;
}
if(Key2 == 0)
{
while(Key2==0);
Run_Dir_P_Flag = 0;
Run_Dir_N_Flag = 1;
}
if(Key3== 0)
{
while(Key3==0);
Next_Stat_Flag = 1;
}
if(Next_Stat_Flag == 1)
{
Next_Stat_Flag = 0;
if(Run_Dir_P_Flag ==1 )
{
State_Count ++;
if(State_Count>= 3)
{
State_Count = 0;
}
}
if(Run_Dir_N_Flag ==1 )
{
State_Count --;
if(State_Count < 0 )
{
State_Count = 2;
}
}
}
}
/*主函数*/
void main()
{
uint i;
InitLCD();//初始12864
ClearScreen(0);//清屏
Setx(0);//显示开始行
while(1)
{
Key_Process(); //按键扫描及处理
/* 可以多个显示,这里是4个一起显示*/
for(i=0;i<4;i++)
{
Display(1,0,i*16,i);//Display(选屏参数(cs0,cs1),pagr选页参数,column选列参数,number选第几汉字输出)
_nop_();
switch(State_Count)
{
case 0: Display(2,0,i*16,i+4); break; //河北科技大学
case 1: Display(2,0,i*16,i+17); break; //博物馆
case 2: Display(2,0,i*16,i+21); break; //火车站
default: break;
}
}
}
}
加载中...
xinyi000
4楼-- · 2019-07-18 22:29
bucuoxuexixuexixuexi
加载中...
武力戡乱
5楼-- · 2019-07-19 02:48
精彩回答 2 元偷偷看……
加载中...
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
为什么Proteus 仿真点阵字体缺笔画 而且速度奇慢
7 个回答
2012~~单片机C语言程序设计实训100例-基于8051+Proteus仿真(第2版)
27 个回答
新手求帮忙解决proteus的问题
1 个回答
大家好,请问用三菱plc仿真软件跟mcgs组态软件怎么样连接?
1 个回答
proteus出问题,不能用
3 个回答
数字频率计 求编程(汇编或C语言)
1 个回答
求单片机与PC机串行通信
2 个回答
相关文章
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
proteus
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
有个程序可以显示第一个站名为什么后面的就是乱码了呢?
程序如下
#include <reg51.h>
#include <intrins.h>
#include<stdio.h>
#define uint unsigned int
#define uchar unsigned char
#define Port P0 //LCD12864数据线
sbit EN=P2^6; // 读写使能
sbit RW=P2^5; // 读写 选择
sbit RS=P2^4; // 数据指令 选择
sbit cs2=P2^2; // 片选2
sbit cs1=P2^1; // 片选1
int State_Count = 0 ;
int Run_Dir_P_Flag = 1;
int Run_Dir_N_Flag = 0;
int Next_Stat_Flag = 0 ;
sbit Key1 = P1^2;
sbit Key2 = P1^3;
sbit Key3 = P1^4;
/********************************/
/* 定义中文字库 */
/********************************/
uchar code Hzk[]={
/*-- 文字:站名: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xC8,0x08,0x09,0x0E,0xE8,0x08,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00,
0x10,0x30,0x17,0x10,0x0E,0x09,0x08,0xFF,0x41,0x41,0x41,0x41,0x41,0xFF,0x00,0x00,
0x00,0x20,0x20,0x10,0x08,0x14,0x67,0x84,0x44,0x24,0x14,0x0C,0x00,0x00,0x00,0x00,
0x04,0x04,0x04,0x02,0xFE,0x43,0x43,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x36,0x36,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,/*" ",0*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",1*/
/*-- 文字: 科技大学 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,
0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00,
0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00,/*"技",0*/
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,/*"大",1*/
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,/*"学",2*/
// 博物馆
0x20,0x20,0xFF,0x20,0x24,0xF4,0x54,0x54,0x54,0xFF,0x54,0x55,0x56,0xF4,0x04,0x00,
0x00,0x00,0xFF,0x00,0x08,0x0B,0x19,0x69,0x09,0x0B,0x49,0x89,0x7D,0x0B,0x08,0x00,/*"博",0*/
0x40,0x3C,0x10,0xFF,0x10,0x10,0x20,0x10,0x8F,0x78,0x08,0xF8,0x08,0xF8,0x00,0x00,
0x02,0x06,0x02,0xFF,0x01,0x01,0x04,0x42,0x21,0x18,0x46,0x81,0x40,0x3F,0x00,0x00,/*"物",1*/
0x40,0x30,0x8F,0x28,0x18,0x10,0x0C,0xE4,0x24,0x25,0x26,0x24,0xE4,0x14,0x0C,0x00,
0x00,0x00,0x7F,0x20,0x10,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0xF8,0x00,0x00,/*"馆",2*/
//火车站
0x00,0x00,0xC0,0x38,0x00,0x00,0x00,0xFF,0x00,0x00,0x40,0x20,0x18,0x00,0x00,0x00,
0x80,0x81,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,/*"火",0*/
0x00,0x08,0x88,0x48,0x28,0x18,0x0F,0xE8,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
0x08,0x08,0x09,0x09,0x09,0x09,0x09,0xFF,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x00,/*"车",1*/
0x00,0xC8,0x08,0x09,0x0E,0xE8,0x08,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00,
0x10,0x30,0x17,0x10,0x0E,0x09,0x08,0xFF,0x41,0x41,0x41,0x41,0x41,0xFF,0x00,0x00,/*"站",2*/
};
/****************************************/
/* 定义ASCII字库8列*16行 */
/****************************************/
uchar code Ezk[]={
/*-- 文字: 2 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*"2",0*/
/*-- 文字: 5 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,
/*-- 文字: . --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,/*".",0*/
/*-- 文字: 7 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,/*"7",0*/
/*-- 文字: 摄氏单位 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x18,0x24,0x24,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,/*"C",0*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",0*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",1*/
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,/*":",2*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",3*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",4*/
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,/*":",5*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",6*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,/*"1",7*/
};
/*状态检查,LCD是否忙*/
void Checkbusy()
{
uchar dat;//状态信息(判断是否忙)
RS=0; // 数据指令选择,D/I(RS)=“L” ,表示 DB7∽DB0 为显示指令数据
RW=1; //R/W=“H” ,E=“H”数据被读到DB7∽DB0
do
{
Port=0x00;
EN=1; //EN下降源
_nop_(); //一个时钟延时
dat=Port;
EN=0;
dat=(0x80 & dat);
}
while(!(dat==0x00)); //仅当第7位为0时才可操作(判别busy信号)
}
/*写命令到LCD中*/
Wcmd(uchar cmd)
{
Checkbusy();//状态检查,LCD是否忙
RS=0; //向LCD发送命令。RS=0写指令,RS=1写数据
RW=0;//R/W=“L” ,E=“H→L”数据被写到 IR 或 DR
Port=cmd; //com :命令
EN=1;//EN下降源
_nop_();
_nop_();
EN=0;
}
/*设置页 0xb8是页的首地址*/
void Setpage(uchar page)
{
page=0xb8|page; //1011 1xxx 0<=page<=7 设定页地址--X 0-7,8行为一页64/8=8,共8页
Wcmd(page);
}
/*设定显示开始行,0xc0是行的首地址*/
void Setx(uchar x)
{
x=0xc0|x; //1100 0000
Wcmd(x); //设置从哪行开始:0--63,一般从0 行开始显示
}
/*设定列地址--Y 0-63 ,0x40是列的首地址*/
void Sety(uchar y)
{
y=y&0x3f; //column最大值为64,越出 0=<column<=63
y= 0x40|y; //01xx xxxx
Wcmd(y);
}
/*开关显示,0x3f是开显示,0x3e是关显示*/
void SetOnOff(uchar onoff)
{
onoff=0x3e|onoff; //0011 111x,onoff只能为0或者1
Wcmd(onoff);
}
/*写显示数据 */
void Writedata(uchar dat)
{
Checkbusy();//状态检查,LCD是否忙
RS=1; //RS=0写指令,RS=1写数据
RW=0;////R/W=“L” ,E=“H→L”数据被写到 IR 或 DR
Port=dat;//dat:显示数据
EN=1; //EN下降源
_nop_();
_nop_();
EN=0;
}
/*选择屏幕screen: 0-全屏,1-左屏,2-右屏*/
void SelectScreen(uchar screen)
{
switch(screen)
{
case 0: cs1=0;//全屏
_nop_();
_nop_();
_nop_();
cs2=0;
_nop_();
_nop_();
_nop_();
break;
case 1: cs1=0;//左屏
_nop_();
_nop_();
_nop_();
cs2=1;
_nop_();
_nop_();
_nop_();
break;
case 2: cs1=1;//右屏
_nop_();
_nop_();
_nop_();
cs2=0;
_nop_();
_nop_();
_nop_();
break;
}
}
/*清屏screen: 0-全屏,1-左屏,2-右*/
void ClearScreen(uchar screen)
{
uchar i,j;
SelectScreen(screen);
for(i=0;i<8;i++) //控制页数0-7,共8页
{
Setpage(i);
Sety(0);
for(j=0;j<64;j++) //控制列数0-63,共64列
{
Writedata(0x00); //写点内容,列地址自动加1
}
}
}
/*延时程序*/
void delay(uint z)
{
uint i,j;
for(i=0; i<z; i++)
for(j = 0; j < 110; j++);
}
/*初始化LCD*/
void InitLCD()
{
Checkbusy();
SelectScreen(0);
SetOnOff(0); //关显示
SelectScreen(0);
SetOnOff(1); //开显示
SelectScreen(0);
ClearScreen(0);//清屏
Setx(0); //开始行:0
}
/*显示全角汉字*/
void Display(uchar ss,uchar page,uchar y,uchar number)
{
int i; //选屏参数,pagr选页参数,column选列参数,number选第几汉字输出
SelectScreen(ss);
y=y&0x3f;
Setpage(page); //写上半页
Sety(y); //控制列
for(i=0;i<16;i++) //控制16列的数据输出
{
Writedata(Hzk[i+32*number]); //i+32*number汉字的前16个数据输出
}
Setpage(page+1); //写下半页
Sety(y); //控制列
for(i=0;i<16;i++) //控制16列的数据输出
{
Writedata(Hzk[i+32*number+16]); //i+32*number+16汉字的后16个数据输出
}
}
/*显示半角汉字和数字和字母*/
void Displayen(uchar ss,uchar page,uchar y,uchar number)
{
uint i;//选屏参数,pagr选页参数,column选列参数,number选第几汉字输出
SelectScreen(ss);
y=y&0x3f;
Setpage(page); //写上半页
Sety(y);
for(i=0;i<8;i++)
{
Writedata(Ezk[i+16*number]);
}
Setpage(page+1); //写下半页
Sety(y);
for(i=0;i<8;i++)
{
Writedata(Ezk[i+16*number+8]);
}
}
//按键扫描及处理
void Key_Process(void)
{
if(Key1 == 0)
{
while(Key1==0);
Run_Dir_P_Flag = 1;
Run_Dir_N_Flag = 0;
}
if(Key2 == 0)
{
while(Key2==0);
Run_Dir_P_Flag = 0;
Run_Dir_N_Flag = 1;
}
if(Key3== 0)
{
while(Key3==0);
Next_Stat_Flag = 1;
}
if(Next_Stat_Flag == 1)
{
Next_Stat_Flag = 0;
if(Run_Dir_P_Flag ==1 )
{
State_Count ++;
if(State_Count>= 3)
{
State_Count = 0;
}
}
if(Run_Dir_N_Flag ==1 )
{
State_Count --;
if(State_Count < 0 )
{
State_Count = 2;
}
}
}
}
/*主函数*/
void main()
{
uint i;
InitLCD();//初始12864
ClearScreen(0);//清屏
Setx(0);//显示开始行
while(1)
{
Key_Process(); //按键扫描及处理
/* 可以多个显示,这里是4个一起显示*/
for(i=0;i<4;i++)
{
Display(1,0,i*16,i);//Display(选屏参数(cs0,cs1),pagr选页参数,column选列参数,number选第几汉字输出)
_nop_();
switch(State_Count)
{
case 0: Display(2,0,i*16,i+4); break; //河北科技大学
case 1: Display(2,0,i*16,i+17); break; //博物馆
case 2: Display(2,0,i*16,i+21); break; //火车站
default: break;
}
}
}
}
一周热门 更多>