#include "typedef.h"
#include"pcf8563.h"
#include "ad.h"
#include "ad_key.h"
#include"led_smg.h"
uchar Set_Time_FLAG=0;
uchar Set_Get_Now_Time_FLAG=0;
uchar Set_Alarm_FLAG=0;
uchar Set_Get_Now_Alarm_FLAG=0;
uchar Set_JDQ1_FLAG=0;
uchar Set_JDQ2_FLAG=0;
uchar Set_JDQ1_OR_Time_FLAG=1;
uchar Set_JDQ2_OR_Time_FLAG=1;
uchar JDQ1_FLAG=0;
uchar JDQ2_FLAG=0;
char Set_Time[11]; //秒-分-时-日-星期-月-年
extern uchar Get_Pcf8563[11];
void My_Delay(int time)
{
while(time--);
}
main()
{
uchar Key=0;
P1M1=0;
P1M0|=0Xfe;
P2M1=0;
P2M0=0XFF;
P3M1=0x00;
P3M0|=0xf0;
// P17=0;
// P16=0;
//P13=0;
//P14=0;
//P15=0;
//PCF8563_Init();
PCF8563_Init_Two();
//while(1)
//{
// Key=My_Key_Two(1);
// displayer_num(Key,1800);
//}
while(1)
{
PCF8563_Read();
P13=0;P14=0;P15=0;
Key=My_Key(1);
if(Key==1)
{
while(Key==1)
{
My_Delay(500);
Key=My_Key(1);
}
Set_JDQ1_FLAG++;
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
//Set_JDQ1_FLAG=0;
Set_JDQ2_FLAG=0;
Set_Get_Now_Time_FLAG=0;
Set_Get_Now_Alarm_FLAG=0;
if(Set_JDQ1_FLAG>3)
Set_JDQ1_FLAG=0;
}
else if(Key==2)
{
while(Key==2)
{
My_Delay(500);
Key=My_Key(1);
}
Set_JDQ2_FLAG++;
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
Set_JDQ1_FLAG=0;
//Set_JDQ2_FLAG=0;
Set_Get_Now_Time_FLAG=0;
Set_Get_Now_Alarm_FLAG=0;
if(Set_JDQ2_FLAG>3)
Set_JDQ2_FLAG=0;
}
else if(Key==3)
{
while(Key==3)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
Set_Get_Now_Time_FLAG=0;
Set_Get_Now_Alarm_FLAG=0;
Set_JDQ1_FLAG=0;
Set_JDQ2_FLAG=0;
Set_JDQ1_OR_Time_FLAG=1;
Set_JDQ2_OR_Time_FLAG=1;
}
else if(Key==4)
{
while(Key==4)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time_FLAG++;
//Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
Set_JDQ1_FLAG=0;
Set_JDQ2_FLAG=0;
Set_Get_Now_Time_FLAG=0;
Set_Get_Now_Alarm_FLAG=0;
if(Set_Time_FLAG>7)
Set_Time_FLAG=0;
}
else if(Key==5)
{
while(Key==5)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Alarm_FLAG++;
Set_Time_FLAG=0;
//Set_Alarm_FLAG=0;
Set_JDQ1_FLAG=0;
Set_JDQ2_FLAG=0;
Set_Get_Now_Time_FLAG=0;
Set_Get_Now_Alarm_FLAG=0;
if(Set_Alarm_FLAG>4)
Set_Alarm_FLAG=0;
}
//PCF8563_Read();
//-------------------------------------------------------
if(Set_Time_FLAG==1)
{
if(Set_Get_Now_Time_FLAG==0)
{
Set_Time[0]=HexToBCD(Get_Pcf8563[0]);
Set_Get_Now_Time_FLAG=1;
}
if(Key==6)
{
while(Key==6)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[0]++;
if(Set_Time[0]>59)
Set_Time[0]=0;
}
else if(Key==7)
{
while(Key==7)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[0]--;
if(Set_Time[0]<0)
Set_Time[0]=59;
}
else if(Key==8)
{
while(Key==8)
{
My_Delay(500);
Key=My_Key(1);
}
PCF8563_I2C_WriteData(0x02,BCDToHex(Set_Time[0]));
Set_Get_Now_Time_FLAG=0;
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
}
P13=1;P14=0;P15=0;
displayer_TWO(Set_Time[0],1800);
}
else if(Set_Time_FLAG==2)
{
if(Set_Get_Now_Time_FLAG==0)
{
Set_Time[1]=HexToBCD(Get_Pcf8563[1]);
Set_Get_Now_Time_FLAG=1;
}
if(Key==6)
{
while(Key==6)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[1]++;
if(Set_Time[1]>59)
Set_Time[1]=0;
}
else if(Key==7)
{
while(Key==7)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[1]--;
if(Set_Time[1]<0)
Set_Time[1]=59;
}
else if(Key==8)
{
while(Key==8)
{
My_Delay(500);
Key=My_Key(1);
}
PCF8563_I2C_WriteData(0x03,BCDToHex(Set_Time[1]));
Set_Get_Now_Time_FLAG=0;
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
}
P13=0;P14=1;P15=0;
displayer_TWO(Set_Time[1],1800);
}
else if(Set_Time_FLAG==3)
{
if(Set_Get_Now_Time_FLAG==0)
{
Set_Time[2]=HexToBCD(Get_Pcf8563[2]);
Set_Get_Now_Time_FLAG=1;
}
if(Key==6)
{
while(Key==6)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[2]++;
if(Set_Time[2]>23)
Set_Time[2]=0;
}
else if(Key==7)
{
while(Key==7)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[2]--;
if(Set_Time[2]<0)
Set_Time[2]=23;
}
else if(Key==8)
{
while(Key==8)
{
My_Delay(500);
Key=My_Key(1);
}
PCF8563_I2C_WriteData(0x04,BCDToHex(Set_Time[2]));
Set_Get_Now_Time_FLAG=0;
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
}
P13=1;P14=1;P15=0;
displayer_TWO(Set_Time[2],1800);
}
else if(Set_Time_FLAG==4)
{
if(Set_Get_Now_Time_FLAG==0)
{
Set_Time[3]=HexToBCD(Get_Pcf8563[3]);
Set_Get_Now_Time_FLAG=1;
}
if(Key==6)
{
while(Key==6)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[3]++;
if(Set_Time[3]>31)
Set_Time[3]=1;
}
else if(Key==7)
{
while(Key==7)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[3]--;
if(Set_Time[3]<1)
Set_Time[3]=31;
}
else if(Key==8)
{
while(Key==8)
{
My_Delay(500);
Key=My_Key(1);
}
PCF8563_I2C_WriteData(0x05,BCDToHex(Set_Time[3]));
Set_Get_Now_Time_FLAG=0;
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
}
P13=0;P14=0;P15=1;
displayer_TWO(Set_Time[3],1800);
}
else if(Set_Time_FLAG==5)
{
if(Set_Get_Now_Time_FLAG==0)
{
Set_Time[4]=HexToBCD(Get_Pcf8563[4]);
Set_Get_Now_Time_FLAG=1;
}
if(Key==6)
{
while(Key==6)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[4]++;
if(Set_Time[4]>6)
Set_Time[4]=0;
}
else if(Key==7)
{
while(Key==7)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[4]--;
if(Set_Time[4]<0)
Set_Time[4]=6;
}
else if(Key==8)
{
while(Key==8)
{
My_Delay(500);
Key=My_Key(1);
}
PCF8563_I2C_WriteData(0x06,BCDToHex(Set_Time[4]));
Set_Get_Now_Time_FLAG=0;
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
}
P13=1;P14=0;P15=1;
displayer_TWO(Set_Time[4],1800);
}
else if(Set_Time_FLAG==6)
{
if(Set_Get_Now_Time_FLAG==0)
{
Set_Time[5]=HexToBCD(Get_Pcf8563[5]);
Set_Get_Now_Time_FLAG=1;
}
if(Key==6)
{
while(Key==6)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[5]++;
if(Set_Time[5]>12)
Set_Time[5]=1;
}
else if(Key==7)
{
while(Key==7)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[5]--;
if(Set_Time[5]<1)
Set_Time[5]=12;
}
else if(Key==8)
{
while(Key==8)
{
My_Delay(500);
Key=My_Key(1);
}
PCF8563_I2C_WriteData(0x07,BCDToHex(Set_Time[5]));
Set_Get_Now_Time_FLAG=0;
Set_Time_FLAG=0;
Set_Alarm_FLAG=0;
}
P13=0;P14=1;P15=1;
displayer_TWO(Set_Time[5],1800);
}
else if(Set_Time_FLAG==7)
{
if(Set_Get_Now_Time_FLAG==0)
{
Set_Time[6]=HexToBCD(Get_Pcf8563[6]);
Set_Get_Now_Time_FLAG=1;
}
if(Key==6)
{
while(Key==6)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[6]++;
if(Set_Time[6]>99)
Set_Time[6]=0;
}
else if(Key==7)
{
while(Key==7)
{
My_Delay(500);
Key=My_Key(1);
}
Set_Time[6]--;
if(Set_Time[6]<0)
Set_Time[6]=99;
}
else if(Key==8)
{
while(Key==8)
{
My_Del
stc15f204ea pcf8563 开关 时钟 -由于内存不足 改为408ad
需积分: 13 159 浏览量
2014-12-21
09:12:00
上传
评论
收藏 108KB ZIP 举报
xxcccm
- 粉丝: 121
- 资源: 20
最新资源
- 基于springboot+vue实现的在线考试系统+源代码+文档
- RTL8723DS 2022 版本 Linux驱动,android驱动 支持4.0-10x
- 要玩NDS的遊戲,必須要先下載三個bios檔案到你的檔案資料夾
- 各类型数据库4月排名,基于排名网站数据爬虫json结果
- 基于springboot+vue实现的在线考试系统+源代码+文档
- 淮北市杜集区人才补贴+生活补贴
- JAVA-JSP技术文档
- 课内实验02-决策表(共享单车月卡).docx
- 基于【React + Node+SpringBoot】疫情数据查看系统的设计与实现【源码+lw+部署+讲解】
- 基于【React + Node】云课堂系统设计与实现【源码+lw+部署+讲解】
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈