源码:
- /*64*16点阵屏的显示点阵屏的显示*/
- #include <reg52.h>
- #include <intrins.h>
- #include <stdio.h>
- #define ulong unsigned long
- #define uchar unsigned char
- #define uint unsigned int
- #define DATAOUT P2 //指定P2口做为输出
- sfr ISP_CONTR = 0xe7;
- sbit DATA=DATAOUT^0; //列数据输出位
- sbit SCLH=DATAOUT^1; //列扫描时钟位
- sbit SCLT=DATAOUT^2; //列数据锁存位
- sbit AB=DATAOUT^4; //行数据输出位
- sbit SCK=DATAOUT^5; //行扫描时钟位
- sbit key1 = P3^2; //键盘位定义
- sbit key2 = P0^1;
- sbit key3 = P0^2;
- sbit key4 = P3^3;
- unsigned int idata numyear;
- unsigned char idata numt0,num,numf,nums,numday,nummonth; //全局变量定义numt0 为定时器0计数,num 为时间秒计数,numf 分钟计数,nums 小时计数
- unsigned char idata lhj[128]; //128字节RAM做为64*16点阵屏显示缓存
- void display(); //做为点阵扫描函数,将显示缓存的数据输出到点阵屏
- void display2();
- void displayS(unsigned int timer);//指定时间扫描显示
- void displayS2(unsigned int );
- void displaymove(unsigned char *lp,unsigned char c,unsigned char timer); //显示汉字内容的移动效果,LP指向要显示第一个字的首地址,C表示显示字的个数,
- void displaymove2(unsigned char *,unsigned char ,unsigned char ); //timer是移动的速度
- void displaymovetb(unsigned char din,unsigned char *lp,unsigned char c,unsigned char timer);
- void displaymovetb2(unsigned char ,unsigned char *,unsigned char ,unsigned char);
- void init(); //初始化函数
- void displayshijian(); //时间显示函数 //上下移动内容,din:1为向下,0为向上,
- void displayshijian2(); //lp指向要移入的内容表示有几个汉字要移,timer为移动速度
- //void delay(unsigned int z);//延时子函数
- /****************** 字模 *************************/
- code unsigned char WU[32]={
- 0x11,0x00,0x11,0x00,0x51,0x00,0x51,0x04,
- 0x7B,0xFE,0x54,0xA4,0x90,0xA4,0x1C,0xA4,
- 0x31,0x24,0xD1,0x44,0x12,0x44,0x12,0x44,
- 0x14,0x84,0x10,0x84,0x11,0x28,0x10,0x10};//物
- code unsigned char DIAN[32]={
- 0x02,0x00,0x02,0x00,0x02,0x10,0x7F,0xF8,
- 0x42,0x10,0x42,0x10,0x7F,0xF0,0x42,0x10,
- 0x42,0x10,0x7F,0xF0,0x42,0x10,0x02,0x00,
- 0x02,0x04,0x02,0x04,0x01,0xFC,0x00,0x00};//电
- code unsigned char XUE[32]={
- 0x22,0x08,0x11,0x08,0x11,0x10,0x00,0x20,
- 0x7F,0xFE,0x40,0x02,0x80,0x04,0x1F,0xE0,
- 0x00,0x40,0x01,0x84,0xFF,0xFE,0x01,0x00,
- 0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00}; //学
- code unsigned char YUAN[32]={
- 0x00,0x80,0x78,0x40,0x4F,0xFE,0x54,0x02,
- 0x58,0x14,0x63,0xF8,0x50,0x00,0x48,0x08,
- 0x4F,0xFC,0x48,0xA0,0x68,0xA0,0x50,0xA0,
- 0x41,0x22,0x41,0x22,0x42,0x1E,0x4C,0x00}; //院
- code unsigned char LING[32]={
- 0x1F,0xF0,0x01,0x00,0x7F,0xFE,0x41,0x02,
- 0x9D,0x74,0x01,0x00,0x1D,0x70,0x02,0x80,
- 0x0C,0x60,0x32,0x18,0xC1,0x06,0x0F,0xE0,
- 0x00,0x40,0x02,0x80,0x01,0x00,0x00,0x80}; //零
- code unsigned char JIU[32]={
- 0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x20,
- 0xFF,0xF0,0x04,0x20,0x04,0x20,0x04,0x20,
- 0x04,0x20,0x04,0x20,0x08,0x20,0x08,0x20,
- 0x10,0x22,0x10,0x22,0x20,0x1E,0xC0,0x00}; //九
- code unsigned char DIAN1[32]={
- 0x02,0x00,0x02,0x00,0x02,0x10,0x7F,0xF8,
- 0x42,0x10,0x42,0x10,0x7F,0xF0,0x42,0x10,
- 0x42,0x10,0x7F,0xF0,0x42,0x10,0x02,0x00,
- 0x02,0x04,0x02,0x04,0x01,0xFC,0x00,0x00}; //电
- code unsigned char ZI[32]={
- 0x00,0x00,0x3F,0xF0,0x00,0x10,0x00,0x20,
- 0x00,0x40,0x01,0x80,0x01,0x04,0xFF,0xFE,
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
- 0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00}; //子
- code unsigned char XIN[32]={
- 0x10,0x08,0x0A,0x1C,0x7F,0x60,0x00,0x40,
- 0x22,0x40,0x14,0x44,0xFF,0xFE,0x0A,0x48,
- 0x7F,0x48,0x08,0x48,0x0A,0x48,0x29,0x88,
- 0x48,0x88,0x89,0x08,0x28,0x08,0x10,0x08}; //新
- code unsigned char NIAN[32]={
- 0x08,0x00,0x08,0x08,0x1F,0xFC,0x11,0x00,
- 0x21,0x00,0x41,0x10,0x1F,0xF8,0x11,0x00,
- 0x11,0x00,0x11,0x04,0xFF,0xFE,0x01,0x00,
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00}; //年
- code unsigned char KUAI[32]={
- 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x88,
- 0x5B,0xFC,0x54,0x88,0x50,0x88,0x90,0x88,
- 0x10,0x88,0x1F,0xFE,0x10,0x80,0x11,0x40,
- 0x11,0x20,0x12,0x10,0x14,0x0E,0x18,0x04}; //快
- code unsigned char LE[32]={
- 0x00,0x20,0x00,0xF0,0x1F,0x00,0x10,0x00,
- 0x11,0x00,0x11,0x00,0x21,0x04,0x7F,0xFE,
- 0x01,0x00,0x01,0x00,0x09,0x20,0x09,0x10,
- 0x11,0x08,0x21,0x0C,0x45,0x04,0x02,0x00}; //乐
- code unsigned char BEI[32] ={
- 0x04,0x80,0x04,0x80,0x04,0x88,0x04,0x98,
- 0x04,0xA0,0x7C,0xC0,0x04,0x80,0x04,0x80,
- 0x04,0x80,0x04,0x80,0x04,0x80,0x04,0x80,
- 0x1C,0x82,0xE4,0x82,0x44,0x7E,0x00,0x00}; //北
- code unsigned char JING[32] = {
- 0x02,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,
- 0x00,0x10,0x1F,0xF8,0x10,0x10,0x10,0x10,
- 0x10,0x10,0x1F,0xF0,0x01,0x00,0x09,0x40,
- 0x09,0x30,0x11,0x18,0x25,0x08,0x02,0x00}; //京
- code unsigned char SHI[32] = {
- 0x00,0x08,0x04,0x08,0x7E,0x08,0x44,0x08,
- 0x47,0xFE,0x44,0x08,0x44,0x08,0x7C,0x88,
- 0x44,0x48,0x44,0x48,0x44,0x08,0x44,0x08,
- 0x7C,0x08,0x44,0x48,0x00,0x28,0x00,0x10}; //时
- code unsigned char JIAN[32] = {
- 0x20,0x04,0x1B,0xFE,0x08,0x04,0x40,0x24,
- 0x4F,0xF4,0x48,0x24,0x48,0x24,0x48,0x24,
- 0x4F,0xE4,0x48,0x24,0x48,0x24,0x48,0x24,
- 0x4F,0xE4,0x48,0x24,0x40,0x14,0x40,0x08}; //间
- code unsigned char XL[32]={
- 0x07,0xc0,0x18,0x30,0x20,0x08,0x40,0x04,
- 0x4C,0x64,0x8C,0x62,0x80,0x02,0x80,0x02,
- 0x90,0x12,0x98,0x32,0x4C,0x64,0x47,0xC4,
- 0x20,0x08,0x18,0x30,0x07,0xC0,0x00,0x00}; //笑脸
- code unsigned char ANZHUO[32]={
- 0x08,0x20,0x03,0x80,0x07,0xc0,0x0d,0x60,
- 0x0f,0xe0,0x00,0x00,0x6f,0xec,0x6f,0xec,
- 0x6f,0xec,0x6f,0xec,0x6f,0xec,0x0f,0xe0,
- 0x06,0xc0,0x06,0xc0,0x06,0xc0,0x00,0x00}; //安卓
- code unsigned char HOU[32]={
- 0x02,0x00,0x02,0x00,0x02,0x08,0x03,0xFC,
- 0x02,0x00,0x02,0x10,0x3F,0xF8,0x20,0x10,
- 0x20,0x10,0x20,0x10,0x3F,0xF0,0x00,0x00,
- 0x29,0x10,0x24,0xC8,0x44,0x44,0x80,0x04}; //“点”
- code unsigned char MIN[32]={
- 0x00,0x80,0x04,0x80,0x04,0x40,0x08,0x40,
- 0x08,0x20,0x10,0x10,0x20,0x08,0x4F,0xEE,
- 0x84,0x24,0x04,0x20,0x04,0x20,0x04,0x20,
- 0x04,0x20,0x08,0x20,0x11,0x40,0x20,0x80}; //“分”
- code unsigned char NIAN2[32]={
- 0x08,0x00,0x08,0x08,0x1F,0xFC,0x11,0x00,
- 0x21,0x00,0x41,0x10,0x1F,0xF8,0x11,0x00,
- 0x11,0x00,0x11,0x04,0xFF,0xFE,0x01,0x00,
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
- }; //年
- code unsigned char YUE[32]={
- 0x00,0x10,0x0F,0xF8,0x08,0x10,0x08,0x10,
- 0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x10,
- 0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x10,
- 0x10,0x10,0x10,0x10,0x20,0x50,0x40,0x20,
- }; //月
- code unsigned char RI2[32]={
- 0x00,0x10,0x1F,0xF8,0x10,0x10,0x10,0x10,
- 0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,
- 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
- 0x10,0x10,0x1F,0xF0,0x10,0x10,0x00,0x00
- }; //日
- //时数据
- code unsigned char c[3][16]={
- ///*-- 文字: 0 --*//*-- 楷体_GB231212; 此字体下对应的点阵为:宽x高=8x16 --*/
- {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,},
- {///*-- 文字: 1 --*/
- 0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,},
- {///*-- 文字: 2 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00,}
- };
- code unsigned char d[10][16]={
- {///*-- 文字: 0 --*/
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
- },
- {///*-- 文字: 1 --*/
- 0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,
- },
- {///*-- 文字: 2 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00,
- },
- {///*-- 文字: 3 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00,
- },
- {///*-- 文字: 4 --*/
- 0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00,
- },
- {///*-- 文字: 5 --*/
- 0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00,
- },
- {///*-- 文字: 6 --*/
- 0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
- },
- {///*-- 文字: 7 --*/
- 0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
- },
- {///*-- 文字: 8 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,
- },
- {///*-- 文字: 9 --*/
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00,}
- };
- //分数据
- code unsigned char b[10][16]={
- {///*-- 文字: 0 --*/
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
- },
- {///*-- 文字: 1 --*/
- 0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,
- },
- {///*-- 文字: 2 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00,
- },
- {///*-- 文字: 3 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00,
- },
- {///*-- 文字: 4 --*/
- 0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00,
- },
- {///*-- 文字: 5 --*/
- 0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00,
- },
- {///*-- 文字: 6 --*/
- 0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
- },
- {///*-- 文字: 7 --*/
- 0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
- },
- {///*-- 文字: 8 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,
- },
- {///*-- 文字: 9 --*/
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00,
- }
- };
- code unsigned char a[6][16]={
- {///*-- 文字: 0 --*/
- 0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
- },
- {///*-- 文字: 1 --*/
- 0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,
- },
- {///*-- 文字: 2 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00,
- },
- {///*-- 文字: 3 --*/
- 0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00,
- },
- {///*-- 文字: 4 --*/
- 0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00,
- },
- {///*-- 文字: 5 --*/
- 0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00,
- }
- };
- /*code unsigned char GGJJ[4][32]={ //"关关雎鸠"
- {0x10,0x10,0x08,0x18,0x04,0x20,0x04,0x48,
- 0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x04,
- 0xFF,0xFE,0x01,0x00,0x02,0x80,0x02,0x80,
- 0x04,0x40,0x08,0x30,0x30,0x0E,0xC0,0x04,},
- {0x10,0x10,0x08,0x18,0x04,0x20,0x04,0x48,
- 0x7F,0xFC,0x01,0x00,0x01,0x00,0x01,0x04,
- 0xFF,0xFE,0x01,0x00,0x02,0x80,0x02,0x80,
- 0x04,0x40,0x08,0x30,0x30,0x0E,0xC0,0x04,},
- {0x00,0xC0,0x08,0xA0,0x7D,0x24,0x49,0xFE,
- 0x4B,0x20,0x7D,0x28,0x49,0xFC,0x49,0x20,
- 0x79,0x28,0x49,0xFC,0x49,0x20,0x4D,0x20,
- 0xF1,0x24,0x41,0xFE,0x01,0x00,0x01,0x00,},
- {0x20,0x20,0x20,0x48,0x21,0xFC,0x29,0x08,
- 0xFD,0x48,0x29,0x08,0x29,0x28,0x29,0x10,
- 0x29,0x04,0x29,0xFE,0x28,0x04,0x2A,0x24,
- 0x4D,0xF4,0x48,0x04,0x80,0x14,0x00,0x08}
- };
- code unsigned char ZHZZ[4][32]={ //"在河之洲"
- {0x02,0x00,0x02,0x00,0x02,0x04,0xFF,0xFE,
- 0x04,0x00,0x04,0x40,0x08,0x40,0x08,0x50,
- 0x13,0xF8,0x30,0x40,0x50,0x40,0x90,0x40,
- 0x10,0x40,0x10,0x44,0x17,0xFE,0x10,0x00,},
- { 0x40,0x04,0x3F,0xFE,0x10,0x08,0x00,0x08,
- 0x80,0x48,0x67,0xE8,0x24,0x48,0x0C,0x48,
- 0x14,0x48,0x24,0x48,0xE7,0xC8,0x24,0x48,
- 0x20,0x08,0x20,0x08,0x20,0x28,0x20,0x10,},
- { 0x02,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
- 0x7F,0xF8,0x00,0x10,0x00,0x20,0x00,0x40,
- 0x00,0x80,0x01,0x00,0x02,0x00,0x0C,0x00,
- 0x30,0x00,0x48,0x06,0x07,0xFC,0x00,0x00,},
- {0x01,0x04,0x41,0x04,0x31,0x24,0x11,0x24,
- 0x81,0x24,0x65,0xB4,0x23,0x6C,0x0B,0x6C,
- 0x11,0x24,0x21,0x24,0xE1,0x24,0x21,0x24,
- 0x22,0x24,0x22,0x24,0x24,0x04,0x20,0x04}
- };
- code unsigned char YTSN[4][32]={ //"窈窕淑女"
- {0x02,0x00,0x41,0x00,0x7F,0xFE,0x48,0x22,
- 0x90,0x14,0x04,0x40,0x08,0x48,0x11,0xFC,
- 0x7E,0x48,0x04,0x48,0x08,0x48,0x14,0x48,
- 0x22,0x88,0x7E,0x88,0x01,0x28,0x02,0x10,
- },
- {0x02,0x00,0x41,0x00,0x7F,0xFE,0x48,0x22,
- 0x92,0x94,0x02,0x80,0x22,0x90,0x12,0x98,
- 0x16,0xA0,0x0A,0xC0,0x12,0xA0,0x62,0x98,
- 0x04,0x8A,0x04,0x82,0x18,0x7E,0x60,0x00,},
- {0x02,0x00,0x42,0x00,0x33,0x80,0x12,0x7C,
- 0x82,0x44,0x62,0x44,0x2F,0xC4,0x0A,0x44,
- 0x12,0x28,0x27,0x28,0xEA,0x90,0x32,0x10,
- 0x22,0x28,0x2A,0x46,0x24,0x84,0x21,0x00,},
- {0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,
- 0x02,0x04,0xFF,0xFE,0x04,0x20,0x04,0x20,
- 0x08,0x20,0x10,0x20,0x0C,0x40,0x02,0x80,
- 0x01,0x80,0x06,0x60,0x18,0x18,0x60,0x08,
- }
- };
- code unsigned char JZHQ[4][32]={ //“君子好逑”
- {0x00,0x10,0x3F,0xF8,0x04,0x10,0x04,0x14,
- 0xFF,0xFE,0x04,0x10,0x04,0x10,0x3F,0xF0,
- 0x08,0x00,0x08,0x08,0x1F,0xFC,0x18,0x08,
- 0x28,0x08,0x48,0x08,0x8F,0xF8,0x08,0x08,},
- {0x00,0x00,0x3F,0xF0,0x00,0x10,0x00,0x20,
- 0x00,0x40,0x01,0x80,0x01,0x04,0xFF,0xFE,
- 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
- 0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,},
- {0x10,0x00,0x11,0xFC,0x10,0x04,0x10,0x08,
- 0xFC,0x10,0x24,0x20,0x24,0x24,0x27,0xFE,
- 0x24,0x20,0x44,0x20,0x28,0x20,0x10,0x20,
- 0x28,0x20,0x44,0x20,0x84,0xA0,0x00,0x40,},
- {0x00,0x40,0x40,0x50,0x30,0x48,0x17,0xFC,
- 0x00,0x40,0x02,0x48,0xF1,0x50,0x10,0x40,
- 0x11,0x50,0x16,0x4C,0x10,0x44,0x11,0x40,
- 0x10,0x80,0x28,0x06,0x47,0xFC,0x00,0x00}
- }; */
- /*code unsigned char DH1[32] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- };
- code unsigned char DH2[32] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- };
- code unsigned char DH3[32] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x01,0x80,0x03,0xC0,0xFF,0xFF,
- 0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- };
- code unsigned char DH4[32] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- }; */
- void init() //初始化程序
- {
- TMOD = 0x01; // 定时器0为工作方式1
- TH0 = (65536-50000)/256; //定时50mS
- TL0 = (65536-50000)%256;
- EA = 1; //开总中断
- ET0 = 1; //开定时器0中断
- EX0 = 1; //开外部中断0
- EX1 = 1; //开外部中断1
- IT0 = 0; //设置外部中断0的中断方式为0 低电平触发
- IT1 = 0;
- TR0 = 1; //启动定时器0
- num = 0;
- nums = 12;
- numf = 30;
- numyear = 2013;
- nummonth = 1;
- numday = 15;
- }
- void displayshijian() //显示时间函数
- {
- unsigned char i,j,p1,k1,p2,k2;
- p1 = nums/10;
- k1 = nums%10; //小时数据
- p2 = numf/10;
- k2 = numf%10; //分钟数据
-
- for(i=0;i<128;i++) //显示缓存清空
- {
- lhj[i]=0;
- }
- for(i=0,j=0;i<128;)
- {
- lhj[i]=c[p1][j];
- lhj[i+1]=d[k1][j];
-
- i=i+8;
- j=j+1;
- }
-
- for(i=2,j=0;i<128;)
- {
- lhj[i]=HOU[j];
- lhj[i+1]=HOU[j+1];
-
- i=i+8;
- j=j+2;
- }
-
- for(i=4,j=0;i<128;)
- {
- lhj[i]=a[p2][j];
- lhj[i+1]=b[k2][j];
-
- i=i+8;
- j=j+1;
- }
-
- for(i=6,j=0;i<128;)
- {
- lhj[i]=MIN[j];
- lhj[i+1]=MIN[j+1];
-
- i=i+8;
- j=j+2;
- }
- displayS(1);
- }
- void displayshijian2() //显示时间函数
- {
-
- unsigned char i,j,p1,k1,p2,k2;
- p1 = nums/10;
- k1 = nums%10; //小时数据
- p2 = numf/10;
- k2 = numf%10; //分钟数据
-
- for(i=0;i<128;i++) //显示缓存清空
- {
- lhj[i]=0;
- }
- for(i=0,j=0;i<128;)
- {
- lhj[i]=c[p1][j];
- lhj[i+1]=d[k1][j];
-
- i=i+8;
- j=j+1;
- }
-
- for(i=2,j=0;i<128;)
- {
- lhj[i]=HOU[j];
- lhj[i+1]=HOU[j+1];
-
- i=i+8;
- j=j+2;
- }
-
- for(i=4,j=0;i<128;)
- {
- lhj[i]=a[p2][j];
- lhj[i+1]=b[k2][j];
-
- i=i+8;
- j=j+1;
- }
-
- for(i=6,j=0;i<128;)
- {
- lhj[i]=MIN[j];
- lhj[i+1]=MIN[j+1];
-
- i=i+8;
- j=j+2;
- }
- displayS(1);
- }
-
- void displaynyr() //年月日显示程序
- {
- unsigned char i,j,n1,n2,n3,n4,p1,k1,p2,k2; //n年 p1k1月 p2k2日
- n1 = numyear/1000;
- n2 = (numyear%1000)/100;
- n3 = (numyear%100)/10;
- n4 = numyear%10;
- p1 = nummonth/10;
- k1 = nummonth%10; //月数据
- p2 = numday/10;
- k2 = numday%10; //日数据
- for(i=0;i<128;i++) //显示缓存清空
- {
- lhj[i]=0;
- }
- for(i=0,j=0;i<128;)
- {
- lhj[i]=d[n1][j];
- lhj[i+1]=d[n2][j];
-
- i=i+8;
- j=j+1;
- }
- for(i=2,j=0;i<128;)
- {
- lhj[i]=d[n3][j];
- lhj[i+1]=d[n4][j];
-
- i=i+8;
- j=j+1;
- }
- for(i=4,j=0;i<128;)
- {
- lhj[i]=NIAN2[j];
- lhj[i+1]=NIAN2[j+1];
-
- i=i+8;
- j=j+2;
- }
- displayS(2);
- displaymovetb(1,0,4,2);
- for(i=0,j=0;i<128;)
- {
- lhj[i]=d[p1][j];
- lhj[i+1]=d[k1][j];
-
- i=i+8;
- j=j+1;
- }
- for(i=2,j=0;i<128;)
- {
- lhj[i]=YUE[j];
- lhj[i+1]=YUE[j+1];
-
- i=i+8;
- j=j+2;
- }
- for(i=4,j=0;i<128;)
- {
- lhj[i]=d[p2][j];
- lhj[i+1]=d[k2][j];
-
- i=i+8;
- j=j+1;
- }
- for(i=6,j=0;i<128;)
- {
- lhj[i]=RI2[j];
- lhj[i+1]=RI2[j+1];
-
- i=i+8;
- j=j+2;
- }
- displayS(3);
- displaymovetb(1,0,4,1);
- }
- void displaynyr2()
- {
- unsigned char i,j,p1,k1,p2,k2; //n年 p1k1月 p2k2日
- /* n1 = numyear/1000;
- n2 = (numyear%1000)/100;
- n3 = (numyear%100)/10;
- n4 = numyear%10; */
- p1 = nummonth/10;
- k1 = nummonth%10; //月数据
- p2 = numday/10;
- k2 = numday%10; //日数据
- /* for(i=0;i<128;i++) //显示缓存清空
- {
- lhj[i]=0;
- }
- for(i=0,j=0;i<128;)
- {
- lhj[i]=d[n1][j];
- lhj[i+1]=d[n2][j];
-
- i=i+8;
- j=j+1;
- }
- for(i=2,j=0;i<128;)
- {
- lhj[i]=d[n3][j];
- lhj[i+1]=d[n4][j];
-
- i=i+8;
- j=j+1;
- }
- for(i=4,j=0;i<128;)
- {
- lhj[i]=NIAN2[j];
- lhj[i+1]=NIAN2[j+1];
-
- i=i+8;
- j=j+2;
- }
- displayS2(1); */
- // displaymovetb2(1,0,4,1);
- /* for(i=0;i<128;i++) //显示缓存清空
- {
- lhj[i]=0;
- } */
- for(i=0,j=0;i<128;)
- {
- lhj[i]=d[p1][j];
- lhj[i+1]=d[k1][j];
-
- i=i+8;
- j=j+1;
- }
- for(i=2,j=0;i<128;)
- {
- lhj[i]=YUE[j];
- lhj[i+1]=YUE[j+1];
-
- i=i+8;
- j=j+2;
- }
- for(i=4,j=0;i<128;)
- {
- lhj[i]=d[p2][j];
- lhj[i+1]=d[k2][j];
-
- i=i+8;
- j=j+1;
- }
- for(i=6,j=0;i<128;)
- {
- lhj[i]=RI2[j];
- lhj[i+1]=RI2[j+1];
-
- i=i+8;
- j=j+2;
- }
- displayS2(1);
- // displaymovetb2(1,0,4,1);
- }
- void extern1() interrupt 2 //外部中断1
- {
- displaynyr2();
- if((key2 == 0)&&(key3 ==0))
- ISP_CONTR = 0x20;
-
- if(key3 == 0)
- {
- if(key3 == 0)
- {
- numday++;
- if(numday > 31)
- numday = 1;
- }
- }
- if(key2 == 0)
- {
- if(key2 == 0)
- {
- nummonth++;
- if(nummonth > 12)
- nummonth = 1;
- }
- }
- key4 = 1;
- }
- void extern0() interrupt 0 //外部中断0
- {
- displayshijian2();
- if(key2 == 0) //key2按键扫描,按下则 小时nums加1
- {
- if(key2 == 0)
- {
- nums++;
- if(nums > 23)
- nums =0;
- }
- }
- if(key3 == 0) //key3按键扫描,按下则 分钟numf加1
- {
- if(key3 == 0)
- {
- numf++;
- if(numf > 59)
- numf =0;
- }
- }
- /* if((key2 == 0)&&(key3 ==0))
- if((key2 == 0)&&(key3 ==0))
- {
- displaymove2(GGJJ,4,1);
- displaymove2(ZHZZ,4,1);
- displaymove2(YTSN,4,1);
- displaymove2(JZHQ,4,1);
- } */
- key1 = 1; //P3.2口赋高电平 防止下次重复进入中断
- }
-
- void T0timer() interrupt 1 //定时器0中断
- {
- TH0 = (65536-50000)/256;
- TL0 = (65536-50000)%256;
- numt0++;
- if(numt0 >= 40) //24M hz40次为一秒
- {
- numt0 = 0;
- num++;
- if(num > 59)
- { num = 0;
- numf++;
- }
- }
- }
- void displaytu_an()
- {
- unsigned char i,j;
- for(i=2,j=0;i<128;) //复制笑脸图案到中间
- {
- lhj[i]=XL[j];
- lhj[i+1]=XL[j+1];
- i=i+8;
- j=j+2;
- }
-
- for(i=4,j=0;i<128;) //复制安卓机器人图案到中间
- {
- lhj[i]=ANZHUO[j];
- lhj[i+1]=ANZHUO[j+1];
-
- i=i+8;
- j=j+2;
- }
- displayS(4); //显示图案约2秒
- }
- /*void displaydonghua()
- {
- unsigned char i,j;
- for(i=2,j=0;i<128;) //复制笑脸图案到中间
- {
- lhj[i]=DH1[j];
- lhj[i+1]=DH1[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(4);
- for(i=2,j=0;i<128;) //复制笑脸图案到中间
- {
- lhj[i]=DH2[j];
- lhj[i+1]=DH2[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(4);
- for(i=0,j=0;i<128;) //复制笑脸图案到中间
- {
- lhj[i]=DH4[j];
- lhj[i+1]=DH4[j+1];
- i=i+8;
- j=j+2;
- }
- for(i=2,j=0;i<128;) //复制笑脸图案到中间
- {
- lhj[i]=DH3[j];
- lhj[i+1]=DH3[j+1];
- i=i+8;
- j=j+2;
- }
- for(i=4,j=0;i<128;) //复制笑脸图案到中间
- {
- lhj[i]=DH4[j];
- lhj[i+1]=DH4[j+1];
- i=i+8;
- j=j+2;
- }
- for(i=6,j=0;i<128;) //复制笑脸图案到中间
- {
- lhj[i]=DH4[j];
- lhj[i+1]=DH4[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(5);
- } */
- void shijianzz()
- {
- /***************************************************///时间自增
- if(numf > 59) //分钟numf,小时nums自增
- {
- numf = 0;
- nums++;
- if(nums > 23)
- {
- nums = 0;
- numday++;
- switch(nummonth)
- {
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12: if(numday > 31)
- { nummonth++;
- numday=1;
- if(nummonth > 12)
- {
- nummonth =1;
- numyear++;
- }
- };
- break;
-
- case 4:
- case 6:
- case 9:
- case 11:if(numday > 30)
- { nummonth++;
- numday=1;
- if(nummonth > 12)
- {nummonth =1;
- numyear++;
- }
- };
- break;
- case 2: {
- if(numyear%4==0)
- if(numday > 29 )
- {
- nummonth++;
- numday=1;
- if(nummonth > 12)
- {nummonth = 1;
- numyear++;
- }
- }
- else
- if(numday > 28 )
- {
- nummonth++;
- numday=1;
- if(nummonth > 12)
- {nummonth =1;
- numyear++;
- }
- }
- };break;
- }
-
- }
- }
- /*********************************************************/
- }
- void displayXNKL()
- {
- /*********逐个显示“新年快乐”************/
- uchar i,j;
- for(i=0,j=0;i<128;)
- {
- lhj[i]=XIN[j];
- lhj[i+1]=XIN[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(2);
-
- for(i=2,j=0;i<128;)
- {
- lhj[i]=NIAN[j];
- lhj[i+1]=NIAN[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(2);
-
- for(i=4,j=0;i<128;)
- {
- lhj[i]=KUAI[j];
- lhj[i+1]=KUAI[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(2);
-
- for(i=6,j=0;i<128;)
- {
- lhj[i]=LE[j];
- lhj[i+1]=LE[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(2);
- /**********************************/
- }
- /********************** 主函数 *************************************/
- void main(void)
- {
- init(); //初始化程序
- displaytu_an();
- displayS(2);
- //displaydonghua();
- while(1)
- {
- // displaytu_an(); //显示图案
- shijianzz(); //时间自增函数
- displaymovetb(1,0,4,3); //向下清屏
- displaymovetb(1,WU,4,2); //向下显示“物电学院"
- displayS(1); //持续显示2S
- displaymovetb(0,0,4,2); //向上卷帘清屏
- displaymove(LING,4,1); //左跑马 “零九电子”
- displayS(1);
- displaymovetb(1,0,4,2); //向下卷帘清屏
- displayXNKL(); //由左往右显示‘新年快乐’
- displaymove(0,4,2); //左跑马清屏
- displaymovetb(1,BEI,4,3); //向下显示 “北京时间”
- displayS(2);
- displaymovetb(1,0,4,1);
- displaynyr(); //显示****年**月**日
- displayshijian(); //调用显示**点**分 时间函数
- displayS(5);
- displaymovetb(1,0,4,3); //向下清屏
- }
- }
- /********************** 主函数 *************************************/
- void display2() //显示子函数 中断调用才使用
- {
- unsigned char i,ia,tmp;
- unsigned int j;
- DATAOUT=0XFF;
- AB=0; //将行数据位清0,准备移位
- for(i=0;i<16;i++)
- {
- SCK=0;
- SCLT=0;
- for(ia=8;ia>0;)
- { //每行64个点,循环位移8个字节
- ia--; //循环四次
- tmp=~lhj[i*8+ia];
- for(j=0;j<8;j++)
- { //循环两次,每次移一个字节,
- SCLH=0;
- DATA=tmp&0x01; //将数据低位做输出
- tmp>>=1;
- SCLH=1; //将DATA上的数据移入寄存器
- } //移入单字节结束
- } //移入两个字节结束
- DATAOUT|=0X24;
- //等价于SCK=1;
- // SCLT=1;
- AB=1;
- }
- j=100;
- while(j--); //每一行的显示,保持6个字节的移位时间,因此,最后一行的显示,也要加入保持时间,补尝显示的亮度
- SCK=0;
- SCK=1; //将最后一行数据移出
- }
- void display() //显示子函数
- {
- unsigned char i,ia,tmp;
- unsigned int j;
- DATAOUT=0XFF;
- AB=0; //将行数据位清0,准备移位
- for(i=0;i<16;i++)
- {
- SCK=0;
- SCLT=0;
- for(ia=8;ia>0;)
- { //每行64个点,循环位移8个字节
- ia--; //循环四次
- tmp=~lhj[i*8+ia];
- for(j=0;j<8;j++)
- { //循环两次,每次移一个字节,
- SCLH=0;
- DATA=tmp&0x01; //将数据低位做输出
- tmp>>=1;
- SCLH=1; //将DATA上的数据移入寄存器
- } //移入单字节结束
- } //移入两个字节结束
- DATAOUT|=0X24;
- //等价于SCK=1;
- // SCLT=1;
- AB=1;
- }
- j=100;
- while(j--); //每一行的显示,保持6个字节的移位时间,因此,最后一行的显示,也要加入保持时间,补尝显示的亮度
- SCK=0;
- SCK=1; //将最后一行数据移出
- }
- void displayS2(unsigned int timer) //指定时间扫描显示函数 中断调用时用
- {
- unsigned char i;
- while(timer--)
- { //当timer=1时,大约1秒时间
- i=20;
- while(i--)
- display2();
- }
- }
- void displayS(unsigned int timer) //指定时间扫描显示函数
- {
- unsigned char i;
- while(timer--)
- { //当timer=1时,大约1秒时间
- i=20;
- while(i--)
- display();
- }
- }
- void displaymove(unsigned char *lp,unsigned char c,unsigned char timer)//左移显示函数,LP指向要显示第一个字的首地址,C表示显示字的个数,
- //timer是移动的速度
- {
- unsigned char i=0,j=0,ia=0;
- unsigned int tmp=0,timerc=0;
- unsigned char tmp2[16];
- c*=2;
- for(i=0;i<16;i++)
- tmp2[i]=0; //将缓冲区清0,
- while(c)
- {
- if(lp!=0)
- { //当lp指向的地址为0时,直接用组缓冲0补上,效果是将当前显示的内容移出
- tmp=c%2; //取余,目的是为了判断处理汉字的前半部份还是后半部份
- for(i=0;i<16;i++)
- {
- tmp2[i]=lp[i*2+tmp]; //取半个汉字点阵数据,16字节
- }
- if(tmp) //当tmp为1时,表时一个字数组处理完成,将地址转到下一个字
- lp+=32;
- }
- //--------------
- tmp=8; //变量再次利用
- while(tmp)
- { //循环8次,是将下一个字的前半部份的字节数据移入显示缓冲
- ia=0; //做为点阵数组的元素
- for(i=0;i<16;i++)
- { //移动是16行同时移,因此要处理16个字节
- for(j=0;j<7;j++)
- { //一行32个点四字节,有三字节在显示缓冲中移动
- lhj[ia]<<=1; //移当前显示缓冲的半行字节
- if(lhj[ia+1]&0x80) //判断后半行字节的高位是否为1,是移入前半行字节低位,否则不处理
- lhj[ia]++;
- ia++;
- }
- lhj[ia]<<=1; //一行32个点四字节,将最后一字节用下一个字补上
- if(tmp2[i]&0x80) //判断下一个要显示汉字的前半行字节的高位是否为1,是移入,否则不处理
- lhj[ia]++;
- ia++;
- tmp2[i]<<=1; //下一个要显示汉字的半行字节向高位移一位,准备下一次取位
- }
- tmp--;
- timerc=timer; //处理完16行,调用显示函数更新点阵
- while(timerc--) //循环做为处理的速度,即移动的速度
- display();
- }
- //----------
- c--; //移完一半,进入下一半或下一个汉字,直到结束
- }
- }
- void displaymove2(unsigned char *lp,unsigned char c,unsigned char timer)//左移显示函数,LP指向要显示第一个字的首地址,C表示显示字的个数,
- //timer是移动的速度
- {
- unsigned char i=0,j=0,ia=0;
- unsigned int tmp=0,timerc=0;
- unsigned char tmp2[16];
- c*=2;
- for(i=0;i<16;i++)
- tmp2[i]=0; //将缓冲区清0,
- while(c)
- {
- if(lp!=0)
- { //当lp指向的地址为0时,直接用组缓冲0补上,效果是将当前显示的内容移出
- tmp=c%2; //取余,目的是为了判断处理汉字的前半部份还是后半部份
- for(i=0;i<16;i++)
- {
- tmp2[i]=lp[i*2+tmp]; //取半个汉字点阵数据,16字节
- }
- if(tmp) //当tmp为1时,表时一个字数组处理完成,将地址转到下一个字
- lp+=32;
- }
- //--------------
- tmp=8; //变量再次利用
- while(tmp)
- { //循环8次,是将下一个字的前半部份的字节数据移入显示缓冲
- ia=0; //做为点阵数组的元素
- for(i=0;i<16;i++)
- { //移动是16行同时移,因此要处理16个字节
- for(j=0;j<7;j++)
- { //一行32个点四字节,有三字节在显示缓冲中移动
- lhj[ia]<<=1; //移当前显示缓冲的半行字节
- if(lhj[ia+1]&0x80) //判断后半行字节的高位是否为1,是移入前半行字节低位,否则不处理
- lhj[ia]++;
- ia++;
- }
- lhj[ia]<<=1; //一行32个点四字节,将最后一字节用下一个字补上
- if(tmp2[i]&0x80) //判断下一个要显示汉字的前半行字节的高位是否为1,是移入,否则不处理
- lhj[ia]++;
- ia++;
- tmp2[i]<<=1; //下一个要显示汉字的半行字节向高位移一位,准备下一次取位
- }
- tmp--;
- timerc=timer; //处理完16行,调用显示函数更新点阵
- while(timerc--) //循环做为处理的速度,即移动的速度
- display2();
- }
- //----------
- c--; //移完一半,进入下一半或下一个汉字,直到结束
- }
- }
- void displaymovetb(unsigned char din,unsigned char *lp,unsigned char c,unsigned char timer)
- //上下移动显示函数,din:1为向下,0为向上,lp指向要移入的内容,C表示有几个汉字要移,timer为移动速度
- {
- unsigned char i=0,j=0,ia=0,ib=0,ic=0,id=0;
- unsigned int tmp=0,timerc=0;
- if(din)
- { //判断移动方向,向下
- ia=32; //要移入第一个汉字的数组元素
- ib=64; //要移入第二个汉字的数组元素
- ic=96;
- id=128;
- i=16; //行索引
- while(i--)
- { //逐行处理
- j=120;
- while(j)
- {
- j--;
- lhj[j+8]=lhj[j]; //将上一行的内容复制到下一行,每两行内容相隔6个字节,复制15行
- }
- if(lp==0)
- { //最后一行的处理,判断移入的内容是否为空,是用0移入
- j=8;
- while(j--)
- lhj[j]=0;
- }
- else
- { //否则,取字数组处理
- ia--;ib--;ic--;id-- ;
- if(c==4)
- { //判断4个字,移一行,6个字节
- lhj[1]=lp[ia];
- ia--;
- lhj[0]=lp[ia];
- lhj[3]=lp[ib];
- ib--;
- lhj[2]=lp[ib];
- lhj[5]=lp[ic];
- ic--;
- lhj[4]=lp[ic];
- lhj[7]=lp[id];
- id--;
- lhj[6]=lp[id];
- }
-
- else if(c==3)
- { //否则3个字,将字放在中间,旁边补0
- lhj[0]=0;
- lhj[2]=lp[ia];
- ia--;
- lhj[1]=lp[ia];
- lhj[4]=lp[ib];
- ib--;
- lhj[3]=lp[ib];
- lhj[6]=lp[ic];
- ic--;
- lhj[5]=lp[ic];
- lhj[7]=0;
- }
- else if(c==2)
- { //否则2个字,将字放在中间,旁边补0
- lhj[0]=0;
- lhj[1]=0;
- lhj[3]=lp[ia];
- ia--;
- lhj[2]=lp[ia];
- lhj[5]=lp[ib];
- ib--;
- lhj[4]=lp[ib];
- lhj[6]=0;
- lhj[7]=0;
- }
- else if(c==1)
- { //否则1个字,将字放在中间,旁边补0
- lhj[0]=0;
- lhj[1]=0;
- lhj[2]=0;
- lhj[4]=lp[ia];
- ia--;
- lhj[3]=lp[ia];
- lhj[5]=0;
- lhj[6]=0;
- lhj[7]=0;
- }
- }
- timerc=timer; //处理完16行,调用显示函数更新点阵
- while(timerc--) //循环做为处理的速度,即移动的速度
- display();
- }
- }
- else
- { //移动方向,向上
- ia=0;ib=32;ic=64;id=96; //向上移动,移入汉字从低位开始
- for(i=0;i<16;i++)
- { //处理16行
- for(j=0;j<120;j++) //将下一行的内容复制到上一行,每两行内容相隔6个字节,复制15行
- lhj[j]=lhj[j+8];
- if(lp==0)
- { //最后一行的处理,判断移入的内容是否为空,是用0移入
- while(j!=128)
- {
- lhj[j]=0;
- j++;
- }
- }
- else
- { //否则,取字数组处理
- if(c==4)
- { //判断4个字,移一行,8个字节
- lhj[120]=lp[ia];
- lhj[121]=lp[ia+1];
- lhj[122]=lp[ib];
- lhj[123]=lp[ib+1];
- lhj[124]=lp[ic];
- lhj[125]=lp[ic+1];
- lhj[126]=lp[id];
- lhj[127]=lp[id+1];
- ia+=2;ib+=2;ic+=2;id+=2;
- }
- else if(c==3)
- { //否则3个字,将字放在中间,旁边补0
- lhj[120]=0;
- lhj[121]=lp[ia];
- lhj[122]=lp[ia+1];
- lhj[123]=lp[ib];
- lhj[124]=lp[ib+1];
- lhj[125]=lp[ic];
- lhj[126]=lp[ic+1];
- lhj[127]=0;
- ia+=2;ib+=2;ic+=2;
- }
- else if(c==2)
- { //否则2个字,将字放在中间,旁边补0
- lhj[120]=0;
- lhj[121]=0;
- lhj[122]=lp[ia];
- lhj[123]=lp[ia+1];
- lhj[124]=lp[ib];
- lhj[125]=lp[ib+1];
- lhj[126]=0;
- lhj[127]=0;
- ia+=2;ib+=2;
- }
- else
- { //判断1个字,移一行,8个字节,将字放在中间,两边补0
- lhj[120]=0;
- lhj[121]=0;
- lhj[122]=0;
- lhj[123]=lp[ia];
- ia++;
- lhj[124]=lp[ia];
- ia++;
- lhj[125]=0;
- lhj[126]=0;
- lhj[127]=0;
- }
- }
- timerc=timer; //处理完16行,调用显示函数更新点阵
- while(timerc--) //循环做为处理的速度,即移动的速度
- display();
- }
- }
-
- }
- void displaymovetb2(unsigned char din,unsigned char *lp,unsigned char c,unsigned char timer)
- //上下移动显示函数,din:1为向下,0为向上,lp指向要移入的内容,C表示有几个汉字要移,timer为移动速度
- {
- unsigned char i=0,j=0,ia=0,ib=0,ic=0,id=0;
- unsigned int tmp=0,timerc=0;
- if(din)
- { //判断移动方向,向下
- ia=32; //要移入第一个汉字的数组元素
- ib=64; //要移入第二个汉字的数组元素
- ic=96;
- id=128;
- i=16; //行索引
- while(i--)
- { //逐行处理
- j=120;
- while(j)
- {
- j--;
- lhj[j+8]=lhj[j]; //将上一行的内容复制到下一行,每两行内容相隔6个字节,复制15行
- }
- if(lp==0)
- { //最后一行的处理,判断移入的内容是否为空,是用0移入
- j=8;
- while(j--)
- lhj[j]=0;
- }
- else
- { //否则,取字数组处理
- ia--;ib--;ic--;id-- ;
- if(c==4)
- { //判断4个字,移一行,6个字节
- lhj[1]=lp[ia];
- ia--;
- lhj[0]=lp[ia];
- lhj[3]=lp[ib];
- ib--;
- lhj[2]=lp[ib];
- lhj[5]=lp[ic];
- ic--;
- lhj[4]=lp[ic];
- lhj[7]=lp[id];
- id--;
- lhj[6]=lp[id];
- }
- else if(c==3)
- { //否则3个字,将字放在中间,旁边补0
- lhj[0]=0;
- lhj[2]=lp[ia];
- ia--;
- lhj[1]=lp[ia];
- lhj[4]=lp[ib];
- ib--;
- lhj[3]=lp[ib];
- lhj[6]=lp[ic];
- ic--;
- lhj[5]=lp[ic];
- lhj[7]=0;
- }
- else if(c==2)
- { //否则2个字,将字放在中间,旁边补0
- lhj[0]=0;
- lhj[1]=0;
- lhj[3]=lp[ia];
- ia--;
- lhj[2]=lp[ia];
- lhj[5]=lp[ib];
- ib--;
- lhj[4]=lp[ib];
- lhj[6]=0;
- lhj[7]=0;
- }
- else if(c==1)
- { //否则1个字,将字放在中间,旁边补0
- lhj[0]=0;
- lhj[1]=0;
- lhj[2]=0;
- lhj[4]=lp[ia];
- ia--;
- lhj[3]=lp[ia];
- lhj[5]=0;
- lhj[6]=0;
- lhj[7]=0;
- }
- }
- timerc=timer; //处理完16行,调用显示函数更新点阵
- while(timerc--) //循环做为处理的速度,即移动的速度
- display();
- }
- }
- else
- { //移动方向,向上
- ia=0;ib=32;ic=64;id=96; //向上移动,移入汉字从低位开始
- for(i=0;i<16;i++)
- { //处理16行
- for(j=0;j<120;j++) //将下一行的内容复制到上一行,每两行内容相隔6个字节,复制15行
- lhj[j]=lhj[j+8];
- if(lp==0)
- { //最后一行的处理,判断移入的内容是否为空,是用0移入
- while(j!=128)
- {
- lhj[j]=0;
- j++;
- }
- }
- else
- { //否则,取字数组处理
- if(c==4)
- { //判断4个字,移一行,8个字节
- lhj[120]=lp[ia];
- lhj[121]=lp[ia+1];
- lhj[122]=lp[ib];
- lhj[123]=lp[ib+1];
- lhj[124]=lp[ic];
- lhj[125]=lp[ic+1];
- lhj[126]=lp[id];
- lhj[127]=lp[id+1];
- ia+=2;ib+=2;ic+=2;id+=2;
- }
- else if(c==3)
- { //否则3个字,将字放在中间,旁边补0
- lhj[120]=0;
- lhj[121]=lp[ia];
- lhj[122]=lp[ia+1];
- lhj[123]=lp[ib];
- lhj[124]=lp[ib+1];
- lhj[125]=lp[ic];
- lhj[126]=lp[ic+1];
- lhj[127]=0;
- ia+=2;ib+=2;ic+=2;
- }
- else if(c==2)
- { //否则2个字,将字放在中间,旁边补0
- lhj[120]=0;
- lhj[121]=0;
- lhj[122]=lp[ia];
- lhj[123]=lp[ia+1];
- lhj[124]=lp[ib];
- lhj[125]=lp[ib+1];
- lhj[126]=0;
- lhj[127]=0;
- ia+=2;ib+=2;
- }
- else
- { //判断1个字,移一行,8个字节,将字放在中间,两边补0
- lhj[120]=0;
- lhj[121]=0;
- lhj[122]=0;
- lhj[123]=lp[ia];
- ia++;
- lhj[124]=lp[ia];
- ia++;
- lhj[125]=0;
- lhj[126]=0;
- lhj[127]=0;
- }
- }
- timerc=timer; //处理完16行,调用显示函数更新点阵
- while(timerc--) //循环做为处理的速度,即移动的速度
- display();
- }
- }
- }
复制代码 |