#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar C_cross[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar R_cross[10][8]={
{0x00,0x42,0x46,0x4a,0x52,0x62,0x42,0x00},//"Z"
{0x00,0x40,0x40,0x7e,0x40,0x40,0x00,0x00},//"T"
{0x7e,0x20,0x10,0x08,0x10,0x20,0x7e,0x00},//"M"
{0x00,0x42,0x42,0x7e,0x42,0x42,0x00,0x00},//"I"
{0x30,0x48,0x44,0x32,0x44,0x48,0x30,0x00},//"LOVE"
{0x00,0x80,0x40,0x3e,0x40,0x80,0x00,0x00}, //"Y"
{0x30,0x28,0x14,0x38,0x38,0x14,0x28,0x30},//"LOVE,LOVE"
{0x00,0x80,0x40,0x3e,0x40,0x80,0x00,0x00}, //"Y"
{0x00,0x20,0x20,0x1e,0x10,0x20,0x20,0x00}, //"R"
{0x00,0x7e,0x42,0x42,0x42,0x24,0x18,0x00} //"D"
};
uchar offset;
uchar n;
void Delayms(uchar mt)
{
uchar t;
for(mt;mt>0;mt--)
for(t=110;t>0;t--);
}
void main(void)
{
uchar i;
uchar *p;
n=0;
TMOD=0x01;
TH0=0xfc;
TL0=0x18;
ET0=1;
EA=1;
TR0=1;
p=&R_cross[0][0];
while(1)
{
for(i=0;i<8;i++)
{
Delayms(10000);
P0=*(p+offset); //这里如果换成a[][]的形式是什么?
P2=C_cross[i];
p++;
if(p>&R_cross[0][7])
p=&R_cross[0][0];
}
}
}
void
timer0() interrupt 1 using 3
{
TF0=0;
TH0=0xfc;
TL0=0xe18;
if(n<200)
{
n++;
}
else
{
n=0;
offset+=1;
if(offset>72)
offset=0;
}
P0=*(p+offset); //这里如果换成a[][]的形式是什么?
求给出详细注释
P0=*(p+offset); //这里如果换成a[][]的形式是什么?
P0 = R_cross[offset/8][offset%8];
//offset是整个二维数组的指针 -- 这个解析不大合适,下面的解析可能合适点。
//offset是一个位移量,加上数组起始地址,即可定位具体数组位置。
//当offset=0,p+offset指向a[0][0],当offset=7,a=[0][7],当offset=8,a=[1][0]
一周热门 更多>