#include <STC89C5xRC.H>
#include "intrins.h"
sbit RCK=P3^5; //RCLK
sbit SCK=P3^6; //SRCLK
sbit SER=P3^4; //SER
sbit k1=P3^1;
typedef unsigned int u16;
typedef unsigned char u8;
unsigned char code Animation[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0xFF,
0xA8,0xA8,0xA8,0xFF,0x00,0x00,0x1E,0x32,
0x4A,0x8E,0x00,0x00,0x7E,0x52,0x52,0x7E,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char code day[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x22,0x46,0x8A,0x92,0x62,0x00,0x00,0xFE,
0x82,0x82,0x82,0xFE,0x00,0x00,0x22,0x46,
0x8A,0x92,0x62,0x00,0x00,0x22,0x46,0x8A,
0x92,0x62,0x00,0x00,0x00,0x00,0x00,0x00
};
void delay(unsigned int xms)
{
unsigned char i;
while(xms--)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
void _74H595(u8 bate)
{
u8 i;
RCK=0;
SCK=0;
for(i=0;i<8;i++)
{
SER=bate>>7;
bate=bate<<1;
SCK=1;
SCK=0;
}
RCK=1;
RCK=0;
}
void worite(u8 Colum,Data)
{
_74H595(Data);
P0=~(0x80>>Colum);
delay(1);
P0=0xFF;
}
void main()
{
u8 i,offset=0,count=0;
u8 k=0;
while(1)
{
if(k1==0)
{
delay(20);
while(!k1);
k=!k;
}
if(k==0)
{
for(i=0;i<20;i++)
{
worite(i,Animation[i+offset]);
if(k1==0)break;
}
count++;
if(count>10)
{
count=0;
offset++;
if(offset>30)
{
offset=0;
}
}
}
else if(k==1)
{
for(i=0;i<20;i++)
{
worite(i,day[i+offset]);
if(k1==0)break;
}
count++;
if(count>10)
{
count=0;
offset++;
if(offset>30)
{
offset=0;
}
}
}
}
}
|