#include"config.h"
#include"zimo.c"
static U8 mode=0,mode1=0,Mode=0,count=0,countmode=0;
static U8 Flag1ms=0,flag=0,stop=0;
static U8 x1,y1,x2,y2;
U16 i;
U8 DispBuff[1][32]; //点亮擦除的缓冲区
U8 code DispBuff1[5][32]=
{0xF8,0x1F,0xE7,0xE7,0xDF,0xFB,0xBF,0xFD,0x7F,0xFE,0x5D,0xBA,0x63,0xC6,0x7F,0xFE,
0x7F,0xFE,0x7F,0xFE,0x7C,0x3E,0xBB,0xDD,0xDF,0xFB,0xE7,0xE7,0xF8,0x0F,0xFF,0xFF,/*"未命名文件",0*/
0xF8,0x1F,0xE7,0xE7,0xDF,0xFB,0xBF,0xFD,0x7F,0xFE,0x5D,0xBA,0x63,0xC6,0x77,0xEE,
0x7F,0xFE,0x7F,0xFE,0x7C,0x3E,0xBB,0xDD,0xDF,0xFB,0xE7,0xE7,0xF8,0x0F,0xFF,0xFF,/*"未命名文件",0*/
0xF8,0x1F,0xE7,0xE7,0xDF,0xFB,0xBF,0xFD,0x7F,0xFE,0x5D,0xBA,0x63,0xC6,0x7F,0xFE,
0x77,0xEE,0x7F,0xFE,0x7C,0x3E,0xBB,0xDD,0xDF,0xFB,0xE7,0xE7,0xF8,0x0F,0xFF,0xFF,/*"未命名文件",0*/
0xF8,0x1F,0xE7,0xE7,0xDF,0xFB,0xBF,0xFD,0x7F,0xFE,0x5D,0xBA,0x63,0xC6,0x7F,0xFE,
0x7F,0xFE,0x77,0xEE,0x7C,0x3E,0xBB,0xDD,0xDF,0xFB,0xE7,0xE7,0xF8,0x0F,0xFF,0xFF,/*"未命名文件",0*/
0xF8,0x1F,0xE7,0xE7,0xDF,0xFB,0xBF,0xFD,0x63,0xC6,0x5D,0xBA,0x7F,0xFE,0x7F,0xFE,
0x7F,0xFE,0x7F,0xFE,0x77,0xEE,0xBB,0xDD,0xDC,0x3B,0xE7,0xE7,0xF8,0x0F,0xFF,0xFF};/*"未命名文件",0*/
U8 idata DispBuff2[1][32]; //上移的缓冲区
U8 idata DispBuff3[1][32]; //下移的缓冲区
U8 idata DispBuff4[1][32]; //左移的缓冲区
U8 idata DispBuff5[1][32]; //右移的缓冲区
void main()
{
TMOD = 0x01; //设置T0工作方式1
TH0 = THCO;
TL0 = TLCO;
EA = 1; //开总中断
ET0 = 1; //开T0中断
TR0 = 1; //启动T0
P3M0=0X00; //设置P33为高阻态输入
P3M1=0X08;
LED_passUp();
LED_passDown();
LED_passLeft();
LED_passRight();
LED_Clear();
while(1)
{
if(Flag1ms==1)
LED_modeSwitch();
}
}
void Timer0(void) interrupt 1
{
TH0=THCO;
TL0=TLCO;
count++;
if(count>=80)
{
Flag1ms=1;
count=0;
countmode++;
if(countmode>=10)
{
countmode=0;
Mode++;
if(Mode==5)
{
delay(1000);
Mode=0;
}
}
if(keymode==0 || keydraw==0 || keyerase==0 || keyopposite==0)
{
LED_getKey();
}
}
}
void LED_Write595(U16 var)
{
U8 i;
LCK = 0;
for(i = 0;i < 16;i++)
{
SCLK = 0;
SDI = var & 0x0001;
SCLK = 1;
var = var >> 1;
}
LCK = 1;
}
void LED_SelectLine(U8 line)
{
ADDA = line & 0x01;
ADDB = line & 0x02;
ADDC = line & 0x04; //138译码器的三个输入端
ADDD = line & 0x08; //片选
}
void LED_Clear(void)
{
U8 i;
for(i=0;i<16;i++)
{
DispBuff[0][2*i]=0xff;
DispBuff[0][2*i+1]=0xff;
}
}
void LED_Opposite(void)
{
U8 i,dat1,dat2;
if(mode==ModeDraw || mode==ModeErase)
{
for(i=0;i<16;i++)
{
dat1=DispBuff[0][2*i];
dat2=DispBuff[0][2*i+1];
dat1=~dat1;
dat2=~dat2;
DispBuff[0][2*i]=dat1;
DispBuff[0][2*i+1]=dat2;
}
}
}
void LED_DisplayStatic(U8 j)
{
U8 i;
U16 dat;
for(i=0;i<16;i++)
{
dat=DispBuff1[j][i*2]; //将第八位的数据传给dat
dat=dat<<8; //dat把得到的数据送至高八位
dat+=DispBuff1[j][i*2+1];
LED_Write595(0xffff);
LED_SelectLine(i);
LED_Write595(dat);
}
LED_Write595(0xffff);
}
void LED_DisplayUp(void)
{
U8 i;
U16 dat;
for(i=0;i<16;i++)
{
dat=DispBuff2[0][i*2]; //将第八位的数据传给dat
dat=dat<<8; //dat把得到的数据送至高八位
dat+=DispBuff2[0][i*2+1];
LED_Write595(0xffff);
LED_SelectLine(i);
LED_Write595(dat);
}
LED_Write595(0xffff);
delay(1); //减慢移动速度
}
void LED_DisplayDown(void)
{
U8 i;
U16 dat;
for(i=0;i<16;i++)
{
dat=DispBuff3[0][i*2]; //将第八位的数据传给dat
dat=dat<<8; //dat把得到的数据送至高八位
dat+=DispBuff3[0][i*2+1];
LED_Write595(0xffff);
LED_SelectLine(i);
LED_Write595(dat);
}
LED_Write595(0xffff);
delay(1); //减慢移动速度
}
void LED_DisplayLeft(void)
{
U8 i;
U16 dat;
for(i=0;i<16;i++)
{
dat=DispBuff4[0][i*2]; //将第八位的数据传给dat
dat=dat<<8; //dat把得到的数据送至高八位
dat+=DispBuff4[0][i*2+1];
LED_Write595(0xffff);
LED_SelectLine(i);
LED_Write595(dat);
}
LED_Write595(0xffff);
delay(1); //减慢移动速度
}
void LED_DisplayRight(void)
{
U8 i;
U16 dat;
for(i=0;i<16;i++)
{
dat=DispBuff5[0][i*2]; //将第八位的数据传给dat
dat=dat<<8; //dat把得到的数据送至高八位
dat+=DispBuff5[0][i*2+1];
LED_Write595(0xffff);
LED_SelectLine(i);
LED_Write595(dat);
}
LED_Write595(0xffff);
delay(1); //减慢移动速度
}
void LED_DisplayDraw(U8 x,U8 y,U8 onoff)
{
U8 i,Dat,Mid;
Dat=DispBuff[0][2*y+x/8]; //将缓冲区数据送给Dat
Mid=0x01;
for(i=0;i<(7-(x%8));i++)
{
Mid=Mid << 1;
}
if(onoff==1)
Dat = Dat | Mid;
else
Dat = Dat & (~Mid);
DispBuff[0][2*y+x/8]=Dat;
}
void LED_Display(void)
{
U8 i;
U16 dat;
for(i=0;i<16;i++)
{
dat=DispBuff[0][2*i]; //将第八位的数据传给dat
dat=dat<<8; //dat把得到的数据送至高八位
dat+=DispBuff[0][2*i+1];
LED_Write595(0xffff);
LED_SelectLine(i);
LED_Write595(dat);
}
LED_Write595(0xffff);
}
void LED_passUp(void)
{
U8 i;
for(i=0;i<16;i++)
{
DispBuff2[0][i*2] = zimoUp[0][i*2];
DispBuff2[0][i*2+1] = zimoUp[0][i*2+1];
}
}
void LED_passDown(void)
{
U8 i;
for(i=0;i<16;i++)
{
DispBuff3[0][i*2] = zimoDown[0][i*2];
DispBuff3[0][i*2+1] = zimoDown[0][i*2+1];
}
}
void LED_passLeft(void)
{
U8 i;
for(i=0;i<16;i++)
{
DispBuff4[0][i*2] = zimoLeft[0][i*2];
DispBuff4[0][i*2+1] = zimoLeft[0][i*2+1];
}
}
void LED_passRight(void)
{
U8 i;
for(i=0;i<16;i++)
{
DispBuff5[0][i*2] = zimoRight[0][i*2];
DispBuff5[0][i*2+1] = zimoRight[0][i*2+1];
}
}
void LED_moveUp(U8 size)
{
U8 i;
static U8 j=0,k=0;
for(i=0;i<16;i++)
{
DispBuff2[0][i*2]=DispBuff2[0][(i+1)*2];
DispBuff2[0][i*2+1]=DispBuff2[0][(i+1)*2+1];
if(i==15)
{
j++;
if(j==16)
{
j=0;
k++;
}
}
DispBuff2[0][30]=zimoUp[k+1][(j-1)*2];
DispBuff2[0][31]=zimoUp[k+1][(j-1)*2+1];
if(k==size-1)
{
delay(2000);
k=0;
LED_passUp();
}
}
}
void LED_moveDown(U8 size)
{
U8 i;
static U8 j=0,k=0;
for(i=0;i<16;i++)
{
DispBuff3[0][30-i*2]=DispBuff3[0][30-(i+1)*2];
DispBuff3[0][31-i*2]=DispBuff3[0][31-(i+1)*2];
if(i==0)
{
j++;
if(j==16)
{
j=0;
k++;
}
}
DispBuff3[0][0]=zimoDown[k+1][30-j*2];
DispBuff3[0][1]=zimoDown[k+1][31-j*2];
if(k==size-1)
{
delay(2000);
k=0;
LED_passDown();
}
}
}
void LED_moveLeft(U8 size)
{
static U8 b=0,flag=0,w=0;
U8 i,dat;
for(i =0;i<16;i++)
{
dat= zimoLeft[w+1][2*i+(flag/8)]; //取下一个字模左半边
dat= dat<<b; //左移b位
DispBuff4[0][2*i]= DispBuff4[0][2*i]<<1; //缓冲区左半边左移一位
if(DispBuff4[0][2*i+1]&0x80) //判断缓冲区右半边最高为是否为灭
{
DispBuff4[0][2*i]= DispBuff4[0][2*i]|0x01; //将缓冲区左半边最低位熄灭
}
DispBuff4[0][2*i+1]= DispBuff4[0][2*i+1]<<1; //缓冲区右半边左移一位
if(dat&0x80) //判断dat最高位是否为灭
{
DispBuff4[0][2*i+1]= DispBuff4[0][2*i+1] |0x01; //将缓冲区右半边最低位熄灭
}
}
flag++;
b++;
if(flag==16)
{
flag=0;
w++;
}
if(b==8)b=0;
if(w== size-1)
{
delay(2000);
w=0;
LED_passLeft();
}
}
void LED_moveRight(U8 size)
{
static U8 b=0,flag=0,w=0;
U8 i,dat;
for(i=0;i<16;i++)
{
dat= zimoRight[w+1][2*i+1-(flag/8)]; //取下一个字模的右半边
dat= dat>>b; //右移b位
DispBuff5[0][2*i+1]= DispBuff5[0][2*i+1]>>1; //缓冲区的右半边右移一位
if(DispBuff5[0][2*i]&0x01) //判断缓冲区左半边最低位是否为灭
{
DispBuff5[0][2*i+1]= DispBuff5[0][2*i+1]|0x80; //将缓冲区右半边最高位熄灭
}
DispBuff5[0][2*i]= DispBuff5[0][2*i]>>1; //缓冲区的左半边右移一位
if(d