之前做过,但是程序找不到了。提供一个思路,将汉字用字符软件转成HEX数据,存在ROM中,然后FPGA从ROM中读出送到点阵上,滚动其实就是将点阵的地址左移或右移。很简单的。建议你自己动手做一下,比拿别人的程序跑更有意义。
include <c8051f330h>
#include <stdioh>
#include <mathh>
#include <Intrinsh>
#include <absacch>
#define SPEED 2000
#define TIME 1800
#define uint unsigned int
#define uchar unsigned char
#define BLKN 2 //用于点阵列扫描的595的个数
#define TOTAL 26 //待显示的字数
#define CONIO P1
uchar number;//d=0,
uchar control=0,choose,send;
uchar receive_number=3,send_number=0;
bit BUSY;
bit SMB_RW;
uchar hou=0;
uchar min=0;
uchar sec=0;
uchar sg;//时高位
uchar sd;//时低位
uchar fg;//分高位
uchar fd;//分低位
uchar mg;//秒高位
uchar md;//秒低位
sbit CLK=P1^7; //输出脉冲
sbit scyx=P1^6; //复位
sbit led=P0^7;
sbit pcf8563_scl=P0^5;//时钟频率
sbit pcf8563_sda=P0^4;//串行数据传输脚
uchar idata dispram[(BLKN/2)32]={0};
uchar receive1[3]={0x00,0x00,0x00};//时、分、秒
uchar send1[4]={0x02,0x33,0x25,0x03};//时、分、秒、器件地址
/字模表/
uchar code Bmp[][32]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x1C,0x18,0x38,0x1C,0x38,0x0E,0x38,0x0E,
0x78,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x18,0x07,0xF0,0x00,0x00,0x00,0x00},
/数字0/
{0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x0F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,
0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x0F,0xFC,0x00,0x00,0x00,0x00},
/数字1/
{0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF8,0x18,0x1C,0x38,0x1C,0x18,0x1C,0x00,0x38,
0x00,0x70,0x01,0xC0,0x07,0x00,0x0C,0x06,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0x00,0x00},
/数字2/
{0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x38,0x38,0x38,0x1C,0x00,0x38,0x03,0xF0,
0x03,0xF0,0x00,0x1C,0x00,0x0E,0x38,0x1C,0x38,0x1C,0x0F,0xF0,0x00,0x00,0x00,0x00},
/数字3/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0xF0,0x01,0xF0,0x03,0x70,0x0C,0x70,
0x18,0x70,0x30,0x70,0x3F,0xFE,0x00,0x70,0x00,0x70,0x03,0xFE,0x00,0x00,0x00,0x00},
/数字4/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFC,0x18,0x00,0x18,0x00,0x18,0xC0,0x1F,0xF8,
0x18,0x1C,0x00,0x1E,0x10,0x0E,0x38,0x1C,0x38,0x18,0x0F,0xF0,0x00,0x00,0x00,0x00},
/数字5/
{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF8,0x0C,0x3C,0x18,0x08,0x38,0x00,0x3F,0xF8,
0x7C,0x1C,0x78,0x0E,0x38,0x0E,0x38,0x0E,0x1C,0x1C,0x07,0xF0,0x00,0x00,0x00,0x00},
/数字6/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFE,0x3C,0x0C,0x30,0x18,0x00,0x30,0x00,0x60,
0x00,0xC0,0x01,0xC0,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x00,0x00,0x00,0x00},
/数字7/
{0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF8,0x38,0x0C,0x30,0x0E,0x3C,0x0C,0x1F,0xF8,
0x0F,0xF0,0x38,0x3C,0x30,0x0E,0x70,0x0E,0x38,0x0C,0x0F,0xF0,0x00,0x00,0x00,0x00},
/数字8/
{0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x38,0x18,0x30,0x0C,0x70,0x0E,0x30,0x0E,
0x38,0x3E,0x1F,0xEE,0x00,0x1C,0x18,0x18,0x3C,0x30,0x1F,0xE0,0x00,0x00,0x00,0x00},
/数字9/
{0x00,0x40,0x40,0x40,0x30,0x40,0x10,0x40,0x00,0x48,0x00,0x7C,0xF0,0x40,0x10,0x40,
0x10,0x40,0x10,0x40,0x10,0x40,0x12,0x40,0x14,0x40,0x18,0x44,0x17,0xFE,0x00,0x00},//让
{0x00,0x08,0x3F,0xFC,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08,
0x21,0x08,0x3F,0xF8,0x20,0x08,0x02,0x00,0x51,0x88,0x50,0x96,0x90,0x12,0x0F,0xF0},//思
{0x10,0x80,0x10,0xA0,0x20,0x94,0x21,0xFE,0x49,0x10,0xFB,0x10,0x15,0xFC,0x21,0x10,
0x41,0x10,0xFD,0xFC,0x01,0x10,0x01,0x10,0x1D,0x14,0xE1,0xFE,0x41,0x00,0x01,0x00},//维
{0x01,0x20,0x41,0x24,0x2F,0xFE,0x21,0x24,0x01,0x24,0x8F,0xFC,0x49,0x24,0x09,0x20,
0x1F,0xFE,0x29,0x22,0xE1,0x22,0x21,0x2A,0x22,0x24,0x22,0x20,0x24,0x20,0x28,0x20},//沸
{0x00,0x40,0x7A,0x48,0x49,0x50,0x4B,0xFC,0x48,0x80,0x7F,0xFE,0x49,0x10,0x4A,0x0E,
0x4D,0xF4,0x78,0x10,0x49,0x14,0x49,0xFE,0x48,0x04,0x4F,0xE4,0x88,0x14,0x18,0x08},//腾
{0x08,0x00,0x08,0x08,0x08,0xFC,0x7E,0x08,0x08,0x08,0x08,0x08,0xFE,0xF8,0x08,0x88,
0x28,0x80,0x2E,0x84,0x28,0x84,0x28,0x7C,0x28,0x00,0x58,0x06,0x8F,0xFC,0x00,0x00},//起
{0x01,0x00,0x01,0x00,0x01,0x08,0x7F,0xFC,0x01,0x00,0x21,0x10,0x19,0x30,0x09,0x44,
0xFF,0xFE,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x1E,0xC1,0x04,0x01,0x00,0x01,0x00},//来
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0C,0x00,0x1E,0x00,0x1E,0x00,0x0C,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x00,0x00},//,
{0x00,0x40,0x40,0x40,0x30,0x40,0x10,0x40,0x00,0x48,0x00,0x7C,0xF0,0x40,0x10,0x40,
0x10,0x40,0x10,0x40,0x10,0x40,0x12,0x40,0x14,0x40,0x18,0x44,0x17,0xFE,0x00,0x00},//让
{0x20,0x00,0x22,0x04,0x3F,0x7E,0x48,0x44,0x08,0x44,0xFF,0xC4,0x10,0x44,0x14,0x7C,
0x22,0x44,0x42,0x10,0x9F,0xF8,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10},//智
{0x08,0x20,0x7E,0xFC,0x08,0x20,0x3E,0xF8,0x08,0x20,0x7E,0xFC,0x08,0x20,0x3F,0xF8,
0x00,0x08,0xFF,0xFE,0x00,0x08,0x3F,0xF8,0x09,0x00,0x28,0xA8,0x48,0x24,0x07,0xE0},//慧
{0x08,0x08,0x0B,0xFC,0x10,0x00,0x20,0x00,0x40,0x00,0x08,0x04,0x17,0xFE,0x30,0x10,
0x50,0x10,0x90,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x50,0x10,0x20},//行
{0x00,0x40,0x08,0x40,0x7C,0x40,0x00,0x44,0x05,0xFE,0xFE,0x44,0x10,0x44,0x10,0x44,
0x20,0x44,0x24,0x44,0x42,0x84,0xFE,0x84,0x41,0x04,0x01,0x04,0x02,0x28,0x04,0x10},//动
{0x08,0x00,0x08,0x08,0x08,0xFC,0x7E,0x08,0x08,0x08,0x08,0x08,0xFE,0xF8,0x08,0x88,
0x28,0x80,0x2E,0x84,0x28,0x84,0x28,0x7C,0x28,0x00,0x58,0x06,0x8F,0xFC,0x00,0x00},//起
{0x01,0x00,0x01,0x00,0x01,0x08,0x7F,0xFC,0x01,0x00,0x21,0x10,0x19,0x30,0x09,0x44,
0xFF,0xFE,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x1E,0xC1,0x04,0x01,0x00,0x01,0x00},//来
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3C,0x00,0x66,0x00,0x66,0x00,0x66,0x00,0x3C,0x00,0x00,0x00},//};
uchar code Bmp1[][32]={
{0x01,0x00,0x11,0x00,0x11,0x00,0x11,0x08,0x3F,0xFC,0x21,0x00,0x41,0x00,0x41,0x00,
0x81,0x10,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x00,0x00},
{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},
{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},
{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},
{0x00,0x00,0x38,0x1C,0x44,0x22,0x54,0x2A,0x44,0x22,0x37,0xEC,0x08,0x10,0x10,0x08,
0x2E,0x74,0x20,0x04,0x21,0x84,0x24,0x24,0x13,0xC8,0x08,0x10,0x07,0xE0,0x00,0x00}
};
/字模表/
/系统函数的配置/
void sysclk_int(void) //内部晶振
{
OSCICL=0x83;
OSCICN=0xc3; //不分频
CLKSEL=0x00;
}
/
void delay1(uchar n) //延时程序
{
uchar j;
for(j=0;j<n;j++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
/
void delay(uint i) //毫秒延时
{
register uchar j;//
for(;i;i--)
for(j=0;j<255;j++);
}
void SPI_INT(void) //SPI初始化
{
SPI0CFG=0x40;
SPI0CN=0x01; //0000 0001最后一位是SPI使能位 SPI工作在三线主方式
SPI0CKR=0x0f; //SPI 时钟频率设置为100kHz 0x63
IE &= 0xbf; //关闭SPI中断
}
void SMB_INT(void) //SMB初始化
{
SMB0CF=0x5f; //使能SMB 允许时间扩充 定时器2低字节溢出时钟源
SMB0CF|=0x80;
}
void TIME01_INT(void) //定时器初始化
{
TCON=0x10; //定时器0允许
TMOD=0x01; //定时器0在16位工作方式
CKCON &= 0xf8;
CKCON |= 0x01; //定时器0使用系统4分频
TL0=0x03;
TH0=0x03;
IE|=0x02;
}
void TIME2_INT(void) //定时器2用于配置SMB的时钟频率
{
TMR2CN=0x00;
CKCON |= 0x00;
TMR2RLL = 0xef;
TMR2RLH = 0xff;
TMR2L = 0xef;
TMR2H = 0xff;
TMR2CN |= 0x0c;
}
void TIME3_INT(void)//用于I2C的超时检测
{
TMR3CN = 0x00; //定时器3为16位自动重载
CKCON &= ~0x40;
TMR3RLL = 0xaf;
TMR3RLH = 0x57;
TMR3L = 0xaf;
TMR3H = 0x57;
EIE1|=0x00;
TMR3CN |= 0x04;
}
void pio_int(void) // 端口配置
{
XBR0=0x06;
XBR1=0x40;
P0MDIN=0xff; //禁止模拟输入,0为模拟,1为数字
P0MDOUT=0x0d; //0为开漏,1为推挽(ff)
P0SKIP=0x08;
P1MDIN=0xff;
P1MDOUT=0xff; //低四位用于138
P1SKIP=0x00;
P0=0xff;
P1=0xff;
}
/呈现各种显示效果的函数集/
//void Jump_Word(uchar a) 立即跳显示一个字或一张图案
//void M_Word(uchar a) 卷帘出显示一个字或一张图案
//void M_Words(number) 显示几个交换的字
//void UP_Run(number) 向上滚屏n个字
//void L_Removeout(number) 右入左出n个字
//void M_Black(void) 黑屏
//void R_Removeout(number) 左入右出n个字
//
/立即跳显示一个字或一张图案/
void Jump_Word(uchar a)
{register uchar i,q;
for(i=0;i<32;i++)
{
for(q=0;q<BLKN/2;q++)
{dispram[i+q32]=Bmp[a][i];}
//if(i%2)delay(SPEED);
}
}
/卷帘出显示一个字或一张图案/
void M_Word(uchar a)
{register uchar i,q;
for(i=0;i<32;i++)
{
for(q=0;q<BLKN/2;q++)
{dispram[i+q32]=Bmp1[a][i];}
if(i%2)delay(SPEED);
}
}
/卷帘出显示number个字/
void M_Words(number)
{register uchar i,q,w;
for(w=0;w<number2/BLKN;w++)
{
for(i=0;i<32;i++)
{
for(q=0;q<BLKN/2;q++){dispram[i+q32]=Bmp[q+wBLKN/2][i];}
if(i%2)delay(SPEED);
}
delay(TIME);
}
}
/向上滚屏number个字/
void UP_Run(number)
{register uchar i,j,k,q;
for(i=0;i<number2/BLKN;i++)
{
for(j=0;j<16;j++)
{
for(k=0;k<15;k++)
{
for(q=0;q<BLKN/2;q++)
{
dispram[k2+q32]=dispram[(k+1)2+q32];
dispram[k2+1+q32]=dispram[(k+1)2+1+q32];
}
}
for(q=0;q<BLKN/2;q++)
{
dispram[30+q32]=Bmp[q+iBLKN/2][j2];
dispram[31+q32]=Bmp[q+iBLKN/2][j2+1];
}
delay(2SPEED);
}
delay(2TIME);
}
}
/左移出显示number个字/
void L_Removeout(number)
{register uchar i,j,k,l,q;
for(i=0;i<number;i++)
{
for(j=0;j<2;j++)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
for(q=0;q<BLKN/2;q++)
{
dispram[l2+q32]=dispram[l2+q32]<<1|dispram[l2+1+q32]>>7;
if(q==BLKN/2-1)
dispram[l2+1+q32]=dispram[l2+1+q32]<<1|Bmp[i][l2+j]>>(7-k);
else
dispram[l2+1+q32]=dispram[l2+1+q32]<<1|dispram[l2+(q+1)32]>>7;
}
}
delay(2SPEED);
}
}
}
/卷帘出黑屏/
void M_Black(void)
{register uchar i,q;
for(i=0;i<32;i++)
{
for(q=0;q<BLKN/2;q++)
{dispram[i+q32]=0x00;}
if(i%2)delay(SPEED);
}
}
/右移出显示number个字/
void R_Removeout(number)
{register uchar i,j,k,l,q;
for(i=0;i<number;i++)
{
for(j=2;j>0;j--)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
for(q=0;q<BLKN/2;q++)
{
dispram[l2+1+q32]=dispram[l2+1+q32]>>1|dispram[l2+q32]<<7;
if(q==0)
dispram[l2+q32]=dispram[l2+q32]>>1|Bmp[i][l2+j-1]<<(7-k);
else
dispram[l2+q32]=dispram[l2+q32]>>1|dispram[l2+1+(q-1)32]<<7;
}
}
delay(2SPEED);
}
}
}
/用于时钟芯片 *** 作的函数集/
//void write_pcf8563(void)写时钟芯片
//void read_pcf8563(void)读时钟芯片
//
void write_pcf8563(void)
{
SPI0CN &=~0x01; //暂时关掉SPI通讯
send =0xa2; //送子器件地址
while(BUSY);
BUSY=1;
SMB_RW=0;control=5;
STA=1; //开始传送
while(BUSY);
SPI0CN |=0x01; //重新开启SPI
}
void read_pcf8563(void) //读当时的时,分,钞
{
SPI0CN &=~0x01;
send =0xa2; //送子器件地址
while(BUSY);
BUSY=1;
SMB_RW=0;
STA=1;
send=0x02;
while(!SI);
BUSY=1;
send=0xa2;
while(BUSY);
BUSY=1;
SMB_RW=1;
STA=1;
while(BUSY);
BUSY=1;
sec=receive1[2]&0x7f;//读秒
min=receive1[1]&0x7f;//读分
hou=receive1[0]&0x3f;//读时
SPI0CN |=0x01;
}
void spit_time(void)//分别计算时、分、秒的各位数字
{
sg=(int)hou/16;
sd=(int)hou%16;
fg=(int)min/16;
fd=(int)min%16;
mg=(int)sec/16;
md=(int)sec%16;
}
void dat_int(void) //数据初始化
{
scyx=1;
CLK=0;
}
void sysclk_int(void);
void delay(unsigned n);
void pio_int(void);
void SPI_INT(void);
void SMB_INT(void);
void dat_int(void);
void TIME01_INT(void);
void TIME2_INT(void);
void TIME3_INT(void);
void write_pcf8563(void);
void read_pcf8563(void);
void spit_time(void);
/主函数/
void main(void) //主程序
{
register uchar i;
PCA0MD &= ~0x40;// 关闭看门狗
sysclk_int();
OSCICN |= 0x02;
/初始化检测pcf8563/
while(!pcf8563_sda)
{
XBR1 = 0x40;
pcf8563_scl = 0;
for(i = 0; i < 255; i++);
pcf8563_scl = 1;
while(!pcf8563_scl);
for(i = 0; i < 10; i++);
XBR1 = 0x00;
}
/初始化检测pcf8563/
pio_int();
TIME01_INT();
TIME2_INT();
TIME3_INT();
SPI_INT(); //SPI0DAT是SPI的数据寄存
SMB_INT();
spit_time();
EIE1|=0x01;
EA=1;
dat_int();
led=0;
TR0=0;
delay(1000);
write_pcf8563();
while(1)
{
TR0=0;
BUSY=0;
read_pcf8563();
spit_time();
TR0=1;
//Jump_Word(sg);
//Jump_Word(sd);
//Jump_Word(fg);
//Jump_Word(fd);
//Jump_Word(md);
//M_Word(md);
M_Word(4);
delay(10TIME);
M_Words(TOTAL);
UP_Run(TOTAL);
M_Black();
delay(10TIME);
L_Removeout(TOTAL);
delay(3TIME);
M_Black();
delay(10TIME);
R_Removeout(TOTAL);
delay(3TIME);
}//总while循环的结束
}//main函数的结束
void t0(void) interrupt 1 //定时器0的中断服务程序
{
register uchar m,n=BLKN;
TH0 = 0xfc;
TL0 = 0x18;
m = CONIO;
m = (++m)&0x0f;
for(n=0;n<BLKN;n++)
{
SPI0DAT = dispram[30-m2+n];//dispram[((BLKN-)n/2+1)30-m2-(n/2)30+n]
while(!SPIF);
SPIF=0;
}
CONIO &= 0xf0;
CLK = 1;
CONIO |= m;
CLK = 0;
scyx=1;
}
void SMBus_ISR (void) interrupt 7
{
bit FAIL = 0;
if (ARBLOST == 0) //如果赢得总线
{
switch (SMB0CN & 0xF0) //确定中断来源
{
case 0xe0: //主发送方式下产生开始条件
SMB0DAT = send;
SMB0DAT &= 0xFE;
SMB0DAT |= SMB_RW; //对发送的数据进行处理
STA = 0;
break;
case 0xc0: //主方式下发送
if (ACK)
{
if (SMB_RW == 0)
{
if(send_number<=3)
{
if(control==0)
{
SMB0DAT = send;
send_number+=5;
}
else
{
SMB0DAT = send1[send_number];
send_number++;
}
}
else
{
send_number=0;control=0;
STO = 1;
BUSY = 0;
}
}
else {;} //BUSY=0
}
else
{
STO = 1;
STA = 1;
}
break;
case 0x80: //主方式下接收
if (receive_number-1>0) //控制接收3个数据就结束
{
receive1[receive_number-1] = SMB0DAT;
ACK = 1;
receive_number--;
}
else
{
receive1[receive_number-1] = SMB0DAT;
receive_number=3;
BUSY = 0;
ACK = 0;
STO = 1;
}
break;
default:
FAIL = 1;
break;
}
}
else //输掉总线
{
FAIL = 1;
}
if (FAIL) //SMBUS通讯失败后的处理
{
SMB0CF &= ~0x80;
SMB0CF |= 0x80;
STA = 0;
STO = 0;
ACK = 0;
BUSY = 0;
FAIL = 0;
}
SI = 0;
}
void T3_ISR() interrupt 14 //定时器3中断服务程序 用于检测SMBus是否超时
{
SMB0CF &= ~0x80;
SMB0CF |= 0x80;
TMR3CN &=~0x80;
STA = 0;
BUSY = 0;
pcf8563_scl=1;
}
怕有些地方你不知道是怎么来的,所有我就把完整的程序都给你了。你自己取出你所需要的就好了。因为不同的显示效果还是得靠住函数来实现的。
如果住函数没有写好,那么你的移动方式的函数就很难写了的。希望能给楼主一点灵感。呵呵~
我还有几种效果的,但是所有的效果都必须基于我的那种显示方式。你仔细看下,和你的是不是一样的,显示缓存,各种动画效果就是移动的控制方式了
给你借鉴一下,具体的呢还得根据你的硬件来了。
在8X8点阵LED上显示柱形,让其先从左到右平滑移动三次,其次从右到左平滑移动三次,再次从上到下平滑移动三次,最后从下到上平滑移动三次,如此循环下去。
1. 程序设计内容
8X8点阵LED工作原理说明 :8X8点阵共需要64个发光二极管组成,且每个发光二极管是放置在行线和列线的交叉点上,当对应的某一列置1电平,某一行置0电平,则相应的二极管就亮;因此要实现一根柱形的亮法,如图49所示,对应的一列为一根竖柱,或者对应的一行为一根横柱,因此实现柱的亮的方法如下所述:
一根竖柱:对应的列置1,而行则采用扫描的方法来实现。
一根横柱:对应的行置0,而列则采用扫描的方法来实现。
你用取模软件先点个心形,然后用字节左右移来实现就可以了
我有1616点阵的各种动态效果程序
给你看下总共有12种动态效果,你改成88就可以了
/呈现各种显示效果的函数集/
void flash_bai(uchar flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)//百叶窗效果
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(l=0;l<8;l++)
{
if(j<8)
{
dispram[l4+1]=dispram[l4+1]&0xff<<j|(flash_word[(flash_heard+i)32+l4]>>(7-j));
dispram[l4+2]=dispram[l4+2]&0xff>>j|(flash_word[(flash_heard+i)32+l4+3]<<(7-j)&0x10);
}
else
{
dispram[l4] =dispram[l4]&0xff<<(j-7)|flash_word[(flash_heard+i)32+l4]>>(15-j);
dispram[l4+1]=flash_word[(flash_heard+i)32+l4]<<(j-7)|(flash_word[(flash_heard+i)32+l4+1]>>(15-j));
dispram[l4+2]=flash_word[(flash_heard+i)32+l4+2]<<(15-j)|(flash_word[(flash_heard+i)32+l4+3]>>(j-7));
dispram[l4+3]=(dispram[l4+3]&0xff>>(j-7))|flash_word[(flash_heard+i)32+l4+3]<<(15-j);
}
}
delay(sduSPEED);
}
delay(stateSPEED);
}
}
/霓虹灯效果/
void flash(uchar flash_word,uchar flash_heard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<=16;j++)
{
for(k=17;k>j;k--)
{
for(l=0;l<16;l++)
{
if(j>8)
{
dispram[l2] =1<<(8-k+j)|(flash_word[(flash_heard+i)32+l2]&0xff>>(16-j));
dispram[l2+1]=flash_word[(flash_heard+i)32+l2+1];
}
else
{
dispram[l2]=1<<(8-k+j);
dispram[l2+1]=1<<(16-k+j)|(flash_word[(flash_heard+i)32+l2+1]&0xff>>(8-j));
}
}
delay(sduSPEED);
}
for(k=17;k>j;k--)
{
for(l=0;l<16;l++)
{
if(j>8)
{
dispram[l2]=1<<(k-8)|(flash_word[(flash_heard+i)32+l2]&0xff>>(16-j));
}
else
{
dispram[l2]=1<<(k-8);
dispram[l2+1]=1<<k|(flash_word[(flash_heard+i)32+l2+1]&0xff>>(8-j));
}
}
delay(sduSPEED);
}
}
delay(stateSPEED);
}
}
/跳动的米奇/
void miqi_jump(void)
{uchar jump_i;
while((receive[1]&0x0f)<2)
{
switch (abc/7280)//(receive[0]&0x0f)%9
{
case 0:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i2] = Bmp1[14][jump_i2]<<1|Bmp1[14][jump_i2+1]>>7;
dispram[jump_i2+1] = Bmp1[14][jump_i2+1]<<1;//左移
}break;
case 1:for(jump_i=0;jump_i<15;jump_i++)
{dispram[0] = 0;
dispram[1] = 0;
dispram[jump_i2+2] = Bmp1[14][jump_i2];
dispram[jump_i2+3] = Bmp1[14][jump_i2+1];}
break;//下移
case 2:for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i2+1] = Bmp1[14][jump_i2+1]>>1|Bmp1[14][jump_i2]<<7;
dispram[jump_i2] = Bmp1[14][jump_i2]>>1;
}break;//右移
case 3:for(jump_i=0;jump_i<15;jump_i++)
{dispram[30] = 0;
dispram[31] = 0;
dispram[jump_i2] = Bmp1[14][jump_i2+2];
dispram[jump_i2+1] = Bmp1[14][jump_i2+3];}
break;//上移
case 4: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i2+2] = Bmp1[14][jump_i2]<<1|Bmp1[14][jump_i2+1]>>7;
dispram[jump_i2+3] = Bmp1[14][jump_i2+1]<<1;//左移
dispram[0] = 0;
dispram[1] = 0;
} break;//下移
case 5: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i2+1] = Bmp1[14][jump_i2+3]>>1|Bmp1[14][jump_i2+2]<<7;
dispram[jump_i2] = Bmp1[14][jump_i2+2]>>1;
dispram[30] = 0;
dispram[31] = 0;
} break;//上移
case 6: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i2+3] = Bmp1[14][jump_i2+1]>>1|Bmp1[14][jump_i2]<<7;
dispram[jump_i2+2] = Bmp1[14][jump_i2]>>1;
dispram[0] = 0;
dispram[1] = 0;
}
break;
case 7: for(jump_i=0;jump_i<16;jump_i++)
{
dispram[jump_i2] = Bmp1[14][jump_i2+2]<<1|Bmp1[14][jump_i2+3]>>7;
dispram[jump_i2+1] = Bmp1[14][jump_i2+3]<<1;//左移
dispram[30] = 0;
dispram[31] = 0;
} break;
case 8:for(jump_i=0;jump_i<32;jump_i++)
dispram[jump_i] = Bmp1[14][jump_i];break;
}
}
}
/从wordsp的第OpenDheard个字开始开门效果显示number个字/
//开门效果
void Open_door(uchar wordsp[][32],uchar OpenDheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i2]=dispram[i2]&0xff<<j|wordsp[OpenDheard+w][2i]&0xff>>(8-j);
dispram[i2+1]=dispram[i2+1]&0xff>>j|wordsp[OpenDheard+w][1+2i]&0xff<<(8-j);
}
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从wordsp的第CloseDheard个字开始关门效果显示number个字/
//关门效果
void Close_door(uchar wordsp[][32],uchar CloseDheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i2]=dispram[i2]&0xff>>j|wordsp[CloseDheard+w][2i]&0xff<<(8-j);
dispram[i2+1]=dispram[i2+1]&0xff<<j|wordsp[CloseDheard+w][1+2i]&0xff>>(8-j);
}
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从wordsp的第Far_Awayheard个字开始两边拉开显示number个字/
//两边拉开
void Far_Away(uchar wordsp[][32],uchar Far_Awayheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i2]=dispram[i2]<<j|wordsp[Far_Awayheard+w][2i]&0xff>>(8-j);
dispram[i2+1]=dispram[i2+1]>>j|wordsp[Far_Awayheard+w][1+2i]&0xff<<(8-j);
}
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从wordsp的第Close_Toheard个字开始两边合拢显示number个字/
//两边合拢
void Close_To(uchar wordsp[][32],uchar Close_Toheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,w;
for(w=0;w<number;w++)
{
for(j=1;j<9;j++)
{
for(i=0;i<16;i++)
{
dispram[i2]=dispram[i2]&0xff>>j|wordsp[Close_Toheard+w][2i]<<(8-j);
dispram[i2+1]=dispram[i2+1]&0xff<<j|wordsp[Close_Toheard+w][1+2i]>>(8-j);
}
delay(sduSPEED);
}
delay(stateTIME);
}
}
/卷帘出显示number个字/
//卷帘出显示
void M_Words(uchar wordsp,uchar MWheard,uchar number,uchar sdu,uchar state)
{register uchar i,w;
for(w=0;w<number;w++)
{
for(i=0;i<32;i++)
{
dispram[i]=wordsp[(MWheard+w)32+i];
if(i%2)
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从UP_Pullp的第UP_Pullheard个字向上拉出number个字/
//向上拉出
void UP_Pull_Word(uchar UP_Pullp[][32],uchar UP_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=0;k<15-j;k++)
{
dispram[k2]=dispram[(k+1)2];
dispram[k2+1]=dispram[(k+1)2+1];
}
dispram[30-2j]=UP_Pullp[UP_Pullheard+i][(15-j)2];
dispram[31-2j]=UP_Pullp[UP_Pullheard+i][(15-j)2+1];
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从UPp的第UPheard个字向上滚屏number个字/
//向上滚屏
void UP_Run_Word(uchar UPp[][32],uchar UPheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=0;k<15;k++)
{
dispram[k2]=dispram[(k+1)2];
dispram[k2+1]=dispram[(k+1)2+1];
}
dispram[30]=UPp[UPheard+i][j2];
dispram[31]=UPp[UPheard+i][j2+1];
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从Down_Pullp的第Down_Pullheard个字向下拉出number个字/
//向下拉出
void Down_Pull_Word(uchar Down_Pullp[][32],uchar Down_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=15;k>j;k--)
{
dispram[k2]=dispram[(k-1)2];
dispram[k2+1]=dispram[(k-1)2+1];
}
dispram[2j]=Down_Pullp[Down_Pullheard+i][2j];
dispram[2j+1]=Down_Pullp[Down_Pullheard+i][2j+1];
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从Downp的第UPheard个字向下滚屏number个字/
//向下滚屏
void Down_Run_Word(uchar Downp,uchar UPheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k;
for(i=0;i<number;i++)
{
for(j=0;j<16;j++)
{
for(k=15;k>0;k--)
{
dispram[k2]=dispram[(k-1)2];
dispram[k2+1]=dispram[(k-1)2+1];
}
dispram[0]=Downp[(UPheard+i)32+(15-j)2];
dispram[1]=Downp[(UPheard+i)32+(15-j)2+1];
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从LRp的第LRheard个字左移出显示number个字/
//用左移出显示
void L_Removeout_Word(uchar LRp,uchar LRheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<2;j++)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
dispram[l2]=dispram[l2]<<1|dispram[l2+1]>>7;
dispram[l2+1]=dispram[l2+1]<<1|LRp[(i+LRheard)32+l2+j]>>(7-k);
}
delay(sduSPEED);
}
delay(stateTIME);
}
}
/从L_Pullp的第L_Pullheard个字左拉出显示number个字/
//左拉出显示
void L_Pull_Word(uchar L_Pullp,uchar L_Pullheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=0;j<2;j++)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
if(j==0)
{
dispram[l2]=dispram[l2]<<1|dispram[l2+1]>>7;
dispram[l2+1]=(dispram[l2+1]&0xff<<(k+1))<<1|L_Pullp[(i+L_Pullheard)32+l2+1]&0xff>>(7-k);
}
else
{
dispram[l2]=(dispram[l2]&0xff<<(k+1))<<1|L_Pullp[(i+L_Pullheard)32+l2]&0xff>>(7-k);
dispram[l2+1]=L_Pullp[(i+L_Pullheard)32+l2+1];
}
}
delay(sduSPEED);
}
delay(stateTIME);
}
}
/卷帘出黑屏/
void M_Black(void)
{register uchar i;
for(i=0;i<32;i++)
{
dispram[i]=0x00;
if(i%2)
delay(5SPEED);
}
}
/从RRp的第RRheard个字右移出显示number个字/
//右移出显示
void R_Removeout_Word(uchar RRp,uchar RRheard,uchar number,uchar sdu,uchar state)
{register uchar i,j,k,l;
for(i=0;i<number;i++)
{
for(j=2;j>0;j--)
for(k=0;k<8;k++)
{
for(l=0;l<16;l++)
{
dispram[l2+1]=dispram[l2+1]>>1|dispram[l2]<<7;
dispram[l2]=dispram[l2]>>1|RRp[(i+RRheard)32+l2+j-1]<<(7-k);
}
delay(sduSPEED);
}
delay(stateTIME);
}
}
/随机跑动函数/
void radom_flash(uchar Radom_p,uchar Radom_heard,uchar number,uchar sdu,uchar state)
{
switch ((receive[1]&0x0f)+(receive[0]&0x70)/16)
{
case 0: Open_door(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//开门
case 1: Close_door(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//关门
case 2: Far_Away(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//分开
case 3: Close_To(Radom_p,Radom_heard,number,sdu,state);M_Black();break;//合拢
case 4: miqi_jump();
case 5: M_Words(Radom_p,Radom_heard,number,sdu,state);M_Black(); break;//卷帘
case 6: UP_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//上拉出
case 7: UP_Run_Word(Radom_p,Radom_heard,number,sdu,state);break;//上滚屏
case 8: Down_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//下拉出
case 9: Down_Run_Word(Radom_p,Radom_heard,number,sdu,state);break;
case 10: L_Removeout_Word(Radom_p,Radom_heard,number,sdu,state);break;//左滚屏
case 11: L_Pull_Word(Radom_p,Radom_heard,number,sdu,state);break;//左拉出
case 12: R_Removeout_Word(Radom_p,Radom_heard,number,sdu,state);break;//右滚屏
case 13: flash(Radom_p,Radom_heard,number,3,state);break;
case 14: flash_bai(Radom_p,Radom_heard,number,sdu,state);break;
}
}
程序和具体电路结合起来才能看出问题,有一个办法可以不用具体研究代码和电路:把你调试用的汉字点阵全部改为0XFF,看是否该汉字所在位置是否全部显示,然后把第一个字节改为0X00或0XEF,看对应显示是否正确,也可以再改其他字节的点阵。用这种方法可以找出问题所在!
第7-15行是汉字的下半部分,据此查看一下程序和电路。
以上就是关于求基于FPGA的LED点阵显示屏滚动的VHDL程序。注:1、要求用VHDL语言编写。2、程序主要是实现汉字左右移动。全部的内容,包括:求基于FPGA的LED点阵显示屏滚动的VHDL程序。注:1、要求用VHDL语言编写。2、程序主要是实现汉字左右移动。、单片机16*16LED点阵怎样让文字从上到下显示出来 求程序、51单片机Led点阵8*8显示一个字的程序是什么 请讲讲程序内容里的原理!谢谢等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)