云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 基于51单片机的电子万年历设计毕业论文设计

基于51单片机的电子万年历设计毕业论文设计

  • 62 次阅读
  • 3 次下载
  • 2025/5/6 15:58:58

delay_18B20(100); // this message is wery important Init_DS18B20(); WriteOneChar(0xCC); //跳过读序号列号的操作 WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器) 前两个就是温度 delay_18B20(100); L_18B20=ReadOneChar(); //读取低八位数据 H_18B20=ReadOneChar(); //读取高八位数据 zhengshu=L_18B20/16+H_18B20*16; //整数部分 xiaoshu_a=(L_18B20&0x0f)*10/16; //小数第一位 }

//------------------DS18B20--------------------- ///////////////////////////////////////////////// /*

* 按键扫描 */

int8 scan_key(void) { int8 val=-1; if (KeyIn1 == 0) { val = 1; while (KeyIn1 == 0); } else if (KeyIn2 == 0) { val = 2; while (KeyIn2 == 0); } else if (KeyIn3 == 0) { val = 3; while (KeyIn3 == 0); } //if (val > 0) //buzzer_sound(); return val; }

/*

* 主界面框架 */

void main_frame(void) { play32(80, 2, 10); play32(32, 2, 10); play8(16, 0, S_xie); play8(40, 0, S_xie); // play8(96, 0, RH);

// play8(120, 0, S_percent); play8(120, 6, S_du); } /*

* 主界面 */

void main_show(bit refresh) {

uint8 lunar[2]; if (refresh) read_time((uint8 *)&time); // 时间 if (refresh || (time.sec != tmp_time.sec)) // 秒更新 { tmp_time.sec = time.sec; // 温湿度

play8_num(104, 6,zhengshu); //温度显示 play32_num(96, 2, time.sec); } if (refresh) main_frame(); if (refresh || (time.min != tmp_time.min)) // 分更新 { if (!refresh) flag = 0; tmp_time.min = time.min; play32_num(48, 2, time.min); }

} /*

if (refresh || (time.hour != tmp_time.hour)) // 时更新 { if ((!refresh)&&(Clock_flag)) alarm_sound(); tmp_time.hour = time.hour; play32_num(0, 2, time.hour); }

if (refresh || (time.day != tmp_time.day)) // 日更新 { tmp_time.day = time.day; play8_num(48, 0, time.day); // 农历 turn_lunar_calendar(&time, lunar); play_lunar_calendar(0, 6, lunar[0], lunar[1]); }

if (refresh || (time.week != tmp_time.week)) // 周更新 { tmp_time.week = time.week; play_week(68, 0, time.week); }

if (refresh || (time.mon != tmp_time.mon)) // 月更新 { tmp_time.mon = time.mon; play8_num(24, 0, time.mon); // 农历 turn_lunar_calendar(&time, lunar); play_lunar_calendar(0, 6, lunar[0], lunar[1]); }

if (refresh || (time.year != tmp_time.year)) // 年更新 { tmp_time.year = time.year; play8_num(0, 0, time.year); // 农历 turn_lunar_calendar(&time, lunar); play_lunar_calendar(0, 6, lunar[0], lunar[1]); }

* 主机界面设置 */

void main_set(void) { int8 key_val, state=1; play32_num(96, 2|0x80, time.sec); while (1) { key_val = scan_key(); if (key_val == 1) // 设置 { if (state >= 7) state = 0; else state++; set_time((uint8 *)&time); main_show(1); switch (state) { case 0: set_time((uint8 *)&time); break; case 1: play32_num(96, 2|0x80, time.sec); break; case 2: play32_num(48, 2|0x80, time.min); break; case 3: play32_num(0, 2|0x80, time.hour); break; case 4: play_week(68, 0|0x80, time.week); break; case 5: play8_num(48, 0|0x80, time.day); break; case 6: play8_num(24, 0|0x80, time.mon); break; case 7: play8_num(0, 0|0x80, time.year); break; default: break; } } else if (key_val > 1) { if (state == 1) { if (key_val == 3) time.sec++; else time.sec--; if (time.sec >= 60) time.sec = 0; else if (time.sec < 0)

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

delay_18B20(100); // this message is wery important Init_DS18B20(); WriteOneChar(0xCC); //跳过读序号列号的操作 WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器) 前两个就是温度 delay_18B20(100); L_18B20=ReadOneChar(); //读取低八位数据 H_18B20=ReadOneChar(); //读取高八位数据 zhengshu=L_18B20/16+H_18B20*16; //整数部分 xiaoshu_a=(L_18B20&0x0f)*10/16; //小数第一位 } //------------------DS18B20-------------------

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com