void smg()
{
static uchar i=0;
c0=1;c1=1;c2=1;c3=1;
P1 = 0XFF;
switch(i)
{
case 0: c0=0;
break;
case 1: c1=0;
break;
case 2: c2=0;
break;
case 3: c3=0;
break;
}
P1 = dm[wm[i]];
i++;
if(i>3)
{
i=0;
}
}
void ledmode()
{
switch(mode)
{
case 0:led2=led3=0;
break;
case 1:led2=1;led3=0;
break;
case 2:led2=0;led3=1;
break;
case 3:led2=led3=1;
break;
}
}
void key()
{
static uchar num;
delay3ms();
button=1;
switch(num)
{
case 0: if(!button)
{
num=1;
}
break;
case 1: if(!button)
{
if(mode<3)
{
mode++;
}
else
{
mode=0;
}
num=2;
}
else
{
num=0;
}
break;
case 2: if(button)num=3;
break;
case 3: if(button)num=0;
break;
}
}
void timeinit()
{
TMOD=0x15; //Set the T0T1 control word
TH0=0x00;
TL0=0x00;
TH1=0xfC;
TL1=0x18;
ET0=1; //Timer 0 interrupt is allowed
ET1=1;
TR0=1; //Start T0 count
TR1=1; // and start T1 counting
EA=1; //CPU switched off
}
{
static uchar i=0;
c0=1;c1=1;c2=1;c3=1;
P1 = 0XFF;
switch(i)
{
case 0: c0=0;
break;
case 1: c1=0;
break;
case 2: c2=0;
break;
case 3: c3=0;
break;
}
P1 = dm[wm[i]];
i++;
if(i>3)
{
i=0;
}
}
void ledmode()
{
switch(mode)
{
case 0:led2=led3=0;
break;
case 1:led2=1;led3=0;
break;
case 2:led2=0;led3=1;
break;
case 3:led2=led3=1;
break;
}
}
void key()
{
static uchar num;
delay3ms();
button=1;
switch(num)
{
case 0: if(!button)
{
num=1;
}
break;
case 1: if(!button)
{
if(mode<3)
{
mode++;
}
else
{
mode=0;
}
num=2;
}
else
{
num=0;
}
break;
case 2: if(button)num=3;
break;
case 3: if(button)num=0;
break;
}
}
void timeinit()
{
TMOD=0x15; //Set the T0T1 control word
TH0=0x00;
TL0=0x00;
TH1=0xfC;
TL1=0x18;
ET0=1; //Timer 0 interrupt is allowed
ET1=1;
TR0=1; //Start T0 count
TR1=1; // and start T1 counting
EA=1; //CPU switched off
}