/****************MCU??SST89C516RD2??*******************/
/****************???????32MHz??*******************/
#include <SST89X5XXRD2.H>
#define uchar unsigned char
#define uint unsigned int
sbit ILE=P2^0; //DAC0832???
sbit CG=P3^2; //??????(??0)
sbit keyS=P2^1;
sbit keyF=P2^2;
//?????
uchar code TableX[112]={0XF8,0XF8,0XFA,0XFC,0XFE,0XFE,0XFC,0XFA,0XF8,
0XFD,0XFB,0XF8,0XF3,
0XED,0XEB,0XEA,0XE8,0XE6,
0XE6,0XDD,0XD4,0XCA,
0XBE,0XBD,0XBC,0XBB,0XBA,
0XB3,0XA6,0X99,0X8C,
0X7E,0X7E,0X7E,0X7E,0X7E,
0X72,0X65,0X58,0X4B,
0X40,0X41,0X42,0X43,0X44,
0X34,0X2A,0X21,0X18,
0X11,0X13,0X14,0X16,0X18,
0X0B,0X06,0X03,0X01,
0X00,0X02,0X04,0X06,0X08,
0X01,0X03,0X06,0X0B,
0X11,0X13,0X14,0X16,0X18,
0X18,0X21,0X2A,0X34,
0X40,0X41,0X42,0X43,0X44,
0X4B,0X58,0X65,0X72,
0X7E,0X7E,0X7E,0X7E,0X7E,
0X8C,0X99,0XA6,0XB3,
0XBE,0XBD,0XBC,0XBB,0XBA,
0XCA,0XD4,0XDD,0XE6,
0XED,0XEB,0XEA,0XE8,0XE6,
0XF3,0XF8,0XFB,0XFD
};
//?????
uchar code TableY[112]={0X7E,0X7E,0X7E,0X7E,0X7E,0X7E,0X7E,0X7E,0X7E,
0X8C,0X99,0XA6,0XB3,
0XBE,0XBD,0XBC,0XBB,0XBA,
0XCA,0XD4,0XDD,0XE6,
0XED,0XEB,0XEA,0XE8,0XE6,
0XF3,0XF8,0XFB,0XFD,
0XFE,0XFC,0XFA,0XF8,0XF6,
0XFD,0XFB,0XF8,0XF3,
0XED,0XEB,0XEA,0XE8,0XE6,
0XE6,0XDD,0XD4,0XCA,
0XBE,0XBD,0XBC,0XBB,0XBA,
0XB3,0XA6,0X99,0X8C,
0X7E,0X7E,0X7E,0X7E,0X7E,
0X72,0X65,0X58,0X4B,
0X40,0X41,0X42,0X43,0X44,
0X34,0X2A,0X21,0X18,
0X11,0X13,0X14,0X16,0X18,
0X0B,0X06,0X03,0X01,
0X00,0X02,0X04,0X06,0X08,
0X01,0X03,0X06,0X0B,
0X11,0X13,0X14,0X16,0X18,
0X18,0X21,0X2A,0X34,
0X40,0X41,0X42,0X43,0X44,
0X4B,0X58,0X65,0X72
};
//????????
float code TimeX[60]={0.0,0.1045,0.2079,0.3090,0.4067,0.5000,0.5878,0.6691,0.7431,0.8090,0.8660,0.9135,0.9511,0.9781,0.9945,1.0,
0.9945,0.9781,0.9511,0.9135,0.8660,0.8090,0.7431,0.6691,0.5878,0.5000,0.4067,0.3090,0.2079,0.1045,0.0,
-0.1045,-0.2079,-0.3090,-0.4067,-0.5000,-0.5878,-0.6691,-0.7431,-0.8090,-0.8660,-0.9135,-0.9511,-0.9781,-0.9945,-1.0,
-0.9945,-0.9781,-0.9511,-0.9135,-0.8660,-0.8090,-0.7431,-0.6691,-0.5878,-0.5000,-0.4067,-0.3090,-0.2079,-0.1045
};
//????????
float code TimeY[60]={1.0,0.9945,0.9781,0.9511,0.9135,0.8660,0.8090,0.7431,0.6691,0.5878,0.5000,0.4067,0.3090,0.2079,0.1045,0.0,
-0.1045,-0.2079,-0.3090,-0.4067,-0.5000,-0.5878,-0.6691,-0.7431,-0.8090,-0.8660,-0.9135,-0.9511,-0.9781,-0.9945,-1.0,
-0.9945,-0.9781,-0.9511,-0.9135,-0.8660,-0.8090,-0.7431,-0.6691,-0.5878,-0.5000,-0.4067,-0.3090,-0.2079,-0.1045,0.0,
0.1045,0.2079,0.3090,0.4067,0.5000,0.5878,0.6691,0.7431,0.8090,0.8660,0.9135,0.9511,0.9781,0.9945
};
//??7??
uchar code SegCode[7][29][2]={
{{-14,30},{-13,30},{-12,30},{-11,30},{-10,30},{-9,30},{-8,30},{-7,30},{-6,30},{-5,30},{-4,30},{-3,30},{-2,30},{-1,30},{0,30},{1,30},{2,30},{3,30},{4,30},{5,30},{6,30},{7,30},{8,30},{9,30},{10,30},{11,30},{12,30},{13,30},{14,30}},
{{14,28},{14,27},{14,26},{14,25},{14,24},{14,23},{14,22},{14,21},{14,20},{14,19},{14,18},{14,17},{14,16},{14,15},{14,14},{14,13},{14,12},{14,11},{14,10},{14,9},{14,8},{14,7},{14,6},{14,5},{14,4},{14,3},{14,2},{14,1},{14,0}},
{{14,-28},{14,-27},{14,-26},{14,-25},{14,-24},{14,-23},{14,-22},{14,-21},{14,-20},{14,-19},{14,-18},{14,-17},{14,-16},{14,-15},{14,-14},{14,-13},{14,-12},{14,-11},{14,-10},{14,-9},{14,-8},{14,-7},{14,-6},{14,-5},{14,-4},{14,-3},{14,-2},{14,-1},{14,0}},
{{-14,-30},{-13,-30},{-12,-30},{-11,-30},{-10,-30},{-9,-30},{-8,-30},{-7,-30},{-6,-30},{-5,-30},{-4,-30},{-3,-30},{-2,-30},{-1,-30},{0,-30},{1,-30},{2,-30},{3,-30},{4,-30},{5,-30},{6,-30},{7,-30},{8,-30},{9,-30},{10,-30},{11,-30},{12,-30},{13,-30},{14,-30}},
{{-14,-28},{-14,-27},{-14,-26},{-14,-25},{-14,-24},{-14,-23},{-14,-22},{-14,-21},{-14,-20},{-14,-19},{-14,-18},{-14,-17},{-14,-16},{-14,-15},{-14,-14},{-14,-13},{-14,-12},{-14,-11},{-14,-10},{-14,-9},{-14,-8},{-14,-7},{-14,-6},{-14,-5},{-14,-4},{-14,-3},{-14,-2},{-14,-1},{-14,0}},
{{-14,28},{-14,27},{-14,26},{-14,25},{-14,24},{-14,23},{-14,22},{-14,21},{-14,20},{-14,19},{-14,18},{-14,17},{-14,16},{-14,15},{-14,14},{-14,13},{-14,12},{-14,11},{-14,10},{-14,9},{-14,8},{-14,7},{-14,6},{-14,5},{-14,4},{-14,3},{-14,2},{-14,1},{-14,0}},
{{-14,0},{-13,0},{-12,0},{-11,0},{-10,0},{-9,0},{-8,0},{-7,0},{-6,0},{-5,0},{-4,0},{-3,0},{-2,0},{-1,0},{0,0},{1,0},{2,0},{3,0},{4,0},{5,0},{6,0},{7,0},{8,0},{9,0},{10,0},{11,0},{12,0},{13,0},{14,0}}};
uchar code Date[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
//?????(1?2?3?6?9)
uchar code NUM1X[14]={6,6,6,6,6,6,6,6,6,6,6,6,6,6};
uchar code NUM1Y[14]={12,10,8,6,4,2,0,0,-2,-4,-6,-8,-10,-12};
uchar code NUM2X[35]={-6,-4,-2,0,2,4,6,6,6,6,6,6,6,6,6,4,2,0,-2,-4,-6,-6,-6,-6,-6,-6,-6,-6,-6,-4,-2,0,2,4,6};
uchar code NUM2Y[35]={12,12,12,12,12,12,12,12,10,8,6,4,2,0,0,0,0,0,0,0,0,0,-2,-4,-6,-8,-10,-12,-12,-12,-12,-12,-12,-12,-12};
uchar code NUM3X[35]={-6,-4,-2,0,2,4,6,6,6,6,6,6,6,6,6,4,2,0,-2,-4,-6,6,6,6,6,6,6,6,6,4,2,0,-2,-4,-6};
uchar code NUM3Y[35]={12,12,12,12,12,12,12,12,10,8,6,4,2,0,0,0,0,0,0,0,0,0,-2,-4,-6,-8,-10,-12,-12,-12,-12,-12,-12,-12,-12};
uchar code NUM6X[30]={6,3,0,-3,-6,-6,-6,-6,-6,-6,-6,-3,0,3,6,6,6,6,6,6,6,3,0,-3,-6,-6,-6,-6,-6,-6};
uchar code NUM6Y[30]={12,12,12,12,12,12,9,6,3,0,0,0,0,0,0,0,-3,-6,-9,-12,-12,-12,-12,-12,-12,-12,-9,-6,-3,0};
uchar code NUM9X[30]={6,3,0,-3,-6,-6,-6,-6,-6,-6,-6,-3,0,3,6,6,6,6,6,6,6,3,0,-3,-6,6,6,6,6,6};
uchar code NUM9Y[30]={12,12,12,12,12,12,9,6,3,0,0,0,0,0,0,0,-3,-6,-9,-12,-12,-12,-12,-12,-12,12,9,6,3,0};
uchar count,sec,min,hour,flag,key,sec1,min1,hour1,count1,keyready;
//???
void init()
{
ILE=1;
TMOD=0x11;
TH0=0x3C;
TL0=0xB0;
TH1=0x3C;
TL1=0xB0;
EA=1;
IE0=1;
EX0=1;
IT0=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
count=0;
sec=0;
min=0;
hour=0;
sec1=0;
min1=0;
hour1=0;
count1=0;
key=0;
keyready=0;
}
//??
void delay(uchar n)
{
uchar i;
for(i=0;i<n;i++);
}
/*=====================================
*函数原型:void displaydate(uchar num,uchar x,uchar y)
*参 数:num->需要显示的数字;x->表盘上的坐标[未加圆心坐标]
*返 回 值:无
======================================*/
void displaydate(uchar num,uchar x,uchar y)
{
uchar i,j,tmp;
tmp=Date[num];
for(i=0;i<7;i++)
{ //扫描7段码
if(0x01&tmp)
{ //根据数字判断每一段是否需要显示
for(j=0;j<29;j++)
{ //显示需要显示的段
ILE=0;
P1=SegCode[i][j][0]+x; //x 坐标
P0=SegCode[i][j][1]+y; //y 坐标
ILE=1;
delay(5);
}
}
tmp=tmp>>1; //移位判断下一段
}
}
//???????
void DisPoint(uchar x,uchar y)
{
uchar i,j;
for(j=0;j<6;j++)
for(i=0;i<6;i++)
{
//ILE=0;
P1=i+x; //x
P0=j+y;
//ILE=1; //y
}
for(j=0;j<6;j++)
for(i=0;i<6;i++)
{
//ILE=0;
P1=j+x; //x
P0=i+y;
//ILE=1; //y
}
}
//?????
void DisDigetalClk()
{
displaydate(hour1%10,60,127); //hour
displaydate(hour1/10,20,127);
displaydate(min1%10,150,127); //min
displaydate(min1/10,110,127);
DisPoint(80,137);
DisPoint(80,110);
displaydate(sec1%10,240,127); //sec
displaydate(sec1/10,200,127);
DisPoint(170,137);
DisPoint(170,110);
}
//?????
void DisMonitorClk()
{
uchar i;
for(i=0;i<14;i++) //1
{
P1=NUM1X[i]+110;
delay(5);
P0=NUM1Y[i]+227;
}
for(i=0;i<14;i++) //1
{
P1=NUM1X[i]+110;
delay(5);
P0=NUM1Y[i]+227;
}
delay(5);
for(i=0;i<35;i++) //2
{
P1=NUM2X[i]+133;
delay(5);
P0=NUM2Y[i]+227;
}
for(i=0;i<35;i++) //2
{
P1=NUM2X[i]+133;
delay(5);
P0=NUM2Y[