没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论




















#include < character.h >
#include < lcd.h >
#include < clock.h >
#include < sensor.h>
#include < calendar.h >
#include < key.h >
/*****************************预概念**************************************/
#define uchar unsigned char
#define uint unsigned int
/****************************************************************************/
sbit bell = P2 ^ 0; //概念蜂鸣器端口
sbit in = P2 ^ 7; //概念红外检测端口
/*****************************************************************************
* 名称: Timer0_Service() inturrupt 1
* 功能: 中断效劳程序 整点报时 3 声嘟嘟的声音
* 入口参数:
* 出口参数:
*****************************************************************************/
void Timer0_Service() interrupt 1
{
static uchar count = 0;
static uchar flag = 0; //记录鸣叫的次数
count = 0;
TR0 = 0;
//关闭 Timer0
TH0 = 0x3c;
TL0 = 0XB0; //延时 50 ms
TR0 = 1 ;
count ++;
//启动 Timer0
if( count == 20 ) //鸣叫 1 秒
{
bell = ~ bell;
count = 0;
flag ++;
}
if( flag == 6 )
{
flag = 0;
TR0 = 0; //关闭 Timer0
}
}
/*****************************************************************************

* 名称: Timer2_Servie() interrupt 5
* 功能: 中断效劳程序 整点报时 一分钟
* 入口参数:
* 出口参数:
*****************************************************************************/
void Timer3_Service() interrupt 5
{
static uchar count;
TF2 = 0; //软件清除中断标志
count ++;
if( in == 1 )
{
count = 0; //计算清 0
TR2 = 0; //关闭 Timer2
bell = 1; //关闭蜂鸣器
}
if( count == 120 ) // 一分钟后 关闭报警
{
count = 0; //计算清 0
TR2 = 0; //关闭 Timer2
bell = 1; //关闭蜂鸣器
}
}
/******************************************************************************
* 函数名称:main()
* 功
能:
* 入口参数:
* 出口参数:
*******************************************************************************
*/
void main( void )
{
uchar clock_time[7] = { 0x00, 0x17, 0x12, 0x14, 0x12, 0x08 };
分 时 日 月 年
//概念时刻变量 秒
uchar alarm_time[2] = { 0, 0}; //闹钟设置 alarm_time[0]: 分钟 alarm_time[1] :小时
uchar temperature[2]; //概念温度变量 temperature[0] 低 8位 temperature[1] 高 8
位
Lcd_Initial();
//LCD 初始化
Clock_Initial( clock_time ); / /时钟初试化
/***********************中断初始化***************************/
EA = 1; //开总中断
ET0 = 1; //Timer0 开中断

ET2 = 1; //Timer2 开中断
TMOD = 0x01 ; //Timer0 工作方式 1
RCAP2H = 0x3c;
RCAP2L = 0xb0; //Timer2 延时 50 ms
while( 1 )
{
switch( Key_Scan() )
{
case up_array: //
{
Key_Idle();
}
break;
case down_array:
{
Key_Idle();
}
break;
case clear_array:
{
Key_Idle();
}
break;
case function_array:{
Key_Function( clock_time, alarm_time );
}
case null:
{
Clock_Fresh( clock_time ); / /时刻刷新
Lcd_Clock( clock_time ); //时刻显示
Sensor_Fresh( temperature ); //温度更新
Lcd_Temperture( temperature ); / /温度显示
Calendar_Convert( 0 , clock_time );
Week_Convert( 0, clock_time );
//整点报时
if( ( * clock_time == 0x59 ) && ( * ( clock_time + 1 ) == 0x59 ) )
{
bell = 0;
TR2 = 1; //启动 Timer2
}

//闹钟报警
if( * alarm_time == * ( clock_time + 1 ) ) / /分钟相吻合
if( * ( alarm_time + 1 ) == *( clock_time + 2 ) ) / /小时相吻合
{
bell = 0;
TR2 = 1; //启动 Timer2
}
}
break;
}
}
}
#ifndef _SUN_MOON
#define _SUN_MOON
/*************************************************************************/
#define uchar unsigned char
#define uint unsigned int
/******************************************************************************
**
* 名称: get_moon_day(uchar month_p,uint table_addr)
* 功能: 读取数据表中农历的大月或小月 ,若是大月返回 1, 小月返回 0
* 入口参数:
* 出口参数:
*******************************************************************************
**/
bit get_moon_day( uchar month_p,uint calendar_address )
{
uchar temp;
switch(month_p)
{
case 1: { temp = year_code[calendar_address] & 0x08; if(temp==0) return(0); else
return(1); }
case 2: { temp = year_code[calendar_address] & 0x04; if(temp==0) return(0); else
return(1); }
case 3: { temp = year_code[calendar_address] & 0x02; if(temp==0) return(0); else
return(1); }
case 4: { temp = year_code[calendar_address] & 0x01; if(temp==0) return(0); else
return(1); }
case 5: { temp = year_code[calendar_address + 1] & 0x80; if(temp==0) return(0); else
return(1); }
case 6: { temp = year_code[calendar_address + 1] & 0x40; if(temp==0) return(0); else
return(1); }

case 7: { temp = year_code[calendar_address + 1] & 0x20; if(temp==0) return(0); else
return(1); }
case 8: { temp = year_code[calendar_address + 1] & 0x10; if(temp==0) return(0); else
return(1); }
case 9: { temp = year_code[calendar_address + 1] & 0x08; if(temp==0) return(0); else
return(1); }
case 10: { temp = year_code[calendar_address + 1] & 0x04; if(temp==0) return(0); else
return(1); }
case 11: { temp = year_code[calendar_address + 1] & 0x02; if(temp==0) return(0); else
return(1); }
case 12: { temp = year_code[calendar_address + 1] & 0x01; if(temp==0) return(0); else
return(1); }
case 13: { temp = year_code[calendar_address + 2] & 0x80; if(temp==0) return(0); else
return(1); }
}
}
/**************************************************************************
* 名称: void Calendar_Convert( uchar * clock_time )
* 功能: 输入 BCD 的阳历数据, 输出 BCD 阴历数据( 1901 - 2099 )
* 入口参数: c_flag:阳历的世纪标志 clock_time: 时钟地址
* 出口参数: 无
* 说明: c_flag = 0 :21 世纪 c_flag = 1 :19 世纪
*****************************************************************************/
void Calendar_Convert( uchar c_flag, uchar * clock_time )
{
bit flag_month, flag_year;
uchar year, month, day, month_point; / /概念 年 月 天
uchar temp1, temp2, temp3;
uint calendar_address; //概念农历地址
uint day_number;
uchar clock_moon[3]; //概念阴历
clock_time += 3; //指向日
day = ( * clock_time >> 4 ) * 10 + ( *clock_time & 0x0f ); //BCD转换十进制
clock_time ++; //指向月
month = ( * clock_time >> 4 ) * 10 + ( * clock_time & 0x0f ); //BCD转换十进制
clock_time ++; //指向年
year = ( * clock_time >> 4 ) * 10 + ( * clock_time & 0x0f ); //BCD转换十进制
//定位日历地址
if( c_flag == 0 )
calendar_address = ( year + 99 ) * 3;
else
剩余55页未读,继续阅读
资源评论

xxpr_ybgg
- 粉丝: 3240
- 资源: 3万+

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
最新资源
- CJK+GBK中字体生成器,GBK编码的各种中文字体及相关文件,对于想安装CJK宏包的Texlive用户非常有帮助
- VMware Workstation Pro去虚拟化 VMware底层文件vmware-vmx.exe修改器
- MES生产管理系统,.netframework+layui经典三层架构实现, 目前有.net6的高性能DDD模式版本
- 基于matlab程序的各种回归、分类算法实现
- DSP头文件CMD文件详细解析
- GoogLeNet 网络对CIFAR10 数据的应用
- 利用MQTT协议+阿里云平台实现视频监控系统(Qt上位机源码).zip
- 批量保存网页到单个文件的3个谷歌浏览器个插件.rar
- 机器学习行为预测数据分享
- 树状数组树状数组树状数组
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
