我是自学单片机,C语言写过一个,指针学过一节课。。
现在做个16*16点阵。。能显示多个汉字,但是就是不会滚动显示,求那位老师,能帮我修改一个能滚动流动的程序。。谢谢
写得不好的地方,请指点,是我学习进步重要一步。。
#include <reg52.h>
#define int8 unsigned char
#define int16 unsigned int
sbit led=P0^0;
int8 j=0;
int16 q;
int16 temp=0;
void delay(int16 T)
{
while(T--);
}
int8 code tab[][32]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
/*-- 文字: 你 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x40,0xF0,0x2C,0x43,0x20,0x98,0x0F,0x08,0xE8,0x08,0x88,0x28,0x18,0x08,0x00,
0x00,0x00,0x7F,0x00,0x10,0x0C,0x03,0x21,0x40,0x3F,0x00,0x00,0x03,0x1C,0x08,0x00,
/*-- 文字: 若 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x44,0x44,0x44,0x44,0xDF,0x64,0x54,0x44,0x44,0x5F,0x44,0x44,0x44,0x44,0x00,
0x10,0x08,0x04,0x02,0x7F,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0x00,
/*-- 文字: 安 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x90,0x8C,0x84,0x84,0xF4,0x85,0x86,0x84,0x84,0x84,0x84,0x94,0x8C,0x84,0x00,
0x80,0x80,0x80,0x40,0x47,0x28,0x28,0x10,0x28,0x24,0x43,0xC0,0x40,0x00,0x00,0x00,
/*-- 文字: 好 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0xF0,0x1F,0x10,0xF0,0x80,0x82,0x82,0x82,0xF2,0x8A,0x86,0x82,0x80,0x00,
0x80,0x43,0x22,0x14,0x0C,0x73,0x20,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: , --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x58,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 便 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x20,0xF0,0x1C,0x07,0xFA,0x2A,0x2A,0x2A,0xFE,0x2A,0x2A,0x2A,0xFA,0x02,0x00,
0x00,0x00,0xFF,0x00,0x80,0x83,0x45,0x29,0x19,0x17,0x21,0x21,0x41,0xC1,0x40,0x00,
/*-- 文字: 是 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x80,0x80,0x80,0x80,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x80,0x80,0x80,0x00,
0x00,0x40,0x20,0x10,0x0E,0x10,0x20,0x3F,0x44,0x44,0x44,0x44,0x44,0x40,0x40,0x00,
/*-- 文字: 晴 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0xFC,0x44,0x44,0xFC,0x20,0x22,0xAA,0xAA,0xBF,0xAA,0xAA,0xAA,0x22,0x20,0x00,
0x00,0x0F,0x04,0x04,0x0F,0x00,0x00,0xFF,0x0A,0x0A,0x4A,0x8A,0x7F,0x00,0x00,0x00,
/*-- 文字: 天 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x40,0x42,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x40,0x00,
0x00,0x80,0x40,0x20,0x10,0x08,0x06,0x01,0x02,0x04,0x08,0x10,0x30,0x60,0x20,0x00,
/*-- 调入了一幅图像:这是您新建的图像 --*/
/*-- 宽度x高度=16x16 --*/
0x00,0x20,0x10,0x10,0x10,0x10,0x20,0x00,0x00,0x20,0x10,0x10,0x10,0x10,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x10,0x28,0x28,0x29,0x28,0x28,0x10,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
int8 code tab1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void cxh()
{
P0 = 0xff;
P1 = 0x00;
P2 = 0xff;
P3 = 0x00;
}
void main()
{
int8 i;
TMOD|=0X01;
TH0 =0XB0;
TL0=0X00;
EA=1;
ET0=1;
TR0=1;
while(1)
{
cxh();
for(i=0;i<8;i++)
{
P1=tab[j] ; //左上角
P3=tab[j][16+i];//左下角
P0=tab1;//列选
delay(100);
cxh();
}
cxh();
for(i=0;i<8;i++)
{
P1=tab[j][8+i] ;//右上角
P3=tab[j][24+i];//右下角
P2=tab1;//列选
delay(100);
cxh();
}
}
}
void int1_yy(void) interrupt 1
{
TH0 =0XB0;
TL0=0X00;
q++;
if(q==30)//3秒显示下一个字
{
q=0;
j++;
}
if(j==12)//
{
j=0;
}
} |