51单片机4个74hc595驱动16x16点阵。程序加仿真成功。但是想改成8个74hc595,驱动32X32的点阵怎么改程序?
改了好久都改不对?求大哥大姐指导一下。
我的程序:
4个74hc595驱动16x16的。
#include<reg51.h>
#define uchar unsigned char
sbit si=P2^0; //74HC595串行数据段
sbit sck=P2^1; //74HC595移位时钟端
sbit rck=P2^2; //74HC595锁存端
uchar i,j,k,zb;
uchar xsz[32],xsz1[32] ;
uchar code smsg[8] ={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
uchar code wz[][32]={
/*-- 文字: 我 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xDF,0xFD,0x8F,0xF5,0xE1,0xED,0xEF,0xED,0xEF,0xFD,0x00,0x80,0xEF,0xFD,0xEF,0xDD,
0xAF,0xDD,0xCF,0xED,0xE7,0xF3,0xE9,0xBB,0xEF,0xB5,0xEF,0xAE,0x2B,0x9F,0xF7,0xBF,
/*-- 文字: 爱 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xEF,0x7F,0xC0,0x81,0xF7,0xBB,0xF7,0x77,0xFB,0x01,0x80,0xBD,0xBF,0xBE,0xDF,
0x01,0xE0,0xDF,0xFF,0x1F,0xF0,0xAF,0xF7,0x77,0xFB,0xFB,0xFC,0x3D,0xF3,0xC7,0x8F,
/*-- 文字: 单 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xF7,0xF7,0xEF,0xFB,0xDF,0xFD,0x03,0xE0,0x7B,0xEF,0x7B,0xEF,0x03,0xE0,0x7B,0xEF,
0x7B,0xEF,0x03,0xE0,0x7F,0xFF,0x7F,0xFF,0x00,0x80,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,
/*-- 文字: 片 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xFF,0xFD,0xF7,0xFD,0xF7,0xFD,0xF7,0xFD,0xF7,0xFD,0x07,0xC0,0xF7,0xFF,0xF7,0xFF,
0xF7,0xFF,0x07,0xF8,0xF7,0xFB,0xF7,0xFB,0xF7,0xFB,0xFB,0xFB,0xFB,0xFB,0xFD,0xFB,
/*-- 文字: 机 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0xF7,0xFF,0x77,0xF0,0x77,0xF7,0x77,0xF7,0x40,0xF7,0x77,0xF7,0x73,0xF7,0x63,0xF7,
0x55,0xF7,0x55,0xF7,0x76,0xF7,0x77,0xB7,0x77,0xB7,0xB7,0xB7,0xB7,0x8F,0xD7,0xFF,
0xE7,0xE7,0xC3,0xC3,0x81,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,
0x03,0xC0,0x07,0xE0,0x07,0xE0,0x0F,0xF0,0x1F,0xF8,0x3F,0xFC,0x3F,0xFC,0x7F,0xFE, /*"心",5*/
};
void ys (uchar a)
{
uchar b,c;
for (b=a;b>0;b--)
for (c=110;c>0;c--);
}
void fs(uchar a)
{
uchar b;
sck=0;
rck=0;
for (b=8;b>0;b--)
{
a=a<<1; //左移一位
si=CY;
sck=1;
sck=0;
}
}
void xs()
{
for (i=0,j=0;i<16;i++) //扫描行,16行循环16次
{
if (i<8)
{
fs(smsg[j]);
fs(0x00);
}
else
{
fs(0x00);
fs(smsg[j]);
}
j++;
if(j==8)
j=0;
fs(xsz[2*i+1]);
fs(xsz[2*i]);
rck=1;
ys(3);
}
}
void co(uchar *p,uchar *p1)
{
uchar a;
for (a=0;a<16;a++)
{
p[a*2]=p1[a*2];
p[a*2+1]=p1[a*2+1];
}
}
void shy(uchar e, uchar g,uchar *p1)
{
uchar a,b,c,d=0,f=31;
for (a=0;a<16;a++)
{
if(g==1)
{
for (b=0;b<30;b++)
xsz[b]=xsz[b+2];
if(p1==0)
{
xsz[30]=0xff;
xsz[31]=0xff;
}
else
{
xsz[30]=p1[d++];
xsz[31]=p1[d++];
}
for (c=e;c>0;c--)
xs();
}
else
{
for (b=29;b>0;b--)
xsz[b+2]=xsz[b];
xsz[2]=xsz[0];
if(p1==0)
{
xsz[1]=0xff;
xsz[0]=0xff;
}
else
{
xsz[1]=p1[f--];
xsz[0]=p1[f--];
}
for (c=e;c>0;c--)
xs();
}
}
}
void zyy(uchar a,uchar b,uchar *p)
{
uchar i,j,k,c;
for (i=0;i<16;i++)
{
if(p==0)
{
xsz1[2*i]=0xff;
xsz1[2*i+1]=0xff;
}
else
{
xsz1[2*i]=p[2*i];
xsz1[2*i+1]=p[2*i+1];
}
}
if(b==1)
for (k=0;k<16;k++)
{
for(i=0;i<16;i++)
{
xsz[i*2+1]=xsz[i*2+1]<<1;
xsz[i*2]=xsz[i*2]<<1;
if (CY==1)
xsz[i*2+1]=xsz[i*2+1]|0x01;
xsz1[i*2+1]=xsz1[i*2+1]<<1;
if (CY==1)
xsz[i*2]=xsz[i*2]|0x01;
xsz1[i*2]=xsz1[i*2]<<1;
if (CY==1)
xsz1[i*2+1]=xsz1[i*2+1]|0x01;
}
for (j=a;j>0;j--)
xs();
}
else
{
for (k=0;k<16;k++)
{
for(i=0;i<16;i++)
{
xsz[i*2]=xsz[i*2]>>1;
c=xsz[i*2+1]&0x01;
xsz[i*2+1]=xsz[i*2+1]>>1;
if (c)
xsz[i*2]=xsz[i*2]|0x80;
c=xsz1[i*2]&0x01;
xsz1[i*2]=xsz1[i*2]>>1;
if (c)
xsz[i*2+1]=xsz[i*2+1]|0x80;
c=xsz1[i*2+1]&0x01;
xsz1[i*2+1]=xsz1[i*2+1]>>1;
if (c)
xsz1[i*2]=xsz1[i*2]|0x80;
}
for (j=a;j>0;j--)
xs();
}
}
}
void main ()
{
while (1)
{
co(xsz,wz[5]);
shy(10,1,wz[0]);
shy(10,1,wz[1]);
shy(10,0,wz[2]);
shy(10,1,wz[3]);
shy(10,0,wz[4]);
shy(10,1,0);
zyy(10,0,wz[0]);
zyy(10,1,wz[1]);
zyy(10,0,wz[2]);
zyy(10,1,wz[3]);
zyy(10,0,wz[4]);
zyy(10,1,0);
co(xsz,wz[5]);
}
}
|