這是一個(gè)51單片機(jī)的64*16LED點(diǎn)陣電子顯示屏設(shè)計(jì)包含原理圖+pcb圖+源程序
壓縮包全部的資料下載:
基于單片機(jī)的LED電子顯示屏的設(shè)計(jì).rar
(8.36 MB, 下載次數(shù): 739)
2015-6-25 15:09 上傳
點(diǎn)擊文件名下載附件
原理圖+PCB圖+源程序
下面分享一下部分源程序:
- /*64*16點(diǎn)陣屏的顯示點(diǎn)陣屏的顯示*/
- #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; //列數(shù)據(jù)輸出位
- sbit SCLH=DATAOUT^1; //列掃描時(shí)鐘位
- sbit SCLT=DATAOUT^2; //列數(shù)據(jù)鎖存位
- sbit AB=DATAOUT^4; //行數(shù)據(jù)輸出位
- sbit SCK=DATAOUT^5; //行掃描時(shí)鐘位
- 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 為定時(shí)器0計(jì)數(shù),num 為時(shí)間秒計(jì)數(shù),numf 分鐘計(jì)數(shù),nums 小時(shí)計(jì)數(shù)
- unsigned char idata lhj[128]; //128字節(jié)RAM做為64*16點(diǎn)陣屏顯示緩存
- void display(); //做為點(diǎn)陣掃描函數(shù),將顯示緩存的數(shù)據(jù)輸出到點(diǎn)陣屏
- void display2();
- void displayS(unsigned int timer);//指定時(shí)間掃描顯示
- void displayS2(unsigned int );
- void displaymove(unsigned char *lp,unsigned char c,unsigned char timer); //顯示漢字內(nèi)容的移動(dòng)效果,LP指向要顯示第一個(gè)字的首地址,C表示顯示字的個(gè)數(shù),
- void displaymove2(unsigned char *,unsigned char ,unsigned char ); //timer是移動(dòng)的速度
- 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(); //初始化函數(shù)
- void displayshijian(); //時(shí)間顯示函數(shù)//上下移動(dòng)內(nèi)容,din:1為向下,0為向上,
- void displayshijian2(); //lp指向要移入的內(nèi)容表示有幾個(gè)漢字要移,timer為移動(dòng)速度
- //void delay(unsigned int z);//延時(shí)子函數(shù)
- /****************** 字模 *************************/
- code unsigned char DIAN[32]={
- 0x00,0x00,0x00,0x00,0x1F,0xF8,0x11,0x10,
- 0x11,0x10,0x11,0x10,0x11,0x10,0xFF,0xFE,
- 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
- 0x1F,0xF9,0x00,0x01,0x00,0x0F,0x00,0x00,
- }; //電
- code unsigned char QI[32]={
- 0x04,0x00,0x08,0x00,0x32,0x00,0xE2,0x00,
- 0x2A,0x00,0x2A,0x00,0x2A,0x00,0x2A,0x00,
- 0x2A,0x00,0x2A,0x00,0x2A,0x00,0x2B,0xF0,
- 0x20,0x0C,0x20,0x02,0x00,0x0F,0x00,0x00,
- }; //氣
- code unsigned char GONG[32]={
- 0x00,0x04,0x20,0x04,0x20,0x04,0x20,0x04,
- 0x20,0x04,0x20,0x04,0x20,0x04,0x3F,0xFC,
- 0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,
- 0x20,0x04,0x20,0x04,0x00,0x04,0x00,0x00,
- }; //工
- code unsigned char CHENG[32]={
- 0x22,0x10,0x22,0x60,0x23,0x80,0x7F,0xFF,
- 0xC2,0x80,0x42,0x60,0x00,0x02,0x7A,0x92,
- 0x42,0x92,0x42,0x92,0x42,0xFE,0x42,0x92,
- 0x42,0x92,0x7A,0x92,0x00,0x82,0x00,0x00,
- }; //程
- code unsigned char LAO[32]={
- 0x04,0x08,0x04,0x10,0x24,0x20,0x24,0x40,
- 0x24,0xFC,0x24,0xA2,0xFD,0x22,0x26,0x22,
- 0x24,0x42,0x2C,0x42,0x14,0x42,0x24,0x82,
- 0x44,0x1E,0x04,0x00,0x04,0x00,0x00,0x00,
- }; //老
- code unsigned char SHI1[32]={
- 0x00,0x00,0x3F,0xE1,0x00,0x02,0x00,0x0C,
- 0xFF,0xF0,0x00,0x00,0x40,0x00,0x27,0xF8,
- 0x24,0x00,0x24,0x00,0x7F,0xFF,0x24,0x10,
- 0x24,0x08,0x27,0xF0,0x20,0x00,0x00,0x00,
- }; //師
- code unsigned char MEN[32]={
- 0x00,0x80,0x01,0x00,0x06,0x00,0x1F,0xFF,
- 0xE0,0x00,0x00,0x00,0x1F,0xFF,0x80,0x00,
- 0x60,0x00,0x00,0x00,0x20,0x00,0x20,0x02,
- 0x20,0x01,0x3F,0xFE,0x00,0x00,0x00,0x00,
- }; //們
- code unsigned char HAO[32]={
- 0x08,0x02,0x08,0x44,0x0F,0xA8,0xF8,0x10,
- 0x08,0x68,0x0F,0x86,0x00,0x00,0x01,0x00,
- 0x41,0x02,0x41,0x01,0x47,0xFE,0x49,0x00,
- 0x51,0x00,0x61,0x00,0x01,0x00,0x00,0x00,
- }; //好
- code unsigned char BEI[32] ={
- 0x00,0x04,0x04,0x06,0x04,0x04,0x04,0x08,
- 0x04,0x08,0xFF,0xFF,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0xFC,0x02,0x02,0x04,0x02,
- 0x08,0x02,0x10,0x02,0x00,0x1E,0x00,0x00,
- }; //北
- code unsigned char JING[32] = {
- 0x20,0x00,0x20,0x02,0x20,0x04,0x27,0xD8,
- 0x24,0x40,0x24,0x42,0xA4,0x41,0x64,0x7E,
- 0x24,0x40,0x24,0x40,0x24,0x40,0x27,0xD0,
- 0x20,0x08,0x20,0x06,0x20,0x00,0x00,0x00,
- }; //京
- code unsigned char SHI[32] = {
- 0x00,0x00,0x3F,0xFC,0x21,0x08,0x21,0x08,
- 0x21,0x08,0x3F,0xFC,0x00,0x00,0x08,0x00,
- 0x08,0x80,0x08,0x60,0x08,0x02,0x08,0x01,
- 0xFF,0xFE,0x08,0x00,0x08,0x00,0x00,0x00,
- }; //時(shí)
-
- code unsigned char JIAN[32] = {
- 0x00,0x00,0x1F,0xFF,0x80,0x00,0x60,0x00,
- 0x00,0x00,0x0F,0xF8,0x48,0x88,0x48,0x88,
- 0x48,0x88,0x4F,0xF8,0x40,0x00,0x40,0x02,
- 0x40,0x01,0x7F,0xFE,0x00,0x00,0x00,0x00,
- }; //間
- code unsigned char XL[32]={
- 0x00,0x00,0x07,0xc0,0x18,0x30,0x20,0x0C,
- 0x40,0xC4,0x8C,0x62,0x8C,0x32,0x80,0x12,
- 0x80,0x12,0x80,0x12,0x8C,0x32,0x4C,0x64,
- 0x40,0xC4,0x20,0x08,0x18,0x60,0x07,0xC0,
- }; //笑臉
- code unsigned char ANZHUO[32]={
- 0x00,0x00,0x00,0x00,0x03,0xE0,0x03,0xE0,
- 0x00,0x00,0x9B,0xF0,0x3B,0xFE,0x6B,0xFE,
- 0x7B,0xF0,0x6B,0xFE,0x3B,0xFE,0x9B,0xF0,
- 0x00,0x00,0x03,0xE0,0x03,0xE0,0x00,0x00,
- }; //安卓
- code unsigned char HOU[32]={
- 0x00,0x01,0x00,0x02,0x03,0xfC,0x02,0x30,
- 0x02,0x10,0x02,0x18,0xFE,0x16,0x12,0x10,
- 0x12,0x18,0x12,0x16,0x12,0x10,0x13,0xf0,
- 0x10,0x08,0x10,0x07,0x00,0x00,0x00,0x00,
- }; //“點(diǎn)”
- code unsigned char MIN[32]={
- 0x01,0x00,0x02,0x01,0x04,0x02,0x09,0x04,
- 0x11,0x18,0x61,0xE0,0x01,0x00,0x01,0x02,
- 0x01,0x01,0xC1,0x02,0x31,0xFC,0x08,0x00,
- 0x04,0x00,0x02,0x00,0x01,0x00,0x00,0x00,
- }; //“分”
- code unsigned char el[32]={
- 0x00,0x00,0x07,0x0C,0x10,0x14,0x10,0x24,
- 0x10,0x44,0x11,0x84,0x0e,0x0c,0x00,0x00,
- 0x00,0x00,0x07,0xe0,0x08,0x10,0x10,0x08,
- 0x10,0x08,0x08,0x10,0x07,0xe0,0x00,0x00,}; //20
- code unsigned char yw[32]={
- 0x00,0x00,0x08,0x04,0x08,0x04,0x1f,0xfc,
- 0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,
- 0x00,0x00,0x3e,0x02,0x22,0x02,0x22,0x02,
- 0x22,0x04,0x22,0x08,0x21,0xf0,0x00,0x00,}; //15
- code unsigned char NIAN2[32]={
- 0x00,0x20,0x04,0x20,0x18,0x20,0xE3,0xE0,
- 0x22,0x20,0x22,0x20,0x22,0x20,0x22,0x20,
- 0x3F,0xFF,0x22,0x20,0x22,0x20,0x22,0x20,
- 0x22,0x20,0x20,0x20,0x00,0x20,0x00,0x00,
- }; //年
- code unsigned char nop[32]={
- 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,
- };
- code unsigned char lw[32]={
- 0x00,0x00,0x07,0xe0,0x08,0x10,0x10,0x08,
- 0x10,0x08,0x08,0x10,0x07,0xe0,0x00,0x00,
- 0x00,0x00,0x3e,0x02,0x22,0x02,0x22,0x02,
- 0x22,0x04,0x22,0x08,0x21,0xf0,0x00,0x00,}; //05
- code unsigned char YUE[32]={
- 0x00,0x01,0x00,0x02,0x00,0x0C,0x3F,0xF0,
- 0x22,0x40,0x22,0x40,0x22,0x40,0x22,0x40,
- 0x22,0x40,0x22,0x40,0x22,0x42,0x22,0x41,
- 0x3F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
- }; //月
- code unsigned char shl[32]={
- 0x00,0x00,0x08,0x04,0x08,0x04,0x1f,0xfc,
- 0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,
- 0x00,0x00,0x0e,0xf8,0x10,0x84,0x20,0x84,
- 0x20,0x84,0x20,0x84,0x20,0x78,0x00,0x00,}; //16
- code unsigned char RI2[32]={
- 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,
- 0x41,0x02,0x41,0x02,0x41,0x02,0x41,0x02,
- 0x41,0x02,0x41,0x02,0x41,0x02,0x7F,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- }; //日
- code unsigned char xie[32]={
- 0x02,0x00,0x42,0x00,0x33,0xFC,0x00,0x08,
- 0x00,0x54,0x3F,0xC8,0x6A,0x52,0xAA,0x61,
- 0x3F,0xFE,0x01,0x00,0x08,0xC2,0x08,0x01,
- 0xFF,0xFE,0x08,0x00,0x08,0x00,0x00,0x00,
- };
- code unsigned char xie1[32]={
- 0x02,0x00,0x42,0x00,0x33,0xFC,0x00,0x08,
- 0x00,0x54,0x3F,0xC8,0x6A,0x52,0xAA,0x61,
- 0x3F,0xFE,0x01,0x00,0x08,0xC2,0x08,0x01,
- 0xFF,0xFE,0x08,0x00,0x08,0x00,0x00,0x00,
- };
- code unsigned char LAO1[32]={
- 0x04,0x08,0x04,0x10,0x24,0x20,0x24,0x40,
- 0x24,0xFC,0x24,0xA2,0xFD,0x22,0x26,0x22,
- 0x24,0x42,0x2C,0x42,0x14,0x42,0x24,0x82,
- 0x44,0x1E,0x04,0x00,0x04,0x00,0x00,0x00,
- }; //老
- code unsigned char SHI2[32]={
- 0x00,0x00,0x3F,0xE1,0x00,0x02,0x00,0x0C,
- 0xFF,0xF0,0x00,0x00,0x00,0x00,0x2f,0xF8,
- 0x28,0x00,0x28,0x00,0x3F,0xFF,0x28,0x10,
- 0x28,0x08,0x2f,0xF0,0x20,0x00,0x00,0x00,
- }; //師
- //時(shí)數(shù)據(jù)
- code unsigned char c[3][16]={
- ///*-- 文字: 0 --*//*-- 楷體_GB231212; 此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=8x16 --*/
- {0x00,0x00,0x07,0xe0,0x08,0x10,0x10,0x08,0x10,0x08,0x08,0x10,0x07,0xe0,0x00,0x00,},
- {///*-- 文字: 1 --*/
- 0x00,0x00,0x08,0x04,0x08,0x04,0x1f,0xfc,0x00,0x04,0x00,0x04,0x00,0x07,0x10,0x10,},
- {///*-- 文字: 2 --*/
- 0x00,0x00,0x07,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0e,0x0c,0x00,0x00,}
- };
- code unsigned char d[10][16]={
- {///*-- 文字: 0 --*/
- 0x00,0x00,0x07,0xe0,0x08,0x10,0x10,0x08,0x10,0x08,0x08,0x10,0x07,0xe0,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,}
- };
- //分?jǐn)?shù)據(jù)
- 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,
- }
- };
- void init() //初始化程序
- {
- TMOD = 0x01; // 定時(shí)器0為工作方式1
- TH0 = (65536-50000)/256; //定時(shí)50mS
- TL0 = (65536-50000)%256;
- EA = 1; //開總中斷
- ET0 = 1; //開定時(shí)器0中斷
- EX0 = 1; //開外部中斷0
- EX1 = 1; //開外部中斷1
- IT0 = 0; //設(shè)置外部中斷0的中斷方式為0 低電平觸發(fā)
- IT1 = 0;
- TR0 = 1; //啟動(dòng)定時(shí)器0
- num = 0;
- nums = 12;
- numf = 30;
- numyear = 2015;
- nummonth = 5;
- numday = 15;
- }
- void displayshijian() //顯示時(shí)間函數(shù)
- {
- unsigned char i,j,p1,k1,p2,k2;
- p1 = nums/10;
- k1 = nums%10; //小時(shí)數(shù)據(jù)
- p2 = numf/10;
- k2 = numf%10; //分鐘數(shù)據(jù)
-
- 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() //顯示時(shí)間函數(shù)
- {
-
- unsigned char i,j,p1,k1,p2,k2;
- p1 = nums/10;
- k1 = nums%10; //小時(shí)數(shù)據(jù)
- p2 = numf/10;
- k2 = numf%10; //分鐘數(shù)據(jù)
-
- 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; //月數(shù)據(jù)
- p2 = numday/10;
- k2 = numday%10; //日數(shù)據(jù)
- 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日
- p1 = nummonth/10;
- k1 = nummonth%10; //月數(shù)據(jù)
- p2 = numday/10;
- k2 = numday%10; //日數(shù)據(jù)
- 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);
- }
- 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按鍵掃描,按下則 小時(shí)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;
- }
- }
- key1 = 1; //P3.2口賦高電平 防止下次重復(fù)進(jìn)入中斷
- }
-
- void T0timer() interrupt 1 //定時(shí)器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;) //復(fù)制笑臉圖案到中間
- {
- lhj[i]=XL[j];
- lhj[i+1]=XL[j+1];
- i=i+8;
- j=j+2;
- }
-
- for(i=4,j=0;i<128;) //復(fù)制安卓機(jī)器人圖案到中間
- {
- lhj[i]=ANZHUO[j];
- lhj[i+1]=ANZHUO[j+1];
-
- i=i+8;
- j=j+2;
- }
- displayS(4); //顯示圖案約2秒
- }
- void shijianzz()
- {
- /***************************************************///時(shí)間自增
- if(numf > 59) //分鐘numf,小時(shí)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()
- {
- /*********逐個(gè)顯示“老師們好”************/
- uchar i,j;
- for(i=0,j=0;i<128;)
- {
- lhj[i]=LAO[j];
- lhj[i+1]=LAO[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(2);
-
- for(i=2,j=0;i<128;)
- {
- lhj[i]=SHI1[j];
- lhj[i+1]=SHI1[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(2);
-
- for(i=4,j=0;i<128;)
- {
- lhj[i]=MEN[j];
- lhj[i+1]=MEN[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(2);
-
- for(i=6,j=0;i<128;)
- {
- lhj[i]=HAO[j];
- lhj[i+1]=HAO[j+1];
- i=i+8;
- j=j+2;
- }
- displayS(2);
- /**********************************/
- }
- /********************** 主函數(shù) *************************************/
- void main(void)
- {
- init(); //初始化程序
- displaytu_an();
- displayS(4);
- while(1)
- {
- shijianzz(); //時(shí)間自增函數(shù)
- displaymovetb(1,0,4,3); //向下清屏
- displaymove(DIAN,4,1); //左跑馬 “電氣工程”
- displayS(2);
- displaymovetb(1,0,4,2); //向下卷簾清屏
- displayXNKL(); //由左往右顯示‘老師們好’
- displayS(2);
- displaymove(0,4,2); //左跑馬清屏
- displaymovetb(1,BEI,4,3); //向下顯示 “北京時(shí)間”
- displayS(2);
- displaymovetb(0,el,4,1);
- displayS(2);
- displaymovetb(1,lw,4,2);
- displayS(2);
- displaymove(xie,4,1);
- displayS(3);
- displaymovetb(1,0,4,3); //向下清屏
- displaytu_an();
- displayS(2);
- /*displaymovetb(1,0,4,1);
- displaynyr(); //顯示****年**月**日
- displayshijian(); //調(diào)用顯示**點(diǎn)**分 時(shí)間函數(shù)
- displayS(4000);*/
-
- }
- }
- /********************** 主函數(shù) *************************************/
- void display2() //顯示子函數(shù) 中斷調(diào)用才使用
- {
- unsigned char i,ia,tmp;
- unsigned int j;
- DATAOUT=0XFF;
- AB=0; //將行數(shù)據(jù)位清0,準(zhǔn)備移位
- for(i=0;i<16;i++)
- {
- SCK=0;
- SCLT=0;
- for(ia=8;ia>0;)
- { //每行64個(gè)點(diǎn),循環(huán)位移8個(gè)字節(jié)
- ia--; //循環(huán)四次
- tmp=~lhj[i*8+ia];
- for(j=0;j<8;j++)
- { //循環(huán)兩次,每次移一個(gè)字節(jié),
- SCLH=0;
- DATA=tmp&0x01; //將數(shù)據(jù)低位做輸出
- tmp>>=1;
- SCLH=1; //將DATA上的數(shù)據(jù)移入寄存器
- } //移入單字節(jié)結(jié)束
- } //移入兩個(gè)字節(jié)結(jié)束
- DATAOUT|=0X24;
- //等價(jià)于SCK=1;
- // SCLT=1;
- AB=1;
- }
- j=100;
- while(j--); //每一行的顯示,保持6個(gè)字節(jié)的移位時(shí)間,因此,最后一行的顯示,也要加入保持時(shí)間,補(bǔ)嘗顯示的亮度
- SCK=0;
- SCK=1; //將最后一行數(shù)據(jù)移出
- }
- void display() //顯示子函數(shù)
- {
- unsigned char i,ia,tmp;
- unsigned int j;
- DATAOUT=0XFF;
- AB=0; //將行數(shù)據(jù)位清0,準(zhǔn)備移位
- for(i=0;i<16;i++)
- {
- SCK=0;
- SCLT=0;
- for(ia=8;ia>0;)
- { //每行64個(gè)點(diǎn),循環(huán)位移8個(gè)字節(jié)
- ia--; //循環(huán)四次
- tmp=~lhj[i*8+ia];
- for(j=0;j<8;j++)
- { //循環(huán)兩次,每次移一個(gè)字節(jié),
- SCLH=0;
- DATA=tmp&0x01; //將數(shù)據(jù)低位做輸出
- tmp>>=1;
- SCLH=1; //將DATA上的數(shù)據(jù)移入寄存器
- } //移入單字節(jié)結(jié)束
- } //移入兩個(gè)字節(jié)結(jié)束
- DATAOUT|=0X24;
- //等價(jià)于SCK=1;
- // SCLT=1;
- AB=1;
- }
- j=100;
- while(j--); //每一行的顯示,保持6個(gè)字節(jié)的移位時(shí)間,因此,最后一行的顯示,也要加入保持時(shí)間,補(bǔ)嘗顯示的亮度
- SCK=0;
- SCK=1; //將最后一行數(shù)據(jù)移出
- }
- void displayS2(unsigned int timer) //指定時(shí)間掃描顯示函數(shù) 中斷調(diào)用時(shí)用
- {
- unsigned char i;
- while(timer--)
- { //當(dāng)timer=1時(shí),大約1秒時(shí)間
- i=20;
- while(i--)
- display2();
- }
- }
- void displayS(unsigned int timer) //指定時(shí)間掃描顯示函數(shù)
- {
- unsigned char i;
- while(timer--)
- { //當(dāng)timer=1時(shí),大約1秒時(shí)間
- i=20;
- while(i--)
- display();
- }
- }
- void displaymove(unsigned char *lp,unsigned char c,unsigned char timer)//左移顯示函數(shù),LP指向要顯示第一個(gè)字的首地址,C表示顯示字的個(gè)數(shù),
- //timer是移動(dòng)的速度
- {
- 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; //將緩沖區(qū)清0,
- while(c)
- {
- if(lp!=0)
- { //當(dāng)lp指向的地址為0時(shí),直接用組緩沖0補(bǔ)上,效果是將當(dāng)前顯示的內(nèi)容移出
- tmp=c%2; //取余,目的是為了判斷處理漢字的前半部份還是后半部份
- for(i=0;i<16;i++)
- {
- tmp2[i]=lp[i*2+tmp]; //取半個(gè)漢字點(diǎn)陣數(shù)據(jù),16字節(jié)
- }
- if(tmp) //當(dāng)tmp為1時(shí),表時(shí)一個(gè)字?jǐn)?shù)組處理完成,將地址轉(zhuǎn)到下一個(gè)字
- lp+=32;
- }
- //--------------
- tmp=8; //變量再次利用
- while(tmp)
- { //循環(huán)8次,是將下一個(gè)字的前半部份的字節(jié)數(shù)據(jù)移入顯示緩沖
- ia=0; //做為點(diǎn)陣數(shù)組的元素
- for(i=0;i<16;i++)
- { //移動(dòng)是16行同時(shí)移,因此要處理16個(gè)字節(jié)
- for(j=0;j<7;j++)
- { //一行32個(gè)點(diǎn)四字節(jié),有三字節(jié)在顯示緩沖中移動(dòng)
- lhj[ia]<<=1; //移當(dāng)前顯示緩沖的半行字節(jié)
- if(lhj[ia+1]&0x80) //判斷后半行字節(jié)的高位是否為1,是移入前半行字節(jié)低位,否則不處理
- lhj[ia]++;
- ia++;
- }
- lhj[ia]<<=1; //一行32個(gè)點(diǎn)四字節(jié),將最后一字節(jié)用下一個(gè)字補(bǔ)上
- if(tmp2[i]&0x80) //判斷下一個(gè)要顯示漢字的前半行字節(jié)的高位是否為1,是移入,否則不處理
- lhj[ia]++;
- ia++;
- tmp2[i]<<=1; //下一個(gè)要顯示漢字的半行字節(jié)向高位移一位,準(zhǔn)備下一次取位
- }
- tmp--;
- timerc=timer; //處理完16行,調(diào)用顯示函數(shù)更新點(diǎn)陣
- while(timerc--) //循環(huán)做為處理的速度,即移動(dòng)的速度
- display();
- }
- //----------
- c--; //移完一半,進(jìn)入下一半或下一個(gè)漢字,直到結(jié)束
- }
- }
- void displaymove2(unsigned char *lp,unsigned char c,unsigned char timer)//左移顯示函數(shù),LP指向要顯示第一個(gè)字的首地址,C表示顯示字的個(gè)數(shù),
- //timer是移動(dòng)的速度
- {
- 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; //將緩沖區(qū)清0,
- while(c)
- {
- if(lp!=0)
- { //當(dāng)lp指向的地址為0時(shí),直接用組緩沖0補(bǔ)上,效果是將當(dāng)前顯示的內(nèi)容移出
- tmp=c%2; //取余,目的是為了判斷處理漢字的前半部份還是后半部份
- for(i=0;i<16;i++)
- {
- tmp2[i]=lp[i*2+tmp]; //取半個(gè)漢字點(diǎn)陣數(shù)據(jù),16字節(jié)
- }
- if(tmp) //當(dāng)tmp為1時(shí),表時(shí)一個(gè)字?jǐn)?shù)組處理完成,將地址轉(zhuǎn)到下一個(gè)字
- lp+=32;
- }
- //--------------
- tmp=8; //變量再次利用
- while(tmp)
- { //循環(huán)8次,是將下一個(gè)字的前半部份的字節(jié)數(shù)據(jù)移入顯示緩沖
- ia=0; //做為點(diǎn)陣數(shù)組的元素
- for(i=0;i<16;i++)
- { //移動(dòng)是16行同時(shí)移,因此要處理16個(gè)字節(jié)
- for(j=0;j<7;j++)
- { //一行32個(gè)點(diǎn)四字節(jié),有三字節(jié)在顯示緩沖中移動(dòng)
- lhj[ia]<<=1; //移當(dāng)前顯示緩沖的半行字節(jié)
- if(lhj[ia+1]&0x80) //判斷后半行字節(jié)的高位是否為1,是移入前半行字節(jié)低位,否則不處理
- lhj[ia]++;
- ia++;
- }
- lhj[ia]<<=1; //一行32個(gè)點(diǎn)四字節(jié),將最后一字節(jié)用下一個(gè)字補(bǔ)上
- if(tmp2[i]&0x80) //判斷下一個(gè)要顯示漢字的前半行字節(jié)的高位是否為1,是移入,否則不處理
- lhj[ia]++;
- ia++;
- tmp2[i]<<=1; //下一個(gè)要顯示漢字的半行字節(jié)向高位移一位,準(zhǔn)備下一次取位
- }
- tmp--;
- timerc=timer; //處理完16行,調(diào)用顯示函數(shù)更新點(diǎn)陣
- while(timerc--) //循環(huán)做為處理的速度,即移動(dòng)的速度
- display2();
- }
- //----------
- c--; //移完一半,進(jìn)入下一半或下一個(gè)漢字,直到結(jié)束
- }
- }
- void displaymovetb(unsigned char din,unsigned char *lp,unsigned char c,unsigned char timer)
- //上下移動(dòng)顯示函數(shù),din:1為向下,0為向上,lp指向要移入的內(nèi)容,C表示有幾個(gè)漢字要移,timer為移動(dòng)速度
- {
- unsigned char i=0,j=0,ia=0,ib=0,ic=0,id=0;
- unsigned int tmp=0,timerc=0;
- if(din)
- { //判斷移動(dòng)方向,向下
- ia=32; //要移入第一個(gè)漢字的數(shù)組元素
- ib=64; //要移入第二個(gè)漢字的數(shù)組元素
- ic=96;
- id=128;
- i=16; //行索引
- while(i--)
- { //逐行處理
- j=120;
- while(j)
- {
- j--;
- lhj[j+8]=lhj[j]; //將上一行的內(nèi)容復(fù)制到下一行,每?jī)尚袃?nèi)容相隔6個(gè)字節(jié),復(fù)制15行
- }
- if(lp==0)
- { //最后一行的處理,判斷移入的內(nèi)容是否為空,是用0移入
- j=8;
- while(j--)
- lhj[j]=0;
- }
- else
- { //否則,取字?jǐn)?shù)組處理
- ia--;ib--;ic--;id-- ;
- if(c==4)
- { //判斷4個(gè)字,移一行,6個(gè)字節(jié)
- 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個(gè)字,將字放在中間,旁邊補(bǔ)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個(gè)字,將字放在中間,旁邊補(bǔ)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個(gè)字,將字放在中間,旁邊補(bǔ)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行,調(diào)用顯示函數(shù)更新點(diǎn)陣
- while(timerc--) //循環(huán)做為處理的速度,即移動(dòng)的速度
- display();
- }
- }
- else
- { //移動(dòng)方向,向上
- ia=0;ib=32;ic=64;id=96; //向上移動(dòng),移入漢字從低位開始
- for(i=0;i<16;i++)
- { //處理16行
- for(j=0;j<120;j++) //將下一行的內(nèi)容復(fù)制到上一行,每?jī)尚袃?nèi)容相隔6個(gè)字節(jié),復(fù)制15行
- lhj[j]=lhj[j+8];
- if(lp==0)
- { //最后一行的處理,判斷移入的內(nèi)容是否為空,是用0移入
- while(j!=128)
- {
- lhj[j]=0;
- j++;
- }
- }
- else
- { //否則,取字?jǐn)?shù)組處理
- if(c==4)
- { //判斷4個(gè)字,移一行,8個(gè)字節(jié)
- 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個(gè)字,將字放在中間,旁邊補(bǔ)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個(gè)字,將字放在中間,旁邊補(bǔ)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個(gè)字,移一行,8個(gè)字節(jié),將字放在中間,兩邊補(bǔ)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行,調(diào)用顯示函數(shù)更新點(diǎn)陣
- while(timerc--) //循環(huán)做為處理的速度,即移動(dòng)的速度
- display();
- }
- }
-
- }
- void displaymovetb2(unsigned char din,unsigned char *lp,unsigned char c,unsigned char timer)
- //上下移動(dòng)顯示函數(shù),din:1為向下,0為向上,lp指向要移入的內(nèi)容,C表示有幾個(gè)漢字要移,timer為移動(dòng)速度
- {
- unsigned char i=0,j=0,ia=0,ib=0,ic=0,id=0;
- unsigned int tmp=0,timerc=0;
- if(din)
- { //判斷移動(dòng)方向,向下
- ia=32; //要移入第一個(gè)漢字的數(shù)組元素
- ib=64; //要移入第二個(gè)漢字的數(shù)組元素
- ic=96;
- id=128;
- i=16; //行索引
- while(i--)
- { //逐行處理
- j=120;
- while(j)
- {
- j--;
- lhj[j+8]=lhj[j]; //將上一行的內(nèi)容復(fù)制到下一行,每?jī)尚袃?nèi)容相隔6個(gè)字節(jié),復(fù)制15行
- }
- if(lp==0)
- { //最后一行的處理,判斷移入的內(nèi)容是否為空,是用0移入
- j=8;
- while(j--)
- lhj[j]=0;
- }
- else
- { //否則,取字?jǐn)?shù)組處理
- ia--;ib--;ic--;id-- ;
- if(c==4)
- { //判斷4個(gè)字,移一行,6個(gè)字節(jié)
- 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個(gè)字,將字放在中間,旁邊補(bǔ)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個(gè)字,將字放在中間,旁邊補(bǔ)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個(gè)字,將字放在中間,旁邊補(bǔ)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行,調(diào)用顯示函數(shù)更新點(diǎn)陣
- while(timerc--) //循環(huán)做為處理的速度,即移動(dòng)的速度
- display();
- }
- }
- else
- { //移動(dòng)方向,向上
- ia=0;ib=32;ic=64;id=96; //向上移動(dòng),移入漢字從低位開始
- for(i=0;i<16;i++)
- { //處理16行
- for(j=0;j<120;j++) //將下一行的內(nèi)容復(fù)制到上一行,每?jī)尚袃?nèi)容相隔6個(gè)字節(jié),復(fù)制15行
- lhj[j]=lhj[j+8];
- if(lp==0)
- { //最后一行的處理,判斷移入的內(nèi)容是否為空,是用0移入
- while(j!=128)
- {
- lhj[j]=0;
- j++;
- }
- }
- else
- { //否則,取字?jǐn)?shù)組處理
- if(c==4)
- { //判斷4個(gè)字,移一行,8個(gè)字節(jié)
- 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個(gè)字,將字放在中間,旁邊補(bǔ)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個(gè)字,將字放在中間,旁邊補(bǔ)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個(gè)字,移一行,8個(gè)字節(jié),將字放在中間,兩邊補(bǔ)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行,調(diào)用顯示函數(shù)更新點(diǎn)陣
- while(timerc--) //循環(huán)做為處理的速度,即移動(dòng)的速度
- display();
- }
- }
- }
復(fù)制代碼
|