//循环显示点阵(向左移动)
/****************点阵左移显示数据*****************************/
#include "reg52.h"
#define DataPort P0
#include "intrins.h"
sbit HCLK1=P2^4;
sbit HCLK2=P2^5;
sbit LCLK1=P2^0;
sbit LCLK2=P2^1;
sbit LCLK3=P2^2;
sbit LCLK4=P2^3;
void DelayMs(unsigned int );
unsigned char k1=0,k2=0,p1;
unsigned char j,p,k1,f,i1,p2=0,g=0;
unsigned char dis_buf[64];
unsigned char dis[32];
////////////////////////////////////////////
code unsigned char tab[][32]=
{
{/*-- 文字: 武 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x02,0x00,0x0A,0xFC,0x12,0x00,0x02,0xFF,0x7F,0x00,0x02,0x20,0x02,0x20,0x04,
0xE4,0x05,0x24,0x04,0x24,0x04,0x24,0x08,0xE4,0x48,0x1C,0x50,0x07,0x60,0x00,0x40},
{/*-- 文字: 汉 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x00,0x08,0x00,0xE8,0x3F,0x40,0x10,0x41,0x10,0x92,0x08,0x92,0x08,0x88,0x08,
0x08,0x05,0x04,0x05,0x07,0x02,0x04,0x05,0x84,0x18,0x64,0x70,0x14,0x20,0x00,0x00},
{0x08,0x00,0x08,0x08,0x88,0x1F,0x88,0x08,0xBF,0x08,0x88,0x08,0x8C,0x08,0x9C,0x08, //"机",
0xAA,0x08,0x8A,0x08,0x89,0x08,0x88,0x08,0x88,0x48,0x48,0x48,0x28,0x70,0x18,0x00},
{0x40,0x00,0x40,0x00,0x40,0x08,0xFE,0x1F,0x42,0x08,0x42,0x08,0xFE,0x0F,0x42,0x08, //"电",
0x42,0x08,0xFE,0x0F,0x42,0x08,0x40,0x00,0x40,0x20,0x40,0x20,0x80,0x3F,0x00,0x00},
{0x40,0x00,0x80,0x20,0xFF,0x7F,0x00,0x00,0xF8,0x0F,0x08,0x08,0x08,0x08,0xF8,0x0F, //"高",
0x00,0x20,0xFE,0x7F,0x02,0x20,0xF2,0x27,0x12,0x24,0x12,0x24,0xF2,0x27,0x02,0x30},
{0x08,0x02,0x28,0x12,0x7C,0x3F,0x92,0x04,0xA0,0x08,0x80,0x00,0xFC,0x1F,0x80,0x00, //"等",
0xFF,0x7F,0x00,0x02,0x00,0x0A,0xFC,0x1F,0x10,0x02,0x20,0x02,0x80,0x02,0x00,0x01},
{ 0x20,0x00,0x7F,0x20,0x24,0x7F,0x24,0x21,0x3C,0x21,0x24,0x21,0x24,0x21,0x3C,0x21, //"职",
0x24,0x3F,0x24,0x21,0xE4,0x12,0x3F,0x12,0x22,0x21,0x20,0x61,0xA0,0x40,0x20,0x00},
{0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x22,0x22,0x24,0x22,0x24,0x12,0x28,0x12, //"业",
0x28,0x0A,0x28,0x0A,0x28,0x06,0x20,0x02,0x20,0x02,0x20,0x22,0xFF,0x7F,0x00,0x00},
{ 0x08,0x02,0x08,0x02,0x08,0x12,0xC8,0x3F,0x3F,0x02,0x08,0x02,0x08,0x02,0xC8,0x1F, //"技",
0x58,0x10,0x8C,0x08,0x8B,0x08,0x08,0x05,0x08,0x02,0x08,0x0D,0x8A,0x70,0x64,0x20},
{0x80,0x00,0x80,0x02,0x80,0x0C,0x80,0x08,0x80,0x20,0xFF,0x7F,0x80,0x00,0xC0,0x01, //"术",
0xA0,0x02,0x90,0x04,0x88,0x08,0x84,0x70,0x83,0x20,0x80,0x00,0x80,0x00,0x80,0x00},
{0x44,0x10,0x88,0x10,0x88,0x08,0x00,0x04,0xFE,0x7F,0x02,0x40,0x01,0x20,0xF8,0x07, //"学",
0x00,0x02,0x80,0x21,0xFF,0x7F,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x00,0x40,0x00},
{0x08,0x02,0x08,0x04,0x08,0x20,0xC8,0x7F,0x3F,0x00,0x08,0x11,0x8C,0x60,0x5C,0x51, //"校",
0x2A,0x11,0x0A,0x0A,0x09,0x0A,0x08,0x04,0x08,0x0A,0x08,0x11,0xC8,0x70,0x38,0x20},
};
///////////////////////////////////////
void ScanLED()
{
unsigned char i;
unsigned int k=0x0001;
k=0x0001;
for(i=0;i<31;i+=2)
{
DataPort=0;
HCLK1=1;
HCLK2=1;
HCLK1=0;
HCLK2=0;
DataPort=dis_buf[i]; //显示16*16大小的字
LCLK4=1;
LCLK4=0;
DataPort=dis_buf[i+1]; //显示16*16大小的字
LCLK3=1;
LCLK3=0;
DataPort=dis_buf[i+32]; //显示16*8大小的字
LCLK2=1;
LCLK2=0;
// DataPort=yinwen16[i/2+p+16];//显示16*8大小的字
DataPort=dis_buf[i+33]; //显示16*8大小的字
LCLK1=1;
LCLK1=0;
DataPort=(unsigned char)(k>>8);
HCLK1=1;
HCLK1=0;
DataPort=(unsigned char)(k&0xFF);
HCLK2=1;
HCLK2=0;
k<<=1;
DelayMs(1);
}
j++;
if(j>5)
{
j=0; // 速度标志
for(p1=0;p1<31;p1+=2) //调整 数据
{
dis_buf[p1+33]=dis_buf[p1+33]>>1|(dis_buf[p1+32]&0x01)<<7;
dis_buf[p1+32]=dis_buf[p1+32]>>1|(dis_buf[p1+1]&0x01)<<7;
dis_buf[p1+1]=dis_buf[p1+1]>>1|(dis_buf[p1]&0x01)<<7;
if(p2<8)
{
dis_buf[p1]=dis_buf[p1]>>1|(dis[p1]&0x01)<<7;
dis[p1]=dis[p1]>>1;
}
else
{
dis_buf[p1]=dis_buf[p1]>>1|(dis[p1+1]&0x01)<<7;
dis[p1+1]=dis[p1+1]>>1;
}
}
/////////////////////////////////////////
k1++;p2+=1;
if(g>11) g=0;//控制所要显示二维数组的大小.
if(k1>16) // k1++用于控制移位个数,可以是16 8等
{
k1=1;p2=0;
for(f=0;f<32;f++) dis[f]=tab[g][f];
g+=1;//从固定表中获取所要显示的数据.
}
}
}
///////////////////////////////
void DelayMs(unsigned int t)
{
unsigned int i=0;
for(;t>0;t--)for(i=0;i<100;i++);
}
//////////////////////////////////
void main(void)
{
while(1)
{
ScanLED();
DelayMs(10);
}
}