?? four word step by step display.c
字號:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define SCAN P1 //行驅動接到P2
sbit STCP=P3^7; //595 STR
sbit OE=P1^7; //595 OE/G
sbit G1=P3^6; //154 G1
uint word; //字模計數器
uchar move; //列指針
uchar line; //行指針
uchar speed=10; //設定移動速度
uint stay=2500; //設定停留時間
uchar BUFF[10]; //緩存數組
uchar code disp[]; //字模數組
void delay()
{
uchar i;
for(i=0;i<50;i++);
}
void out_rxd(uchar x) //從串口發送數據
{
SBUF=~x;
while(TI==0); //等待發送完畢
TI=0;
}
/********************裝載一線點陣數據********************/
void loadline()
{
uchar s;
for(s=0;s<5;s++) //s為要顯示的字數+1(顯示4字+1=5)
{
BUFF[2*s]=disp[word+32*s+2*line];
BUFF[2*s+1]=disp[word+1+32*s+2*line];
}
}
/********************發送一線移動數據********************/
void sendline()
{
char s;
uchar inc,temp,tempcol;
if(move<8) inc=0;
else inc=1;
for(s=7+inc;s>=0+inc;s--)
{
if(move<8) tempcol=move;
else tempcol=move-8;
temp=(BUFF[s]<<tempcol)|(BUFF[s+1]>>(8-tempcol)); //字模左邊字節左移tempcol位,
//右邊字節右移8-tempcol位,2者相或
temp=~temp; //字模反相
SBUF=temp; //把BUFF中的字節從右到左移位、相或 后發送輸出
while(TI==0); //等待發送完畢 while(!TI);
TI=0;
}
}
void main()
{
char s;
uint k;
uchar sp,y=0;
move=0;
word=0;
OE=0;
G1=0;
SCON=0; //設置串口為工作方式0(同步通信方式,TxD輸出同步脈沖)
while(1)
{
while(word<1152) //(4+32)*32=1152
{
while(move<16) //數據移位
{
for(sp=0;sp<speed;sp++) //移動速度
{
for(line=0;line<16;line++) //行掃描
{
loadline(); //裝載一線點陣數據
sendline(); //發送一線移動數據
SCAN=line; //顯示第line行
STCP=1; //鎖存為高,595鎖存信號
STCP=0;
delay(); //延時,等待一段時間,產生視覺暫留
}
}
move++; //移動一步(一位)
}
move=0;
word=word+32; //下一個字
if(word%128==0) //完全顯示4字的時候停留一段時間(4*32=128)
{
for(k=0;k<stay;k++) //停留時間(循環顯示)
{
for(s=3;s>=0;s--) //送一行字型編碼
{
out_rxd(disp[word+1+32*s+2*y]);
out_rxd(disp[word+32*s+2*y]);
}
SCAN=y; //顯示第y行
STCP=1; //鎖存為高,595鎖存信號
STCP=0;
delay(); //延時一段時間,讓LED亮起來(視覺暫留)
if(++y==16) y=0; //y++; if(y==16) y=0; 行加1
}
}
}
word=0;
}
}
uchar code disp[]={
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,
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,
////////////////////////////////////////////////////////////////////////////////
/*-- 文字: 對 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x10,0x00,0x10,0x7C,0x10,0x04,0x10,0x05,0xFE,0x44,0x10,0x24,0x10,0x19,0x10,
0x08,0x90,0x14,0xD0,0x24,0x90,0x22,0x10,0x42,0x10,0x80,0x10,0x00,0x50,0x00,0x20,
/*-- 文字: 酒 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x40,0x00,0x2F,0xFE,0x21,0x20,0x01,0x20,0x97,0xFC,0x55,0x24,0x15,0x24,0x25,0x24,
0x25,0x24,0x26,0x3C,0xC4,0x04,0x47,0xFC,0x44,0x04,0x47,0xFC,0x44,0x04,0x00,0x00,
/*-- 文字: 當 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x80,0x10,0x90,0x08,0x98,0x0C,0x90,0x08,0xA0,0x00,0x80,0x3F,0xFC,0x00,0x04,
0x00,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x04,0x3F,0xFC,0x00,0x04,0x00,0x00,
/*-- 文字: 歌 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x20,0x7F,0x20,0x02,0x40,0x7A,0x7E,0x4A,0x84,0x7B,0x28,0x02,0x20,0xFF,0xA0,
0x02,0x20,0x7A,0x20,0x4A,0x20,0x4A,0x50,0x7A,0x48,0x02,0x8C,0x0B,0x06,0x04,0x04,
/*-- 文字: 人 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x01,0x00,0x01,0x80,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80,
0x04,0x80,0x04,0x40,0x08,0x60,0x08,0x30,0x10,0x18,0x20,0x0E,0x40,0x04,0x00,0x00,
/*-- 文字: 生 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x80,0x10,0xC0,0x10,0x80,0x10,0x88,0x1F,0xFC,0x20,0x80,0x20,0x80,0x40,0x88,
0x9F,0xFC,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x84,0x7F,0xFE,0x00,0x00,
/*-- 文字: 幾 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x00,0x0F,0xE0,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,
0x08,0x20,0x08,0x20,0x08,0x22,0x10,0x22,0x10,0x22,0x20,0x1E,0x40,0x00,0x00,0x00,
/*-- 文字: 何 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x08,0x00,0x0C,0x00,0x1B,0xFE,0x10,0x08,0x30,0x08,0x27,0xC8,0x64,0x48,0xA4,0x48,
0x24,0x48,0x27,0xC8,0x24,0x48,0x20,0x08,0x20,0x08,0x20,0x28,0x20,0x10,0x00,0x00,
/*-- 文字: 譬 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x3C,0x40,0x25,0xFC,0x3C,0x88,0x20,0x50,0x7D,0xFC,0xA4,0x20,0x3F,0xFE,0x24,0x20,
0x7F,0xFE,0x00,0x00,0x1F,0xF0,0x00,0x00,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,
/*-- 文字: 如 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x10,0x00,0x10,0x00,0x18,0x00,0x10,0x7E,0xFE,0x42,0x22,0x42,0x22,0x42,0x22,0x42,
0x22,0x42,0x24,0x42,0x14,0x42,0x08,0x42,0x14,0x7E,0x23,0x42,0x42,0x42,0x80,0x00,
/*-- 文字: 朝 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x08,0x00,0x08,0x7C,0x7F,0x44,0x08,0x44,0x3E,0x44,0x22,0x7C,0x3E,0x44,0x22,0x44,
0x3E,0x7C,0x08,0x44,0xFF,0x44,0x08,0x44,0x08,0x84,0x08,0x94,0x09,0x08,0x00,0x00,
/*-- 文字: 露 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x3F,0xF8,0x01,0x00,0x7F,0xFE,0x41,0x04,0x15,0x50,0x0A,0x28,0x3C,0x80,0x24,0xF8,
0x3D,0x50,0x12,0x20,0x5C,0xD8,0x53,0x06,0x50,0xF8,0x5C,0x88,0xE0,0xF8,0x00,0x88,
/*-- 文字: 去 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x7F,0xFE,0x02,0x00,0x06,0x00,0x08,0x20,0x10,0x10,0x3F,0xF8,0x10,0x10,0x00,0x00,
/*-- 文字: 日 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x00,0x1F,0xF0,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,0x00,0x00,
/*-- 文字: 苦 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x04,0x20,0x04,0x20,0x7F,0xFE,0x04,0x20,0x05,0x20,0x01,0x00,0xFF,0xFE,0x01,0x00,
0x01,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x00,0x00,
/*-- 文字: 多 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x01,0x00,0x01,0xF8,0x02,0x08,0x04,0x10,0x0B,0x20,0x10,0xC0,0x03,0x00,0x0C,0x80,
0x71,0xFE,0x02,0x04,0x0D,0x08,0x30,0x90,0x00,0x60,0x01,0x80,0x0E,0x00,0x70,0x00,
/*-- 文字: 慨 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x20,0x00,0x27,0xBE,0x24,0x88,0x27,0x88,0xB4,0xA8,0xAC,0xA8,0xA7,0xBE,0x24,0x18,
0x24,0x18,0x25,0x18,0x25,0xA8,0x26,0xA8,0x24,0x4A,0x20,0x8A,0x23,0x06,0x20,0x00,
/*-- 文字: 當 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x80,0x10,0x90,0x08,0x98,0x0C,0x90,0x08,0xA0,0x00,0x80,0x3F,0xFC,0x00,0x04,
0x00,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x04,0x3F,0xFC,0x00,0x04,0x00,0x00,
/*-- 文字: 以 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x10,0x24,0x10,0x22,0x10,0x23,0x10,0x22,0x10,0x20,0x10,0x20,0x10,0x21,0x10,
0x22,0x10,0x2C,0x30,0x38,0x30,0x70,0x68,0x20,0xC4,0x01,0x07,0x06,0x02,0x00,0x00,
/*-- 文字: 慷 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x20,0x20,0x23,0xFE,0x22,0x20,0x33,0xFC,0xAA,0x24,0xAB,0xFE,0xA2,0x24,0x23,0xFC,
0x22,0x20,0x23,0x24,0x22,0xE8,0x24,0xB0,0x25,0x28,0x26,0x2E,0x28,0xA4,0x20,0x40,
/*-- 文字: 憂 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x20,0x80,0x20,0x90,0x20,0x8C,0x30,0x88,0xA8,0x80,0xA7,0xFE,0xA0,0xA0,0x20,0xA0,
0x21,0x20,0x21,0x20,0x21,0x20,0x22,0x20,0x22,0x22,0x24,0x22,0x24,0x1E,0x28,0x00,
/*-- 文字: 思 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x00,0x1F,0xF8,0x11,0x08,0x11,0x08,0x1F,0xF8,0x11,0x08,0x11,0x08,0x1F,0xF8,
0x00,0x00,0x01,0x00,0x08,0x88,0x48,0x84,0x48,0x16,0xC8,0x12,0x07,0xF0,0x00,0x00,
/*-- 文字: 難 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0xA0,0x00,0x90,0xF9,0x10,0x09,0xFE,0x8B,0x20,0x4B,0x20,0x2D,0xFC,0x11,0x20,
0x19,0x20,0x29,0xFC,0x25,0x20,0x45,0x20,0x81,0x20,0x01,0xFE,0x01,0x00,0x01,0x00,
/*-- 文字: 忘 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x01,0x00,0x00,0x80,0xFF,0xFE,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x1F,0xFC,
0x00,0x00,0x09,0x00,0x28,0x88,0x28,0x84,0x28,0x16,0x48,0x14,0x47,0xF0,0x00,0x00,
/*-- 文字: 何 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x08,0x00,0x0C,0x00,0x1B,0xFE,0x10,0x08,0x30,0x08,0x27,0xC8,0x64,0x48,0xA4,0x48,
0x24,0x48,0x27,0xC8,0x24,0x48,0x20,0x08,0x20,0x08,0x20,0x28,0x20,0x10,0x00,0x00,
/*-- 文字: 以 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x10,0x24,0x10,0x22,0x10,0x23,0x10,0x22,0x10,0x20,0x10,0x20,0x10,0x21,0x10,
0x22,0x10,0x2C,0x30,0x38,0x30,0x70,0x68,0x20,0xC4,0x01,0x07,0x06,0x02,0x00,0x00,
/*-- 文字: 解 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x20,0x00,0x21,0xFC,0x7C,0x44,0x88,0x44,0x7E,0x44,0x4A,0x9C,0x7F,0x08,0x4A,0x90,
0x4A,0xFE,0x7F,0x10,0x4A,0x10,0x4B,0xFE,0x4A,0x10,0x42,0x10,0x4A,0x10,0x84,0x10,
/*-- 文字: 憂 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x20,0x80,0x20,0x90,0x20,0x8C,0x30,0x88,0xA8,0x80,0xA7,0xFE,0xA0,0xA0,0x20,0xA0,
0x21,0x20,0x21,0x20,0x21,0x20,0x22,0x20,0x22,0x22,0x24,0x22,0x24,0x1E,0x28,0x00,
/*-- 文字: 唯 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x01,0x00,0x01,0xA0,0xF1,0x10,0x93,0xFE,0x93,0x10,0x95,0x10,0x95,0xFE,0x99,0x10,
0x91,0x10,0xF1,0xFE,0x91,0x10,0x01,0x10,0x01,0x10,0x01,0xFE,0x01,0x00,0x00,0x00,
/*-- 文字: 有 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x01,0x00,0x01,0x00,0x7F,0xFE,0x02,0x00,0x04,0x00,0x0F,0xF0,0x18,0x10,0x28,0x10,
0x4F,0xF0,0x88,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x90,0x08,0x70,0x08,0x20,
/*-- 文字: 杜 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x00,0x00,0x10,0x40,0x10,0x40,0x10,0x40,0x10,0x40,0xFE,0x40,0x10,0x40,0x3B,0xFC,
0x34,0x40,0x54,0x40,0x50,0x40,0x90,0x40,0x10,0x40,0x10,0x40,0x17,0xFE,0x10,0x00,
/*-- 文字: 康 --*/
/*-- 宋體12; 此字體下對應的點陣為:寬x高=16x16 --*/
0x01,0x00,0x00,0x80,0x3F,0xFE,0x20,0x80,0x2F,0xF8,0x20,0x88,0x3F,0xFE,0x20,0x88,
0x2F,0xF8,0x28,0x80,0x24,0xC8,0x22,0xD8,0x24,0xA0,0x58,0x98,0x4A,0x8E,0x81,0x04,
////////////////////////////////////////////////////////////////////////////////
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,
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};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -