江湖救急!新手做了个16*16点阵,程序有个问题想请教好心人
时间:10-02
整理:3721RD
点击:
16*16点阵,现象是字移动到一半的点阵就消失了,到另一半点阵又出现了,而不是走完整个点阵?
还有点阵的移动函数怎么理解?希望能举个简单例子,然后详细地讲解,谢谢!
对了,k是第几个字,2个138和2个595
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit r=P2^0;
sbit clk=P2^1;
sbit stb=P2^2;
uchar code table[3][32]={
{0x04,0x80,0x04,0x80,0x08,0x80,0x08,0x80,
0x10,0x84,0x20,0x84,0x40,0x7C,0x80,0x00,
0x00,0x00,0x3F,0xF0,0x02,0x00,0x02,0x00,
0x02,0x00,0x02,0x00,0x7F,0xFC,0x04,0x80,}, //无
{0x40,0x44,0xFC,0x48,0x40,0x30,0x00,0x22,
0x1C,0x52,0xE0,0x8A,0x43,0x06,0x00,0x02,
0x10,0x50,0x10,0x48,0x20,0x40,0x24,0x5C, // 线
0x45,0xE0,0xF8,0x40,0x10,0x5E,0x23,0xE0,},
{0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,
0x21,0x0A,0x01,0x02,0x01,0x02,0x00,0xFE,
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,
0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,}
};
void writebyte(uchar dat)
{
uchar i;
for(i=0;i<8;i++)
{
dat=dat>>1;
r=CY;
clk=0;
clk=1;
}
}
void senddata()
{
stb=0;
stb=1;
}
void main()
{
uchar num,i,j,k;
while(1)
{
for(k=1;k<3;k++)
{
for(i=0;i<16;i++) //移动一个字
{
for(j=0;j<20;j++)
{
for(num=0;num<16;num++) //移动一位
{
if(i<8)
{
writebyte(((table[k][2*num]>>(8-i))|(table[k][2*num+1]<<i)));
writebyte(((table[k-1][2*num+1]>>(8-i))|(table[k-1][2*num]<<i)));
senddata();
}
else
{
writebyte(((table[k][2*num+1]>>(16-i))|(table[k][2*num]<<(i-8))));
writebyte(((table[k-1][2*num]>>(16-i))|(table[k-1][2*num+1]<<(i-8))));
senddata();
}
P1=num;
}
}
}
}
}
}
还有点阵的移动函数怎么理解?希望能举个简单例子,然后详细地讲解,谢谢!
对了,k是第几个字,2个138和2个595
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit r=P2^0;
sbit clk=P2^1;
sbit stb=P2^2;
uchar code table[3][32]={
{0x04,0x80,0x04,0x80,0x08,0x80,0x08,0x80,
0x10,0x84,0x20,0x84,0x40,0x7C,0x80,0x00,
0x00,0x00,0x3F,0xF0,0x02,0x00,0x02,0x00,
0x02,0x00,0x02,0x00,0x7F,0xFC,0x04,0x80,}, //无
{0x40,0x44,0xFC,0x48,0x40,0x30,0x00,0x22,
0x1C,0x52,0xE0,0x8A,0x43,0x06,0x00,0x02,
0x10,0x50,0x10,0x48,0x20,0x40,0x24,0x5C, // 线
0x45,0xE0,0xF8,0x40,0x10,0x5E,0x23,0xE0,},
{0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,
0x21,0x0A,0x01,0x02,0x01,0x02,0x00,0xFE,
0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,
0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,}
};
void writebyte(uchar dat)
{
uchar i;
for(i=0;i<8;i++)
{
dat=dat>>1;
r=CY;
clk=0;
clk=1;
}
}
void senddata()
{
stb=0;
stb=1;
}
void main()
{
uchar num,i,j,k;
while(1)
{
for(k=1;k<3;k++)
{
for(i=0;i<16;i++) //移动一个字
{
for(j=0;j<20;j++)
{
for(num=0;num<16;num++) //移动一位
{
if(i<8)
{
writebyte(((table[k][2*num]>>(8-i))|(table[k][2*num+1]<<i)));
writebyte(((table[k-1][2*num+1]>>(8-i))|(table[k-1][2*num]<<i)));
senddata();
}
else
{
writebyte(((table[k][2*num+1]>>(16-i))|(table[k][2*num]<<(i-8))));
writebyte(((table[k-1][2*num]>>(16-i))|(table[k-1][2*num+1]<<(i-8))));
senddata();
}
P1=num;
}
}
}
}
}
}