概述
//要用到 _nop_()
#define uint unsigned int
#define uchar unsigned char
sbit SH_595=P2^1;
sbit DATA_595=P2^0;
sbit ST_CP_595=P2^2;//74HC595(12)-ST_CP上升沿-移位寄存器的数据进入数据存储寄存器 输出锁存器的时钟信号端口
sbit MR_595=P2^3; //74HC595(10)-MR 为0将移位寄存器的数据清0
sbit E1_154=P2^4;//74HC154(18)-E1为0开列(col)输出 显示允许 控制信号端口
uchar keynum;
uchar tempbmp[64];
uint base=0; //在bmp地址中移动,从0 到 rows - 15,每次加2,实现移动效果
uint tmp=0;
uint col=0;
unsigned char code bmp1[]={ //字模表
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,0x08,0x00,0x08,0x1F,0xC8,0x92,0x48,0x52,0x48,0x32,0x48,0x12,0x48,0x1F,0xFF,
0x12,0x48,0x32,0x48,0x52,0x48,0x92,0x48,0x1F,0xC8,0x00,0x08,0x00,0x08,0x00,0x00,/*"单",0*/
0x00,0x00,0x00,0x01,0x00,0x06,0x7F,0xF8,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,
0x04,0x40,0xFC,0x40,0x04,0x7F,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,/*"片",1*/
0x08,0x20,0x08,0xC0,0x0B,0x00,0xFF,0xFF,0x09,0x00,0x08,0xC1,0x00,0x06,0x7F,0xF8,
0x40,0x00,0x40,0x00,0x40,0x00,0x7F,0xFC,0x00,0x02,0x00,0x02,0x00,0x1E,0x00,0x00,/*"机",2*/
0x02,0x00,0x02,0x00,0x42,0x00,0x33,0xFC,0x00,0x09,0x02,0x11,0x05,0x02,0x79,0xC2,
0x41,0x34,0x41,0x08,0x41,0x14,0x79,0x62,0x05,0x82,0x04,0x01,0x04,0x01,0x00,0x00,/*"设",3*/
0x02,0x00,0x02,0x00,0x42,0x00,0x33,0xFE,0x00,0x04,0x02,0x08,0x02,0x00,0x02,0x00,
0x02,0x00,0xFF,0xFF,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,/*"计",4*/
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,0x00,0x00,0x00,0x00,0x00,
};
void delayXms(uchar ms) // 延时毫秒@12M,ms最大值255
{
uchar i;
while(ms--)
for(i = 0;i<10;i++);
}
void SendByte(uchar a) //
{
uchar byte,i;
byte=a;
for(i=0;i<8;i++)
{
SH_595=0;
if(byte&0X80)
DATA_595=1;
else
DATA_595=0;
SH_595=1;
byte<<=1;
}
}
void sendbmp(uchar *bmp,uint rows)
{
for(base=0;base<=rows-64;base=base+2)// 左移动
{
for(tmp=0;tmp<5;tmp++) //每个字块显示5次
{
for(col=0;col<16;col++)
{
E1_154=0; //为0,允许显示
MR_595=0; //清理行输出,将移位寄存器的数据清0
MR_595=1;
ST_CP_595=0; //上升沿
ST_CP_595=1;
// base=64;
SendByte(bmp[base+col*2]); // 实际上595是输出 行数据分为第一个字上半屏,下半屏 第二个字上下半屏
SendByte(bmp[base+col*2+1]);
P1=col; //列控制
ST_CP_595=0; //上升沿
ST_CP_595=1;
delayXms(7); //显示2ms
}
}
}
}
void main()
{
//列选线
MR_595=1;
E1_154=1;
while(1)
{
sendbmp(&bmp1,sizeof(bmp1));//显示第2次字
}
}
最后
以上就是正直铃铛为你收集整理的c语言点阵字体位置,51单片机,点阵显示汉字(C语言)的全部内容,希望文章能够帮你解决c语言点阵字体位置,51单片机,点阵显示汉字(C语言)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复