找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 17115|回复: 33
打印 上一主题 下一主题
收起左侧

51单片机制作的:计算器、万年历、温度表

  [复制链接]
跳转到指定楼层
楼主
ID:76686 发表于 2015-4-11 18:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

51单片机制作的:计算器,万年历,温度表,适合初学者,感谢原作者! 51单片机计算器、万年历、温度表.rar (421.52 KB, 下载次数: 385)
  1. /**************************************************************************************
  2. 程序名称:时间 温度控制系统(128*64LCD+ds1302+ds18b20)
  3. 主要功能:温度计 时钟 闹铃 密码锁 篮球器 计算器 温度控制 键盘锁 系统设置等。
  4. 主要说明:程序全部定义在一个C文件中。
  5. 作者:   zhaozonghui
  6. 时间:   2014.11.15
  7. 版本:   zzh-v0.1
  8. /**************************************************************************************
  9. 图文菜单系统

  10. **************************************************************************************/
  11. #include    <STC15F2K60S2.H>
  12. #include    <intrins.h>               
  13. #define     uchar        unsigned char
  14. #define     uint         unsigned int
  15. #define     time_count   0x3cb0
  16. #define     close        1
  17. #define     open         0
  18. /*============ 状态控制及温感器总线定义 ==============*/
  19. sbit             b20_io=        P1^5;                // DS18B20总线          
  20. sbit             pw_oc=                P3^5;                // 密码锁开启控制(黄灯)
  21. sbit             buzzer=        P1^6;                 // 蜂鸣器
  22. sbit             lcd_bl=        P3^6;                // 背光控制口
  23. sbit             als_th=        P3^7;                // 上限温度警报(红灯)
  24. sbit              als_tl=        P3^4;                // 下限温度警报(绿灯)
  25. #define             keyboard     P2                        // 键盘数据口
  26. /*================= ST7920LCD 定义 ===================*/
  27. #define     comm         0                        // lcd指令
  28. #define     dat          1                        // lcd数据
  29. sbit             lcd_e=                 P1^2;                // lcd使能
  30. sbit             lcd_rw=                P1^1;                // lcd读写
  31. sbit            lcd_rs=                P1^0;                // lcd数据命令
  32. #define     lcd_data     P0                        // lcd(8bit)数据传输   
  33. /*=============== DS1302 寄存器地址定义 ===============*/
  34. sbit            d02_rst=        P4^4;                // DS1302使能
  35. sbit            d02_data=        P4^2;                // DS1302数据线
  36. sbit            d02_sclk=        P4^1;                // DS1302脉冲
  37. #define     d02_wrc      0x8e                // 1302读写RAM控制(1允许 0禁止)
  38. #define     d02_year         0x8c                // 年
  39. #define     d02_weeks         0x8a                // 星期
  40. #define     d02_month         0x88                // 月
  41. #define     d02_day                 0x86                // 日
  42. #define     d02_hour         0x84                // 时
  43. #define     d02_minute         0x82                // 分
  44. #define     d02_second         0x80                // 秒
  45. #define     d02_signs         0xc0                // 系统状态(记录设置标记)
  46. #define     d02_passw         0xc2                // 密码寄存器首位(有3位下位地址加2,初始值为:741456)
  47. #define     d02_alm                 0xc8                // 闹铃时间小时位(下位为分钟位加2)
  48. #define     d02_temp         0xcc                // 温度上限警报(有两位下位位下限加2)
  49. #define     d02_initsi   0xd4                // 1302初始化标记(为0xb4时,说明已经初始化)
  50. #define     ret_ds1302()    d02_rst=0;d02_sclk=0;d02_rst=1        // 1302读写复位
  51. #define     end_ds1302()    d02_sclk=1;d02_rst=0                        // 1302读写结束
  52. /*===============================全局变量定义 ==================================*/
  53. typedef        struct                        // 定义时间类型
  54. {
  55.   uchar        hour;
  56.   uchar        minute;
  57.   uchar        second;
  58. }time;
  59. typedef        struct                        // 定义日期类型
  60. {
  61.   uchar        year;
  62.   uchar        month;
  63.   uchar        day;
  64.   uchar        week;
  65. }date;
  66. typedef union                     // 定义温度类型
  67. {
  68.   int temp_data;
  69.   uchar t_data[2];
  70. }trdata;

  71. trdata  bdata  temp;             // 温度警报值暂存       
  72. date    idata  today={'8',1,1,1};         // 日期暂存
  73. time    idata  now={0x12,0,0} , save_time={0x12,0,0};
  74.               // 时间暂存(now是读出时间暂存 save_time上一时间暂存)
  75. uchar   idata  time_tick=20,time_tick1=20,alarm_time[2],als_temp[2],
  76.               // T0中断数,     T1中断数,     闹铃时间,   警报温度
  77.                bl_delay=15,temp_delay=5,opera[2][12],resu[12],
  78.                           // 背光时间,  温度更新时间, 计算器数据寄存, 结果寄存
  79.                            i,j,save1,temp_min=0;
  80.                            // 计算器i/j下标,中间暂存,温度更新(分)
  81. uchar  bdata   signs=0;                 // 系统标记寄存器
  82.   sbit bl1=signs^7;                  // bl1,bl0背光选择位(00 延时,01 常开,10 关闭)
  83.   sbit bl0=signs^6;                       
  84.   sbit di1=signs^5;                         // di1,di0显示模式(00模式1,01模式2,10模式3)
  85.   sbit di0=signs^4;                       
  86.   sbit meu=signs^3;                         // 菜单显示方式(0 图片,1 文字)
  87.   sbit keb=signs^2;                         // 键盘锁(0 无锁,1加锁)
  88.   sbit alm=signs^1;                         // 闹钟启动位(0 关闭,1开启)
  89.   sbit als=signs^0;                         // 报警启动位(0 启动,1关闭)
  90. uint   bdata   run_signs=0;     // 运行标记寄存器
  91.   sbit ds18b20=run_signs^0;                // 温感器存在标记(0不存在,1存在)
  92.   sbit temp_pn=run_signs^1;                // 温度正负号标记(0正,1负)
  93.   sbit temprun=run_signs^2;                // 温感器运行标记(0否,1启动)
  94.   sbit nba_tim=run_signs^3;           // 篮球计时器标记(0关闭,1启动)
  95.   sbit adju_si=run_signs^4;                // 数字更改连续标记(1连续)
  96.   sbit cal_del=run_signs^5;     // 计算器显示点标记(0没有显示)
  97.   sbit cal_run=run_signs^6;            // 计算完毕标记(1有效)
  98.   sbit oth_run=run_signs^7;     // 其他标记
  99.   sbit alm_run=run_signs^8;     // 闹钟时间到达标记(1有效)
  100.   sbit dis_sig=run_signs^9;     // 显示时间标记(1有效)
  101.   sbit lock_op=run_signs^10;    // 关锁时间到标记(1有效)
  102.   sbit b20time=run_signs^11;    // 温感器重新读温度标记(1有效)
  103.   sbit t0_isr =run_signs^12;    // TO中断标记(1有效(1s)
  104.   sbit thl_als=run_signs^13;        // 温度警报标记
  105.   sbit init_d2=run_signs^14;        // 模式2初始显示
  106.   sbit buzstop=run_signs^15;        // 蜂鸣器停止标记
  107. /*===============================字体显示代码 ==================================*/
  108. uchar code weeks[7][2]={"一","二","三","四","五","六","日"}; // 星期                //图片中文
  109. uchar code menu_cn[6][8]={"调    整","工    具","设    置","保    密","版    本","退    出"};
  110. uchar code menu_cn_2[6][8]={"调  整  ","工  具","设  置","保  密","版  本","退  出"};   // 菜单文字
  111. uchar code selected[2][28]={{"进入【      】\x04 "},{"设置【      】\x10 \x04 "}};    // 选框
  112. uchar code secrets_menu[4][6]={"开  锁","更  改","初始化","退  出"};      // 保密菜单中文
  113. uchar code tool_menu[5][6]={"计算器","温度计","闹  铃","篮球器","退  出"};        // 工具菜单中文
  114. uchar code char_num[10]={"0123456789"};                   // 数字显示代码            // 每月天数
  115. uchar code dayofmonth[12]={0x31,0x28,0x31,0x30,0x31,0x30,0x31,0x31,0x30,0x31,0x30,0x31};
  116. uchar code key_code[]={0xD7,0x7E,0x7D,0x7B,0xBE,0xBD,0xBB,0xDE,0xDD,0xDB,0xB7,0x77,0xEE,0xED,0xEB,0xE7};
  117. uchar code ksp[4]={0x7F,0xBF,0xDF,0xEF};                           // 按键扫描代码
  118. uchar code tool_cal[4][2]={"+ ","- ","* ","/ "};            // 运算符号
  119. uchar code alm_sign[2][2]={"关","开"};                                 // 闹铃开关
  120. uchar code set_bl_dm[2][3][4]={{"30秒","常开","关闭"},{"模01","模02","模03"}};
  121. uchar code set_mka[3][2][4]={{"图片","文字"},{"解锁","加锁"},{"开启","关闭"}};
  122. uchar code nba_oppo[8][2]={"红","白","蓝","绿","紫","灰","黄","黑"};
  123. uchar code set_menu[6][4]={"背光","显示","菜单","键盘","警报","退出"};
  124. uchar code version[10][14]={   // 版本信息
  125.                             {"为了打发枯燥的"},{"日子,学习这个"}, {"与年龄不相称的"},
  126.         {"单片机编程语言"},{"都说要学以致用"},{"说起容易作起来"},
  127.                                               {"真的很不容易啊"},{"但是充满乐趣!"},   {"赵宗会14/11/15"},
  128.                                               {"         (ok)\x10"}};
  129. uchar code timer_tips[12][16]={ // 篮球器使用说明
  130.                             {"使用方法:      "},{"  (+)(-)与(*)(/)"},{"分别是两方的分数"},
  131.                                                 {"加与减,(7)键回退"},{"一秒,(8)键24秒复"},{"位,(9)键暂停与开"},
  132.                                                 {"始;暂停状态下:"},{"按两次(OK)键可返"},{"回时钟模式-2界面"},
  133.                                              {",(OK)键返回程序"},{"界面,(./S)键两次"},{"退出程序.   \x1f"}};
  134. /*===============================操作导航代码 ==================================*/
  135. typedef struct                        // 定义主菜单操作索引
  136. {
  137.   uchar shaft_num;
  138.   uchar left_num;
  139.   uchar right_num;
  140. }menu_index;
  141. typedef struct                        // 定义导航更改索引
  142. {
  143.   uchar lnum;
  144.   uchar rnum;
  145. }index;
  146. menu_index code index_m[6]={{3,5,1},{4,0,2},{5,1,3},{0,2,4},{1,3,5},{2,4,0}}; // 菜单导航
  147. index code index_t[6]={{4,1},{0,2},{1,3},{2,4},{3,0}};       // 工具导航
  148. index code index_p[5]={{3,1},{0,2},{1,3},{2,0}};             // 保密导航
  149. index code index_s[6]={{5,1},{0,2},{1,3},{2,4},{3,5},{4,0}}; // 设置导航
  150. index code index_a[7]={{0x81,0x91},{0x83,0x91},{0x85,0x91},{0x89,0x81},
  151.                               {0x8b,0x81},{0x8d,0x81},{0x8f,0x91}};       // 调整下的坐标
  152. index code index_temp_set[3]={{0x8b,0x81},{0x8b,0x91},{0x8f,0x91}}; // 温度设定下的坐标
  153. index code index_alm[3]={{0x8c,0x81},{0x8e,0x81},{0x8f,0x91}};            // 闹铃更改坐标       
  154. index code index_cal[3]={{0x86,0x90},{0x8e,0x80},{0x8e,0x90}};            // 计算器操作坐标
  155. uchar code index_nba[4]={0x93,0x97,0x8b,0x8f};                                            // 篮球器设置导航
  156. /*=========================菜单图片(宽度x高度=32*24)=============================*/
  157. uchar code menu_pic[6][96]={
  158.         {// 调整
  159.          0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,
  160.          0x40,0x00,0x00,0x82,0x47,0xFF,0xE1,0xC2,0x47,0xFF,0xF3,0xE2,0x47,0x38,0x68,0x02,
  161.          0x46,0xDF,0x68,0x82,0x46,0xDF,0x69,0xC2,0x46,0xDE,0xE8,0x82,0x46,0xDD,0xE8,0x02,
  162.          0x46,0xDD,0xE8,0x02,0x47,0x3D,0xE8,0x02,0x47,0xFF,0xE8,0x02,0x47,0xFF,0xE9,0xC2,
  163.          0x42,0x00,0x18,0x02,0x41,0xFF,0xF3,0xE2,0x40,0x00,0x01,0xC2,0x40,0x00,0x00,0x82,
  164.          0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
  165.         {// 工具                                       
  166.          0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x03,0x82,
  167.          0x41,0xF0,0x07,0xC2,0x43,0xFF,0xCF,0xE2,0x47,0x3F,0xFE,0x02,0x47,0x3F,0xFE,0x02,
  168.          0x43,0xFF,0xCF,0xE2,0x41,0xF0,0x0F,0xC2,0x40,0x00,0x03,0x82,0x40,0x00,0x00,0x02,
  169.          0x40,0x00,0x03,0xC2,0x40,0x00,0x03,0xC2,0x41,0x80,0x01,0x82,0x43,0xFF,0xF3,0xC2,
  170.          0x47,0xFF,0xFF,0xE2,0x47,0xFF,0xFF,0xE2,0x43,0xFF,0xF3,0xC2,0x41,0x80,0x01,0x82,
  171.          0x40,0x00,0x01,0x82,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
  172.         {// 设置
  173.          0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x43,0x18,0x00,0x02,
  174.          0x44,0xA4,0x0E,0x02,0x44,0xA4,0x1F,0x02,0x43,0x24,0x3F,0x02,0x40,0x00,0x7F,0x02,
  175.          0x40,0xF0,0xFC,0x02,0x43,0xF9,0xF0,0x02,0x43,0x03,0xE0,0x02,0x46,0x77,0x80,0x02,
  176.          0x46,0x7F,0x00,0x02,0x46,0x7E,0x00,0x02,0x46,0x7C,0x00,0x02,0x47,0x3D,0x00,0x02,
  177.          0x43,0x1D,0x81,0x22,0x43,0x81,0xB2,0x42,0x41,0xC3,0x4F,0xE2,0x40,0xFE,0x4A,0x42,
  178.          0x40,0x3C,0x32,0x42,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
  179.         {// 保密
  180.          0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0xFC,0x03,0x02,
  181.          0x41,0xFE,0x1F,0x02,0x43,0x87,0x03,0x82,0x43,0x03,0x03,0x02,0x43,0x03,0x03,0x02,
  182.          0x43,0x03,0x0F,0x02,0x43,0x03,0x03,0x02,0x43,0x03,0x03,0x02,0x47,0xFF,0x83,0x02,
  183.          0x47,0xFF,0x83,0x02,0x47,0xCF,0x83,0x02,0x47,0x87,0x83,0x02,0x47,0xCF,0x83,0x02,
  184.          0x47,0xCF,0x87,0x82,0x47,0xCF,0x8F,0xC2,0x47,0xCF,0x9C,0xE2,0x47,0xFF,0x8F,0xC2,
  185.          0x43,0xFF,0x07,0x82,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
  186.         {// 版本
  187.          0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,
  188.          0x40,0x0F,0x00,0x62,0x40,0x1D,0x80,0xF2,0x40,0x38,0x41,0xF2,0x40,0x70,0x23,0xE2,
  189.          0x40,0xE2,0x17,0xC2,0x41,0xE4,0x4F,0x82,0x41,0xF0,0x9F,0x02,0x41,0x59,0x16,0x02,
  190.          0x42,0x4C,0x1D,0x02,0x42,0x46,0x20,0x82,0x42,0x47,0x00,0x42,0x44,0x43,0x80,0xC2,
  191.          0x44,0x44,0xC1,0xC2,0x44,0xC8,0x63,0x82,0x45,0x50,0x37,0x02,0x46,0x60,0x1E,0x02,
  192.          0x40,0x40,0x0C,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
  193.         {// 退出
  194.          0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x40,0xFF,0xE2,
  195.          0x40,0x60,0x80,0x62,0x43,0xF0,0x80,0xA2,0x43,0xF0,0x81,0x22,0x40,0x60,0x82,0x22,
  196.          0x40,0x40,0x84,0x22,0x40,0x00,0x88,0x22,0x40,0x00,0x88,0x22,0x47,0xFF,0xF8,0x22,
  197.          0x47,0xFF,0xF8,0x22,0x46,0x2A,0x2A,0x22,0x46,0xE3,0x78,0x22,0x46,0x77,0x78,0x22,
  198.          0x46,0xE3,0x78,0x62,0x46,0x2A,0x38,0x82,0x47,0xFF,0xF9,0x02,0x47,0xFF,0xFA,0x02,
  199.          0x40,0x00,0x0C,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,}};
  200. /*================显示模式2数字及温度符号图片(宽度x高度=16*32)=====================*/
  201. uchar code mode_2num[11][64]={


  202. {0x00,0x00,0x00,0x00,0x03,0xC0,0x0C,0x30,0x18,0x18,0x10,0x08,0x21,0x84,0x22,0x44,
  203. 0x22,0x44,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,
  204. 0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x22,0x44,
  205. 0x22,0x44,0x21,0x84,0x10,0x08,0x18,0x18,0x0C,0x30,0x03,0xC0,0x00,0x00,0x00,0x00},/*"0",0*/

  206. {0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x90,0x01,0x10,0x01,0x10,0x06,0x10,0x3C,0x10,
  207. 0x20,0x10,0x20,0x10,0x3F,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,
  208. 0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,
  209. 0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0xF0,0x00,0x00,0x00,0x00},/*"1",1*/

  210. {0x00,0x00,0x00,0x00,0x07,0xE0,0x08,0x30,0x10,0x08,0x20,0x04,0x23,0x84,0x24,0x42,
  211. 0x48,0x22,0x48,0x22,0x48,0x22,0x78,0x22,0x00,0x22,0x00,0x22,0x00,0x46,0x00,0x44,
  212. 0x00,0x8C,0x01,0x08,0x02,0x10,0x04,0x20,0x0C,0x40,0x08,0x80,0x11,0x00,0x22,0x00,
  213. 0x24,0x00,0x27,0xFE,0x40,0x02,0x40,0x02,0x40,0x02,0x7F,0xFE,0x00,0x00,0x00,0x00},/*"2",2*/

  214. {0x00,0x00,0x00,0x00,0x07,0xC0,0x08,0x30,0x10,0x18,0x20,0x08,0x23,0x84,0x44,0xC4,
  215. 0x48,0x44,0x48,0x44,0x78,0x44,0x00,0x44,0x00,0xC8,0x03,0x90,0x02,0x30,0x02,0x08,
  216. 0x03,0x84,0x00,0x44,0x00,0x22,0x00,0x22,0x00,0x22,0x78,0x22,0x48,0x22,0x48,0x22,
  217. 0x44,0x42,0x23,0x84,0x20,0x04,0x10,0x08,0x08,0x30,0x07,0xC0,0x00,0x00,0x00,0x00},/*"3",3*/

  218. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x84,0x01,0x04,0x01,0x44,0x02,0x44,
  219. 0x02,0x44,0x02,0x44,0x04,0xC4,0x05,0x44,0x09,0x44,0x0A,0x44,0x12,0x44,0x14,0x44,
  220. 0x24,0x44,0x24,0x44,0x48,0x44,0x4F,0xC7,0x40,0x01,0x40,0x01,0x40,0x01,0x7F,0xC7,
  221. 0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x7C,0x00,0x00,0x00,0x00},/*"4",4*/

  222. {0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFC,0x10,0x04,0x20,0x04,0x20,0x04,0x27,0xFC,
  223. 0x24,0x00,0x28,0x00,0x28,0x00,0x2B,0xE0,0x2C,0x10,0x28,0x08,0x20,0x04,0x23,0x84,
  224. 0x44,0x42,0x38,0x62,0x00,0x22,0x00,0x22,0x00,0x22,0x00,0x22,0x78,0x22,0x48,0x62,
  225. 0x44,0x44,0x23,0x84,0x20,0x0C,0x10,0x08,0x08,0x30,0x07,0xC0,0x00,0x00,0x00,0x00},/*"5",5*/

  226. {0x00,0x00,0x00,0x00,0x03,0xE0,0x0C,0x10,0x18,0x08,0x10,0x04,0x21,0xC4,0x22,0x3C,
  227. 0x22,0x00,0x24,0x00,0x44,0x00,0x45,0xE0,0x46,0x18,0x44,0x08,0x48,0x04,0x41,0xC4,
  228. 0x42,0x42,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x24,0x22,
  229. 0x22,0x44,0x21,0xC4,0x10,0x0C,0x18,0x08,0x0C,0x30,0x03,0xE0,0x00,0x00,0x00,0x00},/*"6",6*/

  230. {0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x40,0x01,0x40,0x01,0x40,0x01,0x7F,0xF9,
  231. 0x00,0x12,0x00,0x22,0x00,0x24,0x00,0x4C,0x00,0x48,0x00,0x88,0x00,0x90,0x01,0x10,
  232. 0x01,0x30,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,
  233. 0x04,0xC0,0x08,0x80,0x08,0x80,0x08,0x80,0x08,0x80,0x0F,0x80,0x00,0x00,0x00,0x00},/*"7",7*/

  234. {0x00,0x00,0x00,0x00,0x03,0xE0,0x0C,0x30,0x18,0x18,0x10,0x08,0x23,0xC4,0x22,0x44,
  235. 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x26,0x44,0x13,0xC8,0x10,0x10,0x08,0x10,
  236. 0x10,0x08,0x21,0x84,0x22,0x44,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,
  237. 0x42,0x42,0x23,0xC4,0x20,0x04,0x10,0x08,0x08,0x10,0x07,0xE0,0x00,0x00,0x00,0x00},/*"8",8*/

  238. {0x00,0x00,0x00,0x00,0x07,0xC0,0x0C,0x30,0x10,0x18,0x30,0x08,0x21,0x84,0x22,0x44,
  239. 0x44,0x24,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x44,0x22,0x42,0x42,
  240. 0x23,0x82,0x20,0x22,0x10,0x22,0x18,0x62,0x07,0xA2,0x00,0x22,0x00,0x24,0x3C,0x44,
  241. 0x22,0x44,0x23,0x84,0x20,0x08,0x10,0x18,0x08,0x30,0x07,0xC0,0x00,0x00,0x00,0x00},/*"9",9*/

  242. {0x00,0x00,0x30,0x00,0x48,0x00,0x48,0x00,0x30,0x00,0x03,0xE0,0x0C,0x30,0x18,0x08,
  243. 0x10,0x0C,0x21,0x84,0x22,0x44,0x22,0x62,0x44,0x22,0x44,0x22,0x44,0x3E,0x44,0x00,
  244. 0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x3E,0x44,0x22,0x44,0x22,0x22,0x22,
  245. 0x22,0x44,0x21,0x84,0x10,0x08,0x18,0x08,0x0C,0x30,0x03,0xC0,0x00,0x00,0x00,0x00},};/*sheshiwendu        */

  246. /*=====================显示模式3数字图片(宽度x高度=24*32)=========================*/
  247. uchar code mode_3num[10][96]={         //阴码,顺向,逐行式 C51 十六进制,对应英文点阵 24×32


  248. {0x01,0xFF,0xC0,0x07,0xFF,0xF0,0x1F,0xFF,0xFC,0x1F,0xFF,0xFC,0x3F,0xE3,0xFE,0x3F,
  249. 0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,
  250. 0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,
  251. 0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,
  252. 0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,0xFE,0x3F,0xE3,
  253. 0xFE,0x1F,0xFF,0xFC,0x1F,0xFF,0xFC,0x07,0xFF,0xF0,0x00,0xFF,0x80,0x00,0x00,0x00},/*"0",0*/

  254. {0x03,0xFC,0x00,0x03,0xFC,0x00,0x07,0xFC,0x00,0x0F,0xFC,0x00,0x3F,0xFC,0x00,0x3F,
  255. 0xFC,0x00,0x3F,0xFC,0x00,0x3F,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,
  256. 0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,
  257. 0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,
  258. 0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,
  259. 0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x00,0x00,0x00},/*"1",1*/

  260. {0x01,0xFF,0x80,0x0F,0xFF,0xE0,0x1F,0xFF,0xF0,0x1F,0xFF,0xF8,0x3F,0xC7,0xF8,0x3F,
  261. 0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,
  262. 0xFC,0x00,0x0F,0xFC,0x00,0x0F,0xF8,0x00,0x1F,0xF0,0x00,0x3F,0xF0,0x00,0x3F,0xE0,
  263. 0x00,0x7F,0xE0,0x00,0xFF,0xC0,0x00,0xFF,0x80,0x01,0xFF,0x80,0x03,0xFF,0x00,0x03,
  264. 0xFE,0x00,0x07,0xFE,0x00,0x0F,0xFC,0x00,0x0F,0xF8,0x00,0x1F,0xF8,0x00,0x3F,0xF0,
  265. 0x00,0x3F,0xFF,0xFC,0x3F,0xFF,0xFC,0x3F,0xFF,0xFC,0x3F,0xFF,0xFC,0x00,0x00,0x00},/*"2",2*/

  266. {0x01,0xFF,0x80,0x0F,0xFF,0xE0,0x1F,0xFF,0xF8,0x3F,0xFF,0xF8,0x3F,0xC7,0xFC,0x3F,
  267. 0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,
  268. 0xFC,0x00,0x07,0xFC,0x00,0x0F,0xF8,0x00,0x7F,0xF8,0x00,0x7F,0xE0,0x00,0x7F,0xC0,
  269. 0x00,0x7F,0xF0,0x00,0x0F,0xF8,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,
  270. 0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,
  271. 0xFC,0x3F,0xFF,0xF8,0x1F,0xFF,0xF8,0x0F,0xFF,0xE0,0x01,0xFF,0x80,0x00,0x00,0x00},/*"3",3*/

  272. {0x00,0x3F,0xFC,0x00,0x7F,0xFC,0x00,0x7F,0xFC,0x00,0xFF,0xFC,0x00,0xFF,0xFC,0x00,
  273. 0xFF,0xFC,0x01,0xFF,0xFC,0x01,0xFF,0xFC,0x01,0xFF,0xFC,0x03,0xFF,0xFC,0x03,0xFF,
  274. 0xFC,0x07,0xF7,0xFC,0x07,0xF7,0xFC,0x07,0xF7,0xFC,0x0F,0xE7,0xFC,0x0F,0xE7,0xFC,
  275. 0x0F,0xE7,0xFC,0x1F,0xC7,0xFC,0x1F,0xC7,0xFC,0x3F,0xC7,0xFC,0x3F,0x87,0xFC,0x3F,
  276. 0x87,0xFC,0x7F,0x87,0xFC,0x7F,0xFF,0xFF,0x7F,0xFF,0xFF,0x7F,0xFF,0xFF,0x7F,0xFF,
  277. 0xFF,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x00,0x00},/*"4",4*/

  278. {0x3F,0xFF,0xFC,0x3F,0xFF,0xF8,0x3F,0xFF,0xF8,0x3F,0xFF,0xF8,0x3F,0xC0,0x00,0x3F,
  279. 0xC0,0x00,0x3F,0xC0,0x00,0x3F,0xC0,0x00,0x3F,0xC0,0x00,0x3F,0xC0,0x00,0x3F,0xDF,
  280. 0xE0,0x3F,0xFF,0xF8,0x3F,0xFF,0xFC,0x3F,0xFF,0xFC,0x3F,0xC7,0xFC,0x3F,0xC7,0xFC,
  281. 0x00,0x07,0xFC,0x00,0x07,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,
  282. 0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,
  283. 0xFC,0x3F,0xFF,0xF8,0x1F,0xFF,0xF8,0x0F,0xFF,0xE0,0x01,0xFF,0x80,0x00,0x00,0x00},/*"5",5*/

  284. {0x01,0xFF,0x80,0x0F,0xFF,0xF0,0x1F,0xFF,0xF8,0x1F,0xFF,0xF8,0x3F,0xE7,0xFC,0x3F,
  285. 0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE0,0x00,0x3F,0xEF,
  286. 0xC0,0x3F,0xFF,0xF0,0x3F,0xFF,0xF8,0x3F,0xFF,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,
  287. 0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,
  288. 0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,
  289. 0xFC,0x3F,0xFF,0xFC,0x1F,0xFF,0xF8,0x0F,0xFF,0xE0,0x01,0xFF,0x80,0x00,0x00,0x00},/*"6",6*/

  290. {0x1F,0xFF,0xFC,0x1F,0xFF,0xFC,0x1F,0xFF,0xFC,0x1F,0xFF,0xFC,0x00,0x0F,0xFC,0x00,
  291. 0x0F,0xF8,0x00,0x0F,0xF8,0x00,0x1F,0xF8,0x00,0x1F,0xF0,0x00,0x3F,0xF0,0x00,0x3F,
  292. 0xE0,0x00,0x3F,0xE0,0x00,0x7F,0xE0,0x00,0x7F,0xC0,0x00,0x7F,0xC0,0x00,0xFF,0xC0,
  293. 0x00,0xFF,0x80,0x01,0xFF,0x80,0x01,0xFF,0x00,0x01,0xFF,0x00,0x03,0xFF,0x00,0x03,
  294. 0xFE,0x00,0x07,0xFE,0x00,0x07,0xFC,0x00,0x07,0xFC,0x00,0x0F,0xFC,0x00,0x0F,0xF8,
  295. 0x00,0x1F,0xF8,0x00,0x1F,0xF0,0x00,0x1F,0xF0,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00},/*"7",7*/

  296. {0x01,0xFF,0x80,0x0F,0xFF,0xF0,0x1F,0xFF,0xF8,0x3F,0xFF,0xFC,0x3F,0xE7,0xFC,0x3F,
  297. 0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,
  298. 0xFC,0x1F,0xE7,0xF8,0x1F,0xFF,0xF8,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x1F,0xFF,0xF8,
  299. 0x1F,0xE7,0xF8,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,
  300. 0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,
  301. 0xFC,0x1F,0xFF,0xF8,0x1F,0xFF,0xF8,0x0F,0xFF,0xF0,0x01,0xFF,0x80,0x00,0x00,0x00},/*"8",8*/

  302. {0x01,0xFF,0x80,0x07,0xFF,0xE0,0x1F,0xFF,0xF8,0x3F,0xFF,0xFC,0x3F,0xE7,0xFC,0x3F,
  303. 0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,
  304. 0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xFF,0xFC,0x1F,0xFF,0xFC,0x0F,0xFF,0xFC,
  305. 0x03,0xFF,0xFC,0x00,0x07,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,
  306. 0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,0xFC,0x3F,0xE7,
  307. 0xFC,0x1F,0xFF,0xF8,0x1F,0xFF,0xF8,0x0F,0xFF,0xF0,0x01,0xFF,0x80,0x00,0x00,0x00},/*"9",9*/
  308. };
  309. /*========================标记及点图片(宽度x高度=16*16)===========================*/
  310. uchar code running[7][32]={
  311.      {// 警报标记16*16
  312.           0x00,0x00,0x00,0x39,0x00,0x7B,0x00,0xFE,0x01,0xDC,0x0F,0x98,0x0F,0x18,0x0C,0x1F,
  313.       0x0C,0x1F,0x0F,0x18,0x0F,0x98,0x01,0xDC,0x00,0xFE,0x00,0x7B,0x00,0x39,0x00,0x00,},
  314.          {// 闹铃开启标记16*16
  315.           0x00,0x00,0x00,0x40,0x00,0xE0,0x01,0xB0,0x01,0xB0,0x03,0x18,0x03,0x18,0x06,0x0C,
  316.       0x0C,0x06,0x0C,0xE6,0x1B,0x1B,0x0C,0x06,0x06,0x0C,0x03,0xF8,0x00,0xE0,0x00,0x00},
  317.          {// 键盘锁标记16*16
  318.       0x00,0x00,0x01,0xF8,0x03,0xFC,0x03,0x0C,0x03,0x0C,0x03,0x0C,0x03,0xFC,0x06,0x96,
  319.       0x0E,0xA7,0x0E,0xC7,0x0E,0xA7,0x0E,0x97,0x07,0xFE,0x03,0xFC,0x01,0xF8,0x00,0x00,},
  320.          {// 温度计标记16*16
  321.           0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
  322.       0x01,0x90,0x01,0x98,0x01,0x9C,0x01,0x9E,0x01,0x9C,0x00,0x18,0x00,0x10,0x00,0x00},
  323.          {// 模式3点16*16
  324.           0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
  325.       0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
  326.          {// 模式2点16*16
  327.           0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
  328.       0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},          
  329.          {// 篮球器运行标记16*16
  330.           0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x01,0x80,0x01,0x80,0x01,0x90,
  331.       0x01,0x98,0x01,0x9C,0x01,0x9E,0x01,0x9C,0x01,0x98,0x01,0x90,0x00,0x00,0x00,0x00}};
  332. /*========================菜单按钮图片(宽度x高度=16*8)============================*/
  333. uchar code menu_key[]=
  334.          {//菜单按钮
  335.           0x7F,0xFE,0x81,0x81,0x83,0xC1,0x87,0xE1,0x8F,0xF1,0x9F,0xF9,0x80,0x01,0x7F,0xFE};
  336. /*=============================================================================
  337. 函数名称:定时器中断处理与初始化,延时
  338. 功能描述:时钟更新、篮球器计时
  339. 全局变量:time_tick、time_tick1、resu[2]、resu[3]、resu[4]、temp_delay、temp_min
  340. 参数说明:无
  341. 返回说明:t0_isr(中断标记)、b20time(温度更新标记)
  342. 设 计 人:LIJH
  343. 版    本:1.0
  344. 说    明:
  345. =============================================================================*/
  346. /*延时1us(一次10个机器周期不等) 参数格式:延时数*/
  347. void delay(unsigned int det)
  348. {
  349.   while(det--)
  350.    {
  351.    _nop_();
  352.    }
  353. }
  354. /*1s延时*/
  355. void delay_pw()
  356. {
  357.   delay(50000);
  358.   delay(50000);
  359. }
  360. /*6个周期  6us */
  361. void  delay_b20(uchar n)
  362. {  
  363.   while(n--)
  364.   {
  365.   _nop_();

  366.   }
  367.   
  368. }
  369. /************主时钟中断处理*********/
  370. void time0_isr(void) interrupt 1
  371. {
  372.   TR0=0;
  373.   TL0=(time_count&0x00FF);
  374.   TH0=(time_count>>8);
  375.   TR0=1;
  376.   if(--time_tick)  return;
  377.   time_tick=20;
  378.   t0_isr=1;
  379.   if(nba_tim&!oth_run)           // 当在篮球器界面时 nba_tim==1、oth_run==0
  380.   {
  381.     if(resu[3]==0)
  382.         {
  383.           resu[3]=59;
  384.           if(resu[2]>0)        resu[2]--;
  385.         }
  386.         else resu[3]--;
  387.         if(resu[2]==0&resu[3]==0)  // 比赛时间到后停止
  388.         {
  389.           TR0=0;TR1=0;EA=0;
  390.         }
  391.         return;
  392.   }
  393.   if((++temp_min)==1)          // 实现温度的更新
  394.   {
  395.     temp_min=0;
  396.     temp_delay--;
  397.         if(temp_delay==0)
  398.     {
  399.           b20time=1;temp_delay=1;
  400.         }
  401.   }       
  402. }
  403. /*************24时钟中断处理**********/
  404. void time1_isr(void) interrupt 2
  405. {
  406.   TR1=0;
  407.   TL1=(time_count&0x00FF);
  408.   TH1=(time_count>>8);
  409.   TR1=1;
  410.   if(--time_tick1) return;
  411.   time_tick1=20;
  412.   if(resu[4]>0)resu[4]--;          //  篮球器24秒中断
  413.   t0_isr=1;
  414.   if(resu[4]==0)
  415.   { TR0=0;TR1=0;EA=0;}
  416. }
  417. /****************定时器初始化***********/
  418. void time_init()                       
  419. {
  420.   EA=0;
  421.   TR0=0;
  422.   TR1=0;
  423.   TMOD=0x01;

  424.   TL0=(time_count&0x00FF);
  425.   TH0=(time_count>>8);
  426.   TL1=(time_count&0x00FF);
  427.   TH1=(time_count>>8);
  428.   IE=0;
  429.   ET0=1;
  430.   ET1=1;
  431. }
  432. /*=============================================================================
  433. 函数名称:LCD驱动
  434. 功能描述:基本驱动(写1个字节、清屏、初始化)
  435. 全局变量:无
  436. 参数说明:dat_comm(0:命令 1:数据),content(数值)
  437. 返回说明:无返回值
  438. 设 计 人:LIJH
  439. 版    本:1.0
  440. 说    明:
  441. =============================================================================*/
  442. /******************************************检查忙碌位*******************************************/
  443. void chk_busy (void)

  444. {
  445.           unsigned char temp=0;
  446.         lcd_data=0xff;                  //做输入先置高,12c系列单片机需转换端口模式
  447.           do
  448.         {        
  449.         lcd_rs=0;
  450.         lcd_rw=1;
  451.         lcd_e=1;
  452.                 _nop_();
  453.                 _nop_();
  454.         temp=lcd_data;
  455.         lcd_e=0;
  456.     }
  457.         while((temp&0x80)!=0);              //高位忙标志BF,BF=1表示:忙
  458. }
  459. /*********************写LCD 参数格式:0:命令,1:数值 ,数据*****************************/
  460. void wr_lcd (uchar dat_comm,uchar content)
  461. {
  462.   chk_busy ();
  463.   lcd_rs=dat_comm;
  464.   lcd_rw = 0;         // 写
  465.   lcd_data=content;   // 输出数据或命令
  466.   _nop_();
  467.   _nop_();
  468.   lcd_e=1;
  469.   lcd_e=0;
  470. }
  471. /*****************************清绘图*****************************/
  472. void clrgdram(void)
  473. {
  474.   uchar i,j;
  475.   for(j=0;j<32;j++)
  476.   {
  477.     wr_lcd(comm,0x34);
  478.     wr_lcd(comm,0x80+j);
  479.     wr_lcd(comm,0x80);
  480.     wr_lcd(comm,0x30);
  481.     for(i=0;i<32;i++)
  482.       wr_lcd(dat,0x00);  // 写入0x00
  483.    }
  484.   wr_lcd(comm,0x36);
  485. }
  486. /**************************清除显示*************************/
  487. void clear_dis(void)
  488. {
  489.   delay(20000);
  490.   wr_lcd(comm,0x30);
  491.   wr_lcd(comm,0x01);  // 清屏,地址指针指向00H
  492.   clrgdram();                  // 请绘图RAM

  493. }
  494. /*************************开机LCD初始化******************/
  495. void init_lcd (void)
  496. {
  497.   delay(20000);
  498.   wr_lcd(comm,0x30);  // 30---基本指令动作  
  499.   wr_lcd(comm,0x06);  // 光标的移动方向
  500.   wr_lcd(comm,0x0c);  // 开显示,关游标
  501.   clear_dis();
  502. }
  503. /*=============================================================================*
  504. 函数名称:DS1302驱动
  505. 功能描述:基本驱动(读写数据、读写日期,时间、初始化)
  506. 全局变量:无
  507. 参数说明:w_adder(写地址),r_adder(读地址),w_data(写入数据)
  508. 返回说明:返回读取的数据
  509. 设 计 人:LIJH
  510. 版    本:1.0
  511. 说    明:上升沿写入数值,下降沿读出数值,没用设立后背电池充电
  512. =============================================================================*/
  513. /**********************向1302写数据 参数格式:地址,数据********************/
  514. void w1302(uchar w_adder,uchar w_data)
  515. {
  516.   uchar d;
  517.   ret_ds1302();
  518.   for(d=0;d<16;d++)
  519.   {
  520.     if(d==8) w_adder=w_data;
  521.         d02_data=(bit)(w_adder&0x01);
  522.     d02_sclk=0;                 // 上升沿
  523.     w_adder>>=1;
  524.     d02_sclk=1;
  525.   }
  526.   end_ds1302();   
  527. }
  528. /******************接收1302一个字节的数据 参数格式:读地址*******************/
  529. uchar r1302(uchar r_adder)
  530. {
  531.   uchar d=0;
  532.   ret_ds1302();
  533.   for(d=0;d<8;d++)         // 写地址
  534.   {
  535.     d02_data=(bit)(r_adder&0x01);
  536.     d02_sclk=0;
  537.     r_adder>>=1;
  538.     d02_sclk=1;
  539.   }
  540.   r_adder=0;
  541.   for(d=0;d<8;d++)         // 读数据
  542.   {
  543.         d02_data=1;
  544.         d02_sclk=1;                 // 下降沿
  545.         r_adder>>=1;
  546.         d02_sclk=0;
  547.         if(d02_data) r_adder|=0x80;
  548.   }
  549.   end_ds1302();
  550.   return(r_adder);
  551. }
  552. /*******************写入时间与日期************************/
  553. void wds1302_time_date(void)
  554. {
  555.   w1302(d02_wrc,0x00);                            // 写允许
  556.   w1302(0x90,0xa5);                  // 单二极管2K电阻充电
  557.   w1302(d02_year,today.year);            // 年
  558.   w1302(d02_weeks,today.week);           // 星期
  559.   w1302(d02_month,today.month);            // 月
  560.   w1302(d02_day,today.day);                    // 日
  561.   w1302(d02_hour,0x7f&now.hour);            // 时
  562.   w1302(d02_minute,now.minute);            // 分
  563.   w1302(d02_second,0x7f&now.second); // 秒
  564.   w1302(d02_wrc,0x80);                                  // 写禁止
  565. }
  566. /************************初始化写DS1302 RAM**********************/
  567. void init_wds1302_ram(void)
  568. {
  569.   w1302(d02_wrc,0x00);
  570.   w1302(0x90,0xa5);         // 单二极管2K电阻充电
  571.   w1302(d02_signs,0x00);           // 状态寄存
  572.   w1302(d02_passw,0x74);           // 密码储存首位
  573.   w1302(d02_passw+2,0x14);  // 初始值为:741456
  574.   w1302(d02_passw+4,0x56);  // 密码最后一位
  575.   w1302(d02_alm,0x12);           // 闹铃时(12小时)
  576.   w1302(d02_alm+2,0x00);           // 闹铃分(0分)
  577.   w1302(d02_temp,0xff);           // 温度上限(255为关闭)          
  578.   w1302(d02_temp+2,0xff);   // 温度下限(关闭)
  579.   w1302(d02_initsi,0xb4);   // 是否要初始化标记(0xb4为已经初始化)
  580.   w1302(d02_wrc,0x80);
  581. }
  582. /*******************写DS1302一字节的RAM***********************/
  583. void wds1302_data(uchar adder,uchar _data)
  584. {
  585.   w1302(d02_wrc,0x00);
  586.   w1302(adder,_data);
  587.   w1302(d02_wrc,0x80);
  588. }
  589. /**************************读取日期***************/
  590. void rds1302_date(void)
  591. {
  592.   today.year=r1302(d02_year+1);          
  593.   today.week=r1302(d02_weeks+1);
  594.   today.month=r1302(d02_month+1);
  595.   today.day=r1302(d02_day+1);  
  596. }
  597. /*****************读取时间*****************/
  598. void rds1302_time(void)
  599. {
  600.   now.hour=(r1302(d02_hour+1));
  601.   now.minute=r1302(d02_minute+1);
  602.   now.second=r1302(d02_second+1);
  603.   if(now.hour==alarm_time[0]&&now.minute==alarm_time[1]) alm_run=1;
  604.   else                                                                                 // 闹铃时间比较
  605.   {
  606.     alm_run=0;buzstop=0;buzzer=close;
  607.   }
  608. }                                       
  609. /**********************开机读数据*******************/
  610. void rds1302_data(void)
  611. {
  612.   signs=r1302(d02_signs+1);
  613.   alarm_time[0]=r1302(d02_alm+1);
  614.   alarm_time[1]=r1302(d02_alm+3);
  615.   als_temp[0]=r1302(d02_temp+1);
  616.   als_temp[1]=r1302(d02_temp+3);                  
  617. }
  618. /***************************DS1302初始化**********************/
  619. void init_ds1302(void)
  620. {
  621.   wds1302_time_date();
  622.   init_wds1302_ram();
  623. }
  624. /*=============================================================================*
  625. 函数名称:DS18b20驱动
  626. 功能描述:基本驱动(读写数据、数据转换、初始化)
  627. 全局变量:无
  628. 参数说明:无
  629. 返回说明:返回读取的数据
  630. 设 计 人:LIJH
  631. 版    本:1.0
  632. 说    明:调试中。。。
  633. =============================================================================*/
  634. /*****************18B20初始化**********************/
  635. void init_ds18b20()
  636. {
  637.   b20_io=1;
  638.   delay_b20(1);
  639.   b20_io=0;
  640.   delay_b20(500);                // 延时≥480us
  641.   b20_io=1;
  642.   delay_b20(60);            // 拉高为高电平后在15—60us出现低电平,并维持60—240us
  643.   ds18b20=~b20_io;
  644.   delay_b20(500);       
  645. }
  646. /******************向18B20发送一个字节****************/
  647. void send18b20_byte(uchar data_send)
  648. {
  649.   uchar d=0;
  650.   for (d=0;d<8;d++)
  651.   {
  652.         b20_io=0;       
  653.                                 // 拉低电平后向总线写入一个位,15us后18B20接收
  654.    delay_b20(1);       
  655.     b20_io=data_send&0x01;            
  656.     delay_b20(60);                                // 延时60us后完成一次
  657.     b20_io=1;
  658.         delay_b20(1);
  659.     data_send>>=1;                            // 下位开始
  660.    delay_b20(1);
  661.   }
  662. }
  663. /**********************从18B20读出温度值 12位分辨率********************/  
  664. void receive18b20(void)
  665. {
  666.   uchar n=1,d;
  667.   for (d=0;d<16;d++)
  668.   {
  669.         if(d==8) n=0;
  670.         b20_io=0;
  671.         delay_b20(1);                                          // 拉低总线
  672.         temp.t_data[n]>>=1;            
  673.         b20_io=1;
  674.         delay_b20(1);                    // 拉高总线
  675.         if(b20_io)                                          // 读入总线数值
  676.       temp.t_data[n]|=0x80;
  677.     delay_b20(60);                                  // 等待60us
  678.   }
  679. }
  680. /*************************数据转化************************/
  681. void conversion_t(void)
  682. {
  683.   uchar save=0,save1=0;
  684.   if(temp.temp_data<0)                  // 判断数值符号
  685.     {temp_pn=1;temp.temp_data=~temp.temp_data+1;}
  686.   else temp_pn=0;
  687.   if(temp.t_data[1]&0x01==1) save+=6;            // 小数点后的值转变
  688.   if((temp.t_data[1]>>1)&0x01==1) save+=12;
  689.   if((temp.t_data[1]>>2)&0x01==1) save+=25;
  690.   if((temp.t_data[1]>>3)&0x01==1) save+=50;
  691.   temp.temp_data>>=4;
  692.   save1=temp.temp_data&0x00ff;                                // 整数部分数值
  693.   temp.t_data[0]=save1;
  694.   temp.t_data[1]=save;
  695.   thl_als=1;
  696.   if(save1>=(als_temp[0]&0x7f))      // 温度比较
  697.   {
  698.         if(!temp_pn||(temp_pn&(als_temp[0]&0x80)!=0)){ als_th=open;als_tl=close;}
  699.   }
  700.   else if(save1<(als_temp[1]&0x7f)&&als_temp[1]!=255)
  701.   {
  702.     if(!temp_pn||(temp_pn&(als_temp[1]&0x80)!=0)) {als_tl=open;als_th=close;}
  703.   }
  704.   else {als_th=als_tl=close;thl_als=0;buzstop=0;buzzer=close;}
  705. }
  706. /********************18b20功能*******************/
  707. void ds18b20_func(void)
  708. {
  709.   EA=0;
  710.   TR0=0;
  711.   temp.temp_data=0;
  712.   init_ds18b20();
  713.   send18b20_byte(0xcc); // 跳过ROM
  714.   send18b20_byte(0x44); // 温度转换
  715.   delay_pw();
  716.   init_ds18b20();
  717.   send18b20_byte(0xcc);
  718.   send18b20_byte(0xbe); // 读RAM
  719.   receive18b20();                // 读取温度值
  720.   conversion_t();                // 数值转换
  721.   EA=1;
  722.   TR0=1;
  723. }
  724. /*=============================================================================
  725. 函数名称:画面构造
  726. 功能描述:界面1、2、3,图片菜单,反白,标头,16*16(32)图片
  727. 全局变量:无
  728. 参数说明:函数说明
  729. 返回说明:无
  730. 设 计 人:LIJH
  731. 版    本:1.0
  732. 说    明:X坐标每一格每次16点
  733. =============================================================================*/
  734. /*反白或显示图片 参数格式:(H)8bit数据,(L)8bit数据,X0坐标(16bit),Y0坐标(1bit),X坐标(16bit),Y坐标(1bit)*/
  735. void con_disp (uchar data1,uchar data2,uchar x0,uchar y0,uchar xl,uchar yl)
  736. {
  737.   uchar i,j;
  738.   for(j=0;j<yl;j++)
  739.   {
  740.     for(i=0;i<xl;i++)
  741.     {
  742.       wr_lcd(comm,0x34);     // 扩展功能
  743.       wr_lcd(comm,y0+j);         // 写Y坐标
  744.       wr_lcd(comm,x0+i);         // 写X坐标
  745.       wr_lcd(comm,0x30);         // 普通功能
  746.       wr_lcd(dat,data1);
  747.       wr_lcd(dat,data2);
  748.     }
  749.   }
  750.   wr_lcd(comm,0x36);                 // 开绘图显示
  751. }
  752. /*************显示字体 参数格式: 显示位置(0x80-0x9f),显示个数,显示内容指针********************/
  753. void display_cnasc(uchar dis_bit,uchar num,uchar *cnasc)
  754. {
  755.   wr_lcd(comm,0x30);             // 普通功能
  756.   wr_lcd(comm,dis_bit);             // 写地址
  757.   while(num>0)
  758.   {
  759.     wr_lcd(dat,*(cnasc++));
  760.     wr_lcd(dat,*(cnasc++));
  761.         num--;
  762.   }
  763. }
  764. /****************导航标头显示****************/
  765. void dis_title(void)
  766. {
  767.   display_cnasc(0x80,1,"\x15 ");
  768.   display_cnasc(0x90,1,"┏");
  769.   display_cnasc(0x97,1,"┓");
  770.   display_cnasc(0x98,1,"┗");
  771.   display_cnasc(0x9f,1,"┛");
  772.   display_cnasc(0x92,1,"\x1e ");
  773.   display_cnasc(0x9a,1,"\x1f ");
  774.   con_disp(0xff,0xff,0x80,0x80,3,16);
  775.   con_disp(0xef,0xef,0x83,0x80,1,16);
  776.   con_disp(0xde,0xf7,0x84,0x80,1,16);
  777.   con_disp(0x76,0xdb,0x85,0x80,1,16);
  778.   con_disp(0x55,0x55,0x86,0x80,1,16);
  779.   con_disp(0x55,0x55,0x87,0x80,1,16);       
  780. }
  781. /*********************图片显示标头*********************/
  782. void dis_title_pic(void)
  783. {
  784.   display_cnasc(0x80,2,"〓〓");
  785.   display_cnasc(0x86,2,"〓〓");
  786. }

  787. /*****************************功能实现显示标头*****************/
  788. void dis_title_e(void)
  789. {
  790.   display_cnasc(0x80,1," \x15");
  791.   con_disp(0xff,0xff,0x80,0x80,1,16);
  792.   con_disp(0xff,0xc7,0x81,0x80,1,16);
  793.   con_disp(0xff,0xff,0x82,0x80,3,16);
  794.   con_disp(0xe3,0xff,0x85,0x80,1,16);
  795.   con_disp(0xff,0xff,0x86,0x80,2,16);
  796. }
  797. /*******************显示菜单图片  格式:图片反显(1)或正常显示(0),显示图片的号码****************/
  798. void anti_nor_pic (uchar cpl_sign,uchar menu_num)
  799. {
  800.   uchar i,j,x,y;
  801.   x=menu_num*3;           // 计算图片显示坐标
  802.   if(x>6) x--;
  803.   if(menu_num<3) y=16;        // 上下半屏显示
  804.   else y=8;
  805.   if(cpl_sign==1) display_cnasc(0x82,4,menu_cn[menu_num]);
  806.   for(j=0;j<24;j++)
  807.   {
  808.    for(i=0;i<2;i++)
  809.    {
  810.      wr_lcd(comm,0x34);
  811.      wr_lcd(comm,0x80+y);
  812.      wr_lcd(comm,0x80+x+i);  // 分两次显示 16bit
  813.      wr_lcd(comm,0x30);
  814.      if(cpl_sign==1)              // 图片反选
  815.      {
  816.            wr_lcd(dat,~menu_pic[menu_num][j*4+i*2]);
  817.        wr_lcd(dat,~menu_pic[menu_num][j*4+i*2+1]);
  818.          }
  819.      else                                          // 正常显示
  820.      {
  821.            wr_lcd(dat,menu_pic[menu_num][j*4+i*2]);
  822.        wr_lcd(dat,menu_pic[menu_num][j*4+i*2+1]);
  823.          }
  824.    }
  825.    y++;
  826.    if(y==32&&menu_num<3) {x+=8;y=0;}  // 上下屏切换
  827.   }
  828.   wr_lcd(comm,0x36);
  829. }

  830. /*************状态16*16图片  格式:反色(1)或正常0,X坐标,Y坐标,状态编码(16*16)*********************/
  831. void dis_run_state(uchar cpl,uchar x0,uchar y0,uchar state_num)
  832. {
  833.   uchar j;
  834.   for(j=0;j<16;j++)
  835.   {
  836.     wr_lcd(comm,0x34);  // 扩展功能
  837.     wr_lcd(comm,y0++);        // 写Y地址
  838.     wr_lcd(comm,x0);        // 写X地址
  839.     wr_lcd(comm,0x30);        // 普通功能
  840.         if(cpl==1)                        // 写数据
  841.     {
  842.           wr_lcd(dat,~running[state_num][j*2]);
  843.       wr_lcd(dat,~running[state_num][j*2+1]);
  844.         }
  845.         else
  846.         {
  847.           wr_lcd(dat,running[state_num][j*2]);
  848.       wr_lcd(dat,running[state_num][j*2+1]);
  849.         }
  850.   }
  851.   wr_lcd(comm,0x36);
  852. }
  853. /***************显示菜单按钮  参数格式:反色(1)或正常(0)**************************/
  854. void dis_menu_key(uchar d)
  855. {
  856.   if(d==1)
  857.   {
  858.     for(d=0;d<8;d++)                                                                  // 显示菜单按钮
  859.       con_disp(~menu_key[d*2],~menu_key[d*2+1],0x9f,0x97+d,1,1);
  860.   }
  861.   else
  862.   {
  863.     for(d=0;d<8;d++)                                                                  // 显示菜单按钮
  864.       con_disp(menu_key[d*2],menu_key[d*2+1],0x9f,0x97+d,1,1);
  865.   }
  866. }
  867. /********************显示模式3的界面**********************/
  868. void dis_mode3(void)
  869. {
  870.   uchar i,j,h,l,x_0=0x80,y_0=0x90;
  871.   h=now.hour>>4;       // 分离十位 个位
  872.   l=now.hour&0x0f;
  873.   for(j=0;j<2;j++)
  874.   {
  875.     for(i=0;i<32;i++)  // 十位个位一起读入
  876.     {
  877.       wr_lcd(comm,0x34);
  878.       wr_lcd(comm,y_0++);
  879.       wr_lcd(comm,x_0);
  880.       wr_lcd(comm,0x30);
  881.       wr_lcd(dat,mode_3num[h][i*3]);  // 连续写数据,X坐标自动加1
  882.       wr_lcd(dat,mode_3num[h][i*3+1]);
  883.       wr_lcd(dat,mode_3num[h][i*3+2]);
  884.       wr_lcd(dat,mode_3num[l][i*3]);
  885.       wr_lcd(dat,mode_3num[l][i*3+1]);
  886.       wr_lcd(dat,mode_3num[l][i*3+2]);
  887.       if(y_0==0xa0){x_0=x_0+8;y_0=0x80;}
  888.     }
  889.     x_0=0x84,y_0=0x90;
  890.     h=now.minute>>4;   // 分离十位 个位
  891.     l=now.minute&0x0f;
  892.   }
  893.   dis_run_state(0,0x83,0x90,4); // 显示点
  894.   dis_run_state(0,0x8b,0x80,4);                                          
  895.   y_0=0x80;                           // 显示状态标记
  896.   if(keb) {dis_run_state(0,0x87,y_0,2);y_0+=16;}
  897.   if(alm) {dis_run_state(0,0x87,y_0,1);y_0+=16;}
  898.   if(y_0<0xa0&&!als){dis_run_state(0,0x87,y_0,0);}
  899.   if(y_0==0xa0&&!als){dis_run_state(0,0x8f,0x80,0);}
  900.   dis_menu_key(0);
  901. }
  902. /**********************显示模式1和2的共用部分*****************/
  903. void mode1_2_union(void)
  904. {
  905.   uchar x=0x9b;
  906.   display_cnasc(0x98,2,"星期");
  907.   if(nba_tim) dis_run_state(0,x,0x90,6);
  908.   if(keb) {dis_run_state(0,x,0x90,2);x++;}    // 显示标记
  909.   if(alm) {dis_run_state(0,x,0x90,1);x++;}
  910.   if(!als){dis_run_state(0,x,0x90,0);}
  911.   dis_menu_key(0);                           // 显示菜单按钮
  912. }
  913. /*******************显示模式2的日期**********************/
  914. void dis_date_mode2(uchar d)
  915. {
  916.   uchar save[2];
  917.   display_cnasc(d+2,1,"年");
  918.   display_cnasc(d+4,1,"月");
  919.   display_cnasc(d+6,1,"日");
  920.   display_cnasc(0x9a,1,weeks[today.week]);  // 显示星期
  921.   save[0]=char_num[today.year>>4];                // 将显示的数值存到数组中
  922.   save[1]=char_num[today.year&0x0f];
  923.   display_cnasc(d+1,1,save);
  924.   save[0]=char_num[today.month>>4];
  925.   save[1]=char_num[today.month&0x0f];
  926.   display_cnasc(d+3,1,save);
  927.   save[0]=char_num[today.day>>4];
  928.   save[1]=char_num[today.day&0x0f];
  929.   display_cnasc(d+5,1,save);
  930. }
  931. /*****************显示模式2的时间数字显示  16*32******************/
  932. void num2_asc_dis(uchar num,uchar x_0)
  933. {
  934.   uchar i,y_0=0x90;
  935.   for(i=0;i<32;i++)  // 十位个位一起读入
  936.   {
  937.     wr_lcd(comm,0x36);
  938.     wr_lcd(comm,y_0++);
  939.     wr_lcd(comm,x_0);
  940.     wr_lcd(comm,0x30);
  941.     wr_lcd(dat,mode_2num[num][i*2]);
  942.     wr_lcd(dat,mode_2num[num][i*2+1]);
  943.         if(i==15){x_0+=8;y_0=0x80;}
  944.   }
  945.   wr_lcd(comm,0x36);
  946. }
  947. /****************显示模式2的时间*******************/
  948. void dis_time_mode2(void)
  949. {
  950.   uchar h,l;
  951.   if(now.hour!=save_time.hour||init_d2)
  952.   {
  953.     h=now.hour>>4;    // 分离十位 个位
  954.     l=now.hour&0x0f;
  955.     num2_asc_dis(h,0x80);
  956.         num2_asc_dis(l,0x80+1);
  957.   }
  958.   if(now.minute!=save_time.minute||init_d2)
  959.   {
  960.     h=now.minute>>4;    // 分离十位 个位
  961.     l=now.minute&0x0f;
  962.     num2_asc_dis(h,0x83);
  963.         num2_asc_dis(l,0x83+1);
  964.   }
  965.   if(now.second!=save_time.second||init_d2)
  966.   {
  967.     h=now.second>>4;    // 分离十位 个位
  968.     l=now.second&0x0f;
  969.     num2_asc_dis(h,0x86);
  970.         num2_asc_dis(l,0x86+1);
  971.   }
  972.   if(init_d2)
  973.   {
  974.     dis_run_state(0,0x82,0x90,5); // 显示点
  975.     dis_run_state(0,0x8a,0x80,5);
  976.     dis_run_state(0,0x85,0x90,5); // 显示点
  977.     dis_run_state(0,0x8d,0x80,5);
  978.   }       
  979. }
  980. /*********************显示模式2的界面*********************/
  981. void dis_mode2(void)
  982. {
  983.   dis_date_mode2(0x81);              // 显示日期
  984.   display_cnasc(0x81,1,"20");
  985.   dis_time_mode2();                          // 显示时间
  986.   mode1_2_union();
  987. }
  988. /*********************显示模式1的日期*****************/
  989. void dis_date_mode1(void)
  990. {
  991.   uchar save[2];
  992.   display_cnasc(0x80,3,"日期:");
  993.   display_cnasc(0x90,3,"时间:");
  994.   display_cnasc(0x88,3,"温度:");
  995.   display_cnasc(0x9a,1,weeks[today.week]);  // 显示星期
  996. //  display_cnasc(0x83,1,"20");
  997.   save[0]=char_num[today.year>>4];                          
  998.   save[1]=char_num[today.year&0x0f];
  999.   display_cnasc(0x83,1,save);
  1000.   save[0]='/';
  1001.   save[1]=char_num[today.month>>4];
  1002.   display_cnasc(0x84,1,save);
  1003.   save[0]=char_num[today.month&0x0f];
  1004.   save[1]='/';
  1005.   display_cnasc(0x85,1,save);
  1006.   save[0]=char_num[today.day>>4];
  1007.   save[1]=char_num[today.day&0x0f];
  1008.   display_cnasc(0x86,1,save);
  1009.   mode1_2_union();
  1010. }
  1011. /*********************显示模式1的时间*****************/
  1012. void dis_time_mode1(void)
  1013. {
  1014.   uchar save[2];
  1015.   save[0]=char_num[now.hour>>4];
  1016.   save[1]=char_num[now.hour&0x0f];
  1017.   display_cnasc(0x93,1,save);
  1018.   save[0]=':';
  1019.   save[1]=char_num[now.minute>>4];
  1020.   display_cnasc(0x94,1,save);
  1021.   save[0]=char_num[now.minute&0x0f];
  1022.   save[1]=':';
  1023.   display_cnasc(0x95,1,save);
  1024.   save[0]=char_num[now.second>>4];
  1025.   save[1]=char_num[now.second&0x0f];
  1026.   display_cnasc(0x96,1,save);
  1027. }
  1028. /*************************显示模式1的温度********************/
  1029. void dis_temp_mode1(void)
  1030. {
  1031.   uchar save[2];
  1032.   if(ds18b20)
  1033.   {
  1034.          if(temp.t_data[0]>99)
  1035.          {
  1036.             save[0]=char_num[temp.t_data[0]/100];
  1037.                 save[1]=char_num[(temp.t_data[0]/10)%10];
  1038.                 display_cnasc(0x8b,1,save);
  1039.                 save[0]=char_num[temp.t_data[0]%10];
  1040.                 save[1]='.';
  1041.                 display_cnasc(0x8c,1,save);
  1042.                 save[0]=char_num[temp.t_data[1]/10];
  1043.                 save[1]=' ';
  1044.                 display_cnasc(0x8d,1,save);
  1045.                 display_cnasc(0x8e,1,"℃");
  1046.           }
  1047.           else
  1048.           {
  1049.         if(temp_pn) display_cnasc(0x8a,1,":-");
  1050.             else  display_cnasc(0x8a,1,":");
  1051.                 save[0]=char_num[temp.t_data[0]/10];
  1052.                 save[1]=char_num[temp.t_data[0]%10];
  1053.                 display_cnasc(0x8b,1,save);
  1054.                 save[0]='.';
  1055.                 save[1]=char_num[temp.t_data[1]/10];
  1056.                 display_cnasc(0x8c,1,save);
  1057.                 display_cnasc(0x8d,1,"℃");
  1058.           }
  1059.         }
  1060.   else display_cnasc(0x8b,3,"FF.F℃");
  1061. }
  1062. /********************显示模式1的界面*****************/
  1063. void dis_mode1(void)
  1064. {
  1065.   dis_date_mode1();
  1066.   dis_time_mode1();
  1067.   dis_temp_mode1();
  1068. }
  1069. /******************篮球器时间显示*****************/
  1070. void nba_dis_time(void)
  1071. {
  1072.   uchar d,dis[2];
  1073.   for(d=2;d<4;d++)
  1074.   {
  1075.         dis[0]=char_num[resu[d]/10];
  1076.         dis[1]=char_num[resu[d]%10];
  1077.         display_cnasc(0x81+d*2,1,dis);
  1078.   }
  1079.   display_cnasc(0x86,1,": ");
  1080.   if(resu[0]==1)
  1081.   {
  1082.         dis[0]='\x07';
  1083.         dis[1]=char_num[resu[4]/10];
  1084.         display_cnasc(0x93,1,dis);
  1085.         dis[1]='\x07';
  1086.         dis[0]=char_num[resu[4]%10];
  1087.         display_cnasc(0x94,1,dis);
  1088.   }
  1089. }
  1090. /*=============================================================================
  1091. 函数名称:键盘扫描
  1092. 功能描述:读取键盘操作数据及部分状态的实现
  1093. 全局变量:dis_sig  t0_isr  temprun  b20time  alm_run als_temp         buzstop  als
  1094.            lock_op  nba_tim
  1095. 参数说明:无
  1096. 返回说明:键盘锁与密码锁时间到达后返回 255
  1097. 设 计 人:LIJH
  1098. 版    本:1.0
  1099. 说    明:
  1100. =============================================================================*/
  1101. /******************扫描键盘*******************/
  1102. uchar  keypad_scan()
  1103. {
  1104.   uchar key,dis[2];
  1105.   keyboard=0xf0;
  1106.   while (keyboard==0xf0)     // 等待按键按下
  1107.   {         
  1108.   /*--------------------- 背光灯关闭延时 -----------------------*/
  1109.         delay(6000);                                      
  1110.         if((++dis[0])==0&&bl_delay!=0) bl_delay--;  // 当有按键按下bl_delay重新赋值        
  1111.         if(bl_delay==0&&!bl0) lcd_bl=close;         // 背光时间到且不是常开模式时关闭背光
  1112.   /*----------------------- 键盘锁延时 -------------------------*/       
  1113.         if(keb&&dis_sig&&bl_delay==0&&resu[11]<2) resu[11]++; // 当有按键按下j清零
  1114.         if(bl_delay==0) bl_delay=15;
  1115.   /*--------------------- 密码锁30秒锁延时 ---------------------*/               
  1116.         if(lock_op)                                        
  1117.         {
  1118.           if((++i)==0) save1++;                 
  1119.           if(save1==15) return(255);
  1120.         }
  1121.   /*---------------------- 时钟界面时间显示 ---------------------*/
  1122.        
  1123.         if(dis_sig&&t0_isr||nba_tim&&oth_run)     // 正常时钟界面与篮球器返回时钟界面显示
  1124.     {   
  1125.           rds1302_date();            // 读出日期
  1126.       rds1302_time();                // 读出时间
  1127.           if(di0)                     // 模式2
  1128.           {
  1129.             dis_time_mode2();
  1130.                 if(now.hour==0&&now.minute==0&&now.second==0)        dis_date_mode2(0x81);
  1131.           }
  1132.       else if(di1)                         // 模式3
  1133.           {
  1134.             if(now.hour!=save_time.hour||now.minute!=save_time.minute)   // 时,分变化后显示
  1135.               dis_mode3();          
  1136.       }
  1137.       else
  1138.           {
  1139.             dis_time_mode1();   // 模式1
  1140.             if(now.hour==0&&now.minute==0&&now.second==0) dis_date_mode1();
  1141.           }
  1142.           save_time=now;        // 重新记录作下次比较
  1143.           t0_isr=0;
  1144.         }
  1145.   /*-------------------- 温度计提示按键操作 ----------------------*/
  1146.         if(temprun)
  1147.         {
  1148.           if(!oth_run)
  1149.           {
  1150.             display_cnasc(0x96,2," key");    // 温度计时提示按键操作
  1151.                 for(dis[1]=0;dis[1]<200;dis[1]++)
  1152.             {
  1153.               delay(5000);
  1154.                   if(keyboard!=0xf0)
  1155.                   {
  1156.                     keyboard=0x7f;
  1157.                         if(keyboard==0x7d) return 0x7d;
  1158.                         else  keyboard=0xf0;
  1159.                   }
  1160.             }
  1161.                 oth_run=1;
  1162.                 display_cnasc(0x96,2,"    ");
  1163.           }
  1164.         }
  1165.    /*------------------------ 蜂鸣器警报 --------------------------*/
  1166.         if(((alm_run&&alm)||thl_als)&&!buzstop)        // 温度,闹铃蜂鸣器警报
  1167.         {                                                                            // 有按键按下时停止
  1168.           if(now.second==0)        lcd_bl=close;
  1169.           delay(90000);                                                        // 读出温度时间比较
  1170.           if(keyboard!=0xf0) break;
  1171.           delay(90000);
  1172.           if(keyboard!=0xf0) break;
  1173.           delay(90000);
  1174.           if(keyboard!=0xf0) break;
  1175.           delay(90000);
  1176.           if(alm_run)  lcd_bl=!lcd_bl;                        // 只在闹铃功能闪
  1177.           if(!als)buzzer=!buzzer;               // 警报开启后蜂鸣器开启                            
  1178.         }
  1179.   /*----------------------- 温度刷新显示 -------------------------*/       
  1180.         if((temprun&&oth_run)||(b20time&&!di0&&!di1&&dis_sig))    // 温度计功能于模式1界面
  1181.     {  
  1182.             ds18b20_func();                                                  // 温度检测功能
  1183.                 oth_run=0;                                    // 作交替标记用
  1184.             if(temprun) return 20;                              // 温度计开启后返回
  1185.             if(b20time)
  1186.                 {
  1187.                  dis_temp_mode1();b20time=0;
  1188.                  } // 时钟界面5分钟更新一次,T0计时
  1189.     }  
  1190.    /*------------------------ 篮球器显示时间 ------------------------*/
  1191.        
  1192.         if(nba_tim&!oth_run)            // 当篮球器模式下 oth_run==0为篮球器计时状态
  1193.         {
  1194.           if(EA) display_cnasc(0x8b,2," R\x10 ");  // 显示运行状态
  1195.           else  display_cnasc(0x8b,2," S! ");
  1196.           if(t0_isr)
  1197.           {                                                                                   // 更新时间
  1198.             nba_dis_time();
  1199.                 if(resu[2]==0&&resu[3]==0)                           // 判断比赛情况
  1200.                 {
  1201.                   resu[6]++;
  1202.                   if(resu[6]<resu[1])  display_cnasc(0x85,3,"休息  ");
  1203.                   else  display_cnasc(0x85,3,"完结  ");
  1204.                 }
  1205.                 if(resu[4]==0||(resu[2]==0&&resu[3]==0))  // 时间到达警报
  1206.             {
  1207.                buzzer=open;
  1208.                delay_pw();
  1209.                    if(resu[2]==0&&resu[3]==0)  // 24秒 总时间警报
  1210.                    {
  1211.                      delay_pw();
  1212.                    }
  1213.                buzzer=close;
  1214.                    if(resu[4]==0) resu[4]=24;  // 重新赋值
  1215.             }
  1216.             t0_isr=0;                                           // 清零等下次中断产生
  1217.           }
  1218.         }
  1219.   }                          
  1220.                                 /*===== 以上等待按键 =====*/
  1221.   /*------------------------- 按键按下后 --------------------------*/
  1222.   delay(55000);                      // 消抖振
  1223.   if(!lock_op)bl_delay=15;   // 背光时间赋值
  1224.   if(bl1) lcd_bl=close;             // 不在背光灯关闭时亮起
  1225.   else lcd_bl=open;
  1226.   if(alm_run|thl_als) {buzstop=1;buzzer=close;}
  1227.   if(keb&&dis_sig)
  1228.   {
  1229.     if(resu[11]==2) return 255;  // 要求输入密码       
  1230.           else resu[11]=0;                         // 时间不到时重新计时
  1231.   }
  1232.   do
  1233.   {           
  1234.         for(dis[0]=0;dis[0]<=3;dis[0]++)
  1235.     {
  1236.       keyboard=ksp[dis[0]];
  1237.           if(keyboard!=ksp[dis[0]])
  1238.       {       
  1239.         key=keyboard;
  1240.         if(key!=ksp[dis[0]]) return(key);
  1241.       }
  1242.     }
  1243.   }while(1);
  1244. }
  1245. /**************读键盘数据*****************/
  1246. uchar  gotkey()
  1247. {
  1248.   uchar  save,n;
  1249.   keyboard=0xf0;
  1250.   while(keyboard!=0xf0);    // 等待键盘松开
  1251.   delay(55000);                    // 消抖阵
  1252.   if(adju_si)                     // 连写输入
  1253.   {
  1254.         adju_si=0;
  1255.         for(n=0;n<60;n++)
  1256.           {
  1257.           delay(12000);
  1258.           if(keyboard!=0xf0)
  1259.           {
  1260.             adju_si=1;          // 在更改时,在此时间内可连成多位数
  1261.             break;
  1262.           }
  1263.     }
  1264.   }                       
  1265.   save=keypad_scan();            // 扫描键盘
  1266.   if(save==255)        return 255;        // 要求输入键盘锁密码或延时时间到达
  1267.   for (n=0;n<16;n++)
  1268.   {  
  1269.         if(save==key_code[n])
  1270.            return(n);
  1271.   }
  1272.   return(20);
  1273. }
  1274. /*===========================================================================
  1275. 函数名称:导航
  1276. 功能描述:主菜单 工具导航  保存提示
  1277. 全局变量:无
  1278. 参数说明:
  1279. 返回说明:无
  1280. 设 计 人:LIJH
  1281. 版    本:1.0
  1282. 说    明:
  1283. ============================================================================*/
  1284. /************按键按下显示 参数格式:k 按钮的显示地址*************/
  1285. void key_dis(uchar k)
  1286. {
  1287.   display_cnasc(k,1,"\x04 ");
  1288.   delay(60000);
  1289.   if(k==0x92||k==0x96) display_cnasc(k,1,"\x1e ");
  1290.   else display_cnasc(k,1,"\x1f ");
  1291. }
  1292. /*******************确定按键按下显示***************/
  1293. void enter_dis(void)
  1294. {
  1295.   display_cnasc(0x8f,1," \x09");
  1296.   delay(90000);
  1297. }
  1298. /*********************主菜单导航*****************/
  1299. uchar dis_menu(void)
  1300. {
  1301.   uchar d,save,key;
  1302.   if(meu)
  1303.   {  
  1304.     display_cnasc(0x81,2,"菜单");
  1305.         dis_title();
  1306.         display_cnasc(0x88,8,selected[0]);
  1307.         con_disp(0xff,0xff,0x8a,0x80,5,16);
  1308.   }
  1309.   else          // 显示图片菜单
  1310.   {
  1311.     dis_title_pic();
  1312.         for(d=0;d<6;d++)  
  1313.       anti_nor_pic(0,d);
  1314.         anti_nor_pic(1,0);
  1315.   }      
  1316.   save=d=0;
  1317.   do
  1318.   {
  1319.         if(meu)          // 操作指示更新
  1320.         {          
  1321.           display_cnasc(0x93,3,menu_cn_2[index_m[save].left_num]);
  1322.           display_cnasc(0x8b,3,menu_cn_2[save]);
  1323.           display_cnasc(0x9b,3,menu_cn_2[index_m[save].right_num]);
  1324.     }
  1325.         else
  1326.         {
  1327.           anti_nor_pic(0,d);     
  1328.           anti_nor_pic(1,save);
  1329.         }
  1330.         d=save;                              // 保存上一索引
  1331.         while(1)
  1332.         {
  1333.           key=gotkey();
  1334.           if(key==11||(key==3&&meu))
  1335.           {
  1336.             if(meu) enter_dis();
  1337.                 break;
  1338.           }
  1339.           else if(meu)
  1340.           {
  1341.             if(key==5)
  1342.                 {
  1343.                   save=index_m[d].right_num;
  1344.                   key_dis(0x9a);
  1345.                   break;
  1346.                 }
  1347.             if(key==2)
  1348.                 {
  1349.                   save=index_m[d].left_num;
  1350.                   key_dis(0x92);
  1351.                   break;
  1352.                 }
  1353.                 if((key==1&&meu))
  1354.             {
  1355.               d=5;
  1356.                   break;
  1357.             }
  1358.           }
  1359.           else
  1360.           {
  1361.             if(key==3){save=index_m[d].right_num; break;} // 根据导航键寻找索引
  1362.             if(key==1){save=index_m[d].left_num; break;}
  1363.                 if(key==5||key==2){save=index_m[d].shaft_num; break;}  
  1364.       }
  1365.         }
  1366.         if(key==11||((key==1|key==3)&&meu)) break;
  1367.   }while(1);
  1368.   return d;
  1369. }
  1370. /****************工具导航*****************/
  1371. uchar tool_func(void)
  1372. {
  1373.   uchar save,d,key;
  1374.   display_cnasc(0x81,2,"工具");
  1375.   dis_title();
  1376.   display_cnasc(0x88,8,selected[0]);
  1377.   con_disp(0xff,0xff,0x8a,0x80,5,16);
  1378.   d=0;
  1379.   save=0;
  1380.   do
  1381.   {          
  1382.         display_cnasc(0x93,3,tool_menu[index_t[save].lnum]);
  1383.         display_cnasc(0x8b,3,tool_menu[save]);
  1384.         display_cnasc(0x9b,3,tool_menu[index_t[save].rnum]);
  1385.         d=save;
  1386.         while(1)
  1387.         {
  1388.           key=gotkey();
  1389.           if(key==1){ d=4;break;}                                // 根据按键寻找索引
  1390.           if(key==11||key==3){enter_dis();break;}
  1391.           if(key==5){save=index_t[d].rnum; key_dis(0x9a);break;}
  1392.           if(key==2){save=index_t[d].lnum; key_dis(0x92);break;}
  1393.     }
  1394.         if(key==11||key==3||key==1) break;
  1395.   }while(1);
  1396.   return d;
  1397. }
  1398. /*****************更改后提示保存*****************/
  1399. void save_y_or_n(void)
  1400. {
  1401.   uchar key;
  1402.   clear_dis();
  1403.   oth_run=0;          
  1404.   display_cnasc(0x92,5,"是否保存? ");
  1405.   display_cnasc(0x89,6,"Y(OK)\\N(./S)");
  1406.   while(1)
  1407.   {
  1408.         key=gotkey();
  1409.         if(key==11)
  1410.         {
  1411.           display_cnasc(0x9a,5,"保存成功! ");
  1412.           delay(300000);
  1413.           oth_run=1;         // 要求保存时oth_run标记为1
  1414.           return;
  1415.         }
  1416.         if(key==10) return;
  1417.   }
  1418. }
  1419. /*=============================================================================
  1420. 函数名称:调整功能
  1421. 功能描述:时间日期调整
  1422. 全局变量:today  now
  1423. 参数说明:见函数
  1424. 返回说明:无
  1425. 设 计 人:LIJH
  1426. 版    本:1.0
  1427. 说    明:
  1428. =============================================================================*/
  1429. /***************调整功能显示时间*************/
  1430. void asjust_time()
  1431. {
  1432.   uchar save[2];
  1433.   display_cnasc(0x8a,1,"时");
  1434.   display_cnasc(0x8c,1,"分");
  1435.   display_cnasc(0x8e,1,"秒");
  1436.   save[0]=char_num[now.hour>>4];
  1437.   save[1]=char_num[now.hour&0x0f];
  1438.   display_cnasc(0x89,1,save);
  1439.   save[0]=char_num[now.minute>>4];
  1440.   save[1]=char_num[now.minute&0x0f];
  1441.   display_cnasc(0x8b,1,save);
  1442.   save[0]=char_num[now.second>>4];
  1443.   save[1]=char_num[now.second&0x0f];
  1444.   display_cnasc(0x8d,1,save);
  1445. }
  1446. /********************调整功能月天数比较************/
  1447. uchar monthday(uchar year,uchar month)
  1448. {
  1449.   if(month==2&&year%4==0)
  1450.     return(29);
  1451.   else
  1452.   {        year=month&0x0f;
  1453.     month>>=4;
  1454.         month=month*10+year;       
  1455.     return(dayofmonth[month-1]);}
  1456. }
  1457. /***************星期推算************/
  1458. void weeks_day()
  1459. {
  1460.   uchar d,buffer,day=4;
  1461.   if(today.month>1)
  1462.   {
  1463.     buffer=(today.month>>4);   // 将BCD码转为十进制
  1464.         buffer=buffer*10;
  1465.         buffer+=(today.month&0x0f);
  1466.         for(d=0;d<buffer-1;d++)
  1467.         {
  1468.           today.week=(dayofmonth[d]>>4);
  1469.           today.week=today.week*10;
  1470.           today.week+=(dayofmonth[d]&0x0f);
  1471.       day+=(today.week%7);
  1472.         }
  1473.   }
  1474.   buffer=(today.year>>4);
  1475.   buffer*=10;
  1476.   buffer+=(today.year&0x0f);
  1477.   if(today.year!=0)
  1478.   {
  1479.         day+=((buffer-1)/4)+buffer+1;
  1480.   }
  1481.   if(buffer%4==0&&today.month>2) day++;
  1482.   buffer=today.day>>4;
  1483.   buffer*=10;
  1484.   buffer+=(today.day&0x0f);
  1485.   today.week=(day+buffer)%7;
  1486. }
  1487. /****************调整功能***************/
  1488. void adjust_func(void)
  1489. {
  1490.   uchar d,save,b=0;
  1491.   dis_title_e();
  1492.   display_cnasc(0x82,3,menu_cn_2[0]);
  1493.   rds1302_date();
  1494.   rds1302_time();
  1495.   dis_date_mode2(0x90);
  1496.   display_cnasc(0x9a,1,"  ");
  1497.   asjust_time();
  1498.   display_cnasc(0x9f,1,"→");
  1499.   display_cnasc(0x90,1,"『");
  1500.   display_cnasc(0x8f,1,"』");
  1501.   d=0;save=0;
  1502.   adju_si=0;
  1503.   do
  1504.   {
  1505.     con_disp(0x00,0x00,index_a[d].lnum,index_a[d].rnum,1,13);
  1506.     con_disp(0xff,0xff,index_a[save].lnum,index_a[save].rnum,1,13);
  1507.         d=save;
  1508.         while(1)
  1509.         {
  1510.           save=gotkey();
  1511.           if(save>=0&&save<10)
  1512.           {
  1513.             switch(d)
  1514.             {
  1515.               case 0: if(adju_si) // adju_si==1时两次输入连成一个数
  1516.                           {
  1517.                                     today.year<<=4;
  1518.                                 today.year+=save;adju_si=0;
  1519.                                   }
  1520.                       else
  1521.                               {
  1522.                                 today.year=save;adju_si=1;
  1523.                               }
  1524.                           break;
  1525.                   case 1: if(adju_si)
  1526.                           {
  1527.                                     today.month<<=4;today.month+=save;
  1528.                             if(today.month>0x12) today.month=save;
  1529.                     else adju_si=0;
  1530.                                   }
  1531.                                   else  
  1532.                                   {
  1533.                                     today.month=save;adju_si=1;
  1534.                                   }
  1535.                                   break;
  1536.                   case 2: if(adju_si)
  1537.                           {
  1538.                                     today.day<<=4;today.day+=save;  // 月天数比较
  1539.                                         if(today.year%4==0&&today.month==2&&today.day==29) ;
  1540.                             else if(today.day>monthday(today.year,today.month))
  1541.                                           today.day=save;
  1542.                                         else adju_si=0;
  1543.                                   }
  1544.                                   else  {today.day=save;adju_si=1;}
  1545.                                   break;
  1546.                   case 3: if(adju_si)
  1547.                           {
  1548.                                     now.hour<<=4;now.hour+=save;
  1549.                                           if(now.hour>0x23) now.hour=save;
  1550.                                         else adju_si=0;
  1551.                                   }
  1552.                                   else  {now.hour=save;adju_si=1;}
  1553.                                   break;
  1554.                   case 4: if(adju_si)
  1555.                           {
  1556.                                     now.minute<<=4;now.minute+=save;
  1557.                                           if(now.minute>0x59) now.minute=save;
  1558.                                         else adju_si=0;
  1559.                                   }
  1560.                                   else  {now.minute=save;adju_si=1;}
  1561.                                   break;
  1562.                   case 5: if(adju_si)
  1563.                           {
  1564.                                     now.second<<=4;now.second+=save;
  1565.                                           if(now.second>0x59) now.second=save;
  1566.                                         else adju_si=0;
  1567.                                   }
  1568.                                   else  {now.second=save;adju_si=1;}
  1569.                                   break;
  1570.                 }
  1571.                 if(today.day>monthday(today.year,today.month)) today.day=1;        // 更改月份时判断天数
  1572.                 if(today.month==0) today.month=1;
  1573.                 if(today.day==0) today.day=1;
  1574.                 if(d<3) dis_date_mode2(0x90);         // 更新显示
  1575.         else asjust_time();
  1576.                 display_cnasc(0x9a,1,"  ");                // 消去星期显示
  1577.       }
  1578.           if(save==11){save=d+1;adju_si=0;break;}
  1579.           if(save==10&&d!=0){save=d-1;adju_si=0;break;}
  1580.         }
  1581.     if(save==7&d==6) break;
  1582.   }while(1);
  1583.   weeks_day();          // 计算星期
  1584.   save_y_or_n();  // 需要保存时oth_run设为1
  1585.   if(oth_run) wds1302_time_date();
  1586. }
  1587. /*=============================================================================
  1588. 函数名称:计算器功能
  1589. 功能描述:10位带符号数的加减乘除运算
  1590. 全局变量:opera  resu  i  j
  1591. 参数说明:见函数
  1592. 返回说明:无
  1593. 设 计 人:LIJH
  1594. 版    本:1.0
  1595. 说    明:
  1596. =============================================================================*/
  1597. /*清寄存器  参数格式:m=2时结果寄存器,当m=1时操作数1,当m=0时操作数0(1),
  1598.                       n=1时,只清寄存器不清显示, 0两清*/
  1599. void removal_data(uchar m,uchar n)
  1600. {
  1601.   uchar l;                // 当n=1时,只清寄存器不清显示, 0两清
  1602.   if(m==2)                // 当m=2时结果寄存器
  1603.   {                            // 当m=1时操作数1
  1604.     if(n==0)        // 当m=0时操作数0 ,1
  1605.           for(l=0;l<6;l++)
  1606.             display_cnasc(0x98+l,1,"  ");
  1607.     for(l=0;l<12;l++)
  1608.       resu[l]=0;
  1609.   }
  1610.   while(m<2)
  1611.   {
  1612.     if(n==0)
  1613.         {
  1614.           if(m==0)
  1615.           {  
  1616.             for(l=0;l<6;l++)
  1617.               display_cnasc(0x90+l,1,"  ");
  1618.                   display_cnasc(0x95,1," 0");
  1619.           }       
  1620.           else
  1621.              for(l=0;l<6;l++)
  1622.                 display_cnasc(0x88+l,1,"  ");
  1623.         }
  1624.     for(l=0;l<12;l++)
  1625.       opera[m][l]=0;
  1626.         m++;
  1627.   }
  1628. }
  1629. /******************显示数值  参数格式:显示首地址****************/
  1630. void dis_cdata(uchar ass)
  1631. {
  1632.   uchar p,d,save[2];
  1633.   if(i==0&&opera[0][0]==1)                 // 显示符号
  1634.   {
  1635.     if(cal_run)  display_cnasc(0x98,1,"=-");
  1636.     else  display_cnasc(0x90,1," -");
  1637.   }
  1638.   d=opera[i][11];                                // 计算位数
  1639.   if(opera[i][10]!=0&&opera[i][10]!=opera[i][11]+1) d++;
  1640.   save[0]=d/2;ass=ass-save[0]+5;        // 计算显示的开始位置
  1641.   p=1;
  1642.   cal_del=0;                                        // 显示点标记 (0为没有显示)
  1643.   if(d%2==1)                                        // 对位数位奇数先处理首位
  1644.   {
  1645.     save[0]=' ';
  1646.     save[1]=char_num[opera[i][1]];
  1647.         display_cnasc(ass,1,save);
  1648.         p++;
  1649.   }
  1650.   ass++;                                                // 显示地址加一
  1651.   while(p<=opera[i][11])
  1652.   {                                                                       
  1653.     if(opera[i][10]==p&&(!cal_del)) {   // 显示点且作标记
  1654.           save[0]='.';cal_del=1;}
  1655.     else {
  1656.           save[0]=char_num[opera[i][p]]; p++;}
  1657.     if(opera[i][10]==p&&(!cal_del)) {
  1658.           save[1]='.';cal_del=1;}
  1659.     else{
  1660.           save[1]=char_num[opera[i][p]];p++;}
  1661.     display_cnasc(ass,1,save);
  1662.     ass++;
  1663.   }
  1664. }   
  1665. /****************从键盘中写入数据*****************/   
  1666. char input_data()
  1667. {
  1668.   uchar save=20,c;
  1669.   for(;i<2;i++)
  1670.   {
  1671.     while(1)
  1672.     {
  1673. pp:   save=gotkey();        // 读键盘
  1674.           if(save==20) continue;
  1675.           if(save==11)                // 按键为确定时,选择计算或删除
  1676.           {
  1677.             c=save=0;
  1678.                 while(1)                // 反色选择
  1679.             {
  1680.                   con_disp (0x00,0x00,index_cal[save].lnum,index_cal[save].rnum,2,16);
  1681.                   con_disp (0xff,0xff,index_cal[c].lnum,index_cal[c].rnum,2,16);       
  1682.                   save=gotkey();
  1683.                   if(save==10)
  1684.                   {
  1685.                     save=c;
  1686.                         if(++c==3) c=0;
  1687.                   }
  1688.                   else if(save==11)
  1689.                   {
  1690.             if(c==0) save=11;
  1691.                     else if(c==1) save=16;
  1692.                         else  return 0;
  1693.                     break;
  1694.                   }
  1695.                   else break;
  1696.         }
  1697.                 con_disp (0x00,0x00,index_cal[c].lnum,index_cal[c].rnum,2,16);            
  1698.           }
  1699.       if(save>=0&&save<=9&&j<10)
  1700.           {
  1701.             if(i==1&&opera[1][0]==15&&j>8) goto pp;
  1702.         if(j==2&&opera[i][1]==0&&opera[i][10]==0)
  1703.           opera[i][1]=save;                // 防止小数位不在时首位为零
  1704.             else{
  1705.                   opera[i][j]=save;opera[i][11]=j;j++;}
  1706.                 if(i==0)                                // 显示
  1707.                   dis_cdata(0x90);
  1708.                 else
  1709.                   dis_cdata(0x88);
  1710.           }
  1711.       else if(save==10&&j<10)       
  1712.       {
  1713.             if(opera[i][10]==0)                // 小数点空时保存
  1714.             {
  1715.                   if(opera[i][11]==0) {opera[i][10]=2;j++;}
  1716.               else  opera[i][10]=j;
  1717.             }
  1718.           }
  1719.           else if(save==16)       
  1720.           {                           // 删除数据
  1721.         removal_data(i,0);j=1;
  1722.                 if(i!=0){i--;j=10;}
  1723.       }
  1724.           else if(i==1&&opera[1][11]!=0&&save>11&&save<16)
  1725.       { save1=save;break; }                   // 连续计算时保存运算符
  1726.       else if(save==11&&opera[1][11]==0) continue;// 操作数1为0时不理会
  1727.           else if(save==11&&opera[1][11]!=0)  break;
  1728.           else if((i==0||i==1&&j==1)&&save>11&&save<16){i=0; break;}   
  1729.        // 当操作数0由运算符结束输入,再按符号键更改
  1730.           else continue;
  1731.     }
  1732.     if(opera[i][10]>opera[i][11]||opera[i][10]==0)
  1733.       opera[i][10]=opera[i][11]+1;        // 整数时小数位保存到最后
  1734.     while(opera[i][11]>=opera[i][10]&&opera[i][opera[i][11]]==0)
  1735.       opera[i][11]--;                                // 去除小数点后多余的0
  1736.     if(i==0)
  1737.     {
  1738.       opera[1][0]=save;                        // 保存运算符并显示
  1739.       display_cnasc(0x88,1,tool_cal[save-12]);
  1740.     }
  1741.     if(opera[0][11]==0) display_cnasc(0x95,1," 0");
  1742.     j=1;
  1743.     while(j<=opera[i][11]&&opera[i][j]==0) j++;//判断是否操作数是否全为0
  1744.     j--;
  1745.     if(j==opera[i][11]) opera[i][11]=0;
  1746.     j=1;
  1747.   }
  1748.   return 1;
  1749. }
  1750. /****************************************************************************************
  1751. 功能:  乘法运算
  1752. 描述:  结果由右到左保存
  1753. 参数:  i , j , opera[i][j],p,q,r,k,save1
  1754. 返回值:1(成功),0(结果位0),-1(溢出)
  1755. /****************************************************************************************/
  1756. char multiplication()
  1757. {
  1758.   uchar p,q,r,k,save1=0; // p指向操作数0 ,q指向操作数1,r指向结果
  1759.   if(opera[0][11]==0||opera[1][11]==0) return 0;
  1760.   resu[10]=opera[0][11]+opera[1][11]-opera[0][10]-opera[1][10]+2; // RESU记录小数点后的位数
  1761.   q=opera[1][11];                                        // 记录操1的位数
  1762.   r=9;
  1763.   opera[1][11]=1;
  1764.   k=1;
  1765.   while(opera[1][k]==0) {opera[1][11]=opera[1][11]+1;k++;}        // 去除前端的0
  1766.   k=1;
  1767.   while(opera[0][k]==0) k++;                        // 去除前端的0
  1768.   resu[11]=9;
  1769.   for(resu[0]=9;q>=opera[1][11];q--,resu[0]--)
  1770.   {
  1771.     if(opera[1][q]==0) continue;                // 操1此位数为0时直接比较
  1772.     for(p=opera[0][11],r=resu[0];p>=k;p--)
  1773.     {
  1774.       save1=opera[0][p]*opera[1][q];                // 将相乘后的数保存
  1775.       resu[r]+=(save1%10);//将缓存中的数取余后加到结果中R指向的位
  1776.       save1/=10;
  1777.       save1=save1+(resu[r]/10);                        // 保存进位的数
  1778.       resu[r]%=10;                                        // 重新写入
  1779.           if(r==1)        //结果有溢出时移位
  1780.           {
  1781.             if(save1==0&&p==k) break;        // 计算到最后位且没进位跳出
  1782.             else if(resu[10]>0)                // 要求有小数存在
  1783.         {
  1784.               for(r=9;r>1;r--) resu[r]=resu[r-1];
  1785.               r=1;
  1786.           resu[r]=save1;
  1787.               resu[11]=1;
  1788.               resu[10]--;
  1789.               resu[0]++;
  1790.         }   
  1791.             else   return -1;                         // 否则溢出
  1792.           }
  1793.           if(r>1&&(r-1)<resu[11])                        // 保存结果位的最高位
  1794.           {
  1795.             if(save1!=0) resu[11]=r-1;
  1796.             else resu[11]=r;
  1797.           }
  1798.           if(r>1){ r--;resu[r]+=save1;}// 当R为1时只需要移位记录结果
  1799.     }
  1800.   }
  1801.   while(resu[resu[11]]==0) resu[11]++;         // 去除前端的0
  1802.   resu[0]=opera[0][0];                                // 保存符号位
  1803.   removal_data(0,1);                                        // 清数据不清显示
  1804.   if(resu[10]>8)   //如果小数点后的数有9 位或以上时,需后移到使小数点放到2的位置  
  1805.   {
  1806.     save1=resu[10]-10+resu[11];                 // 记录后移位数
  1807.     if(save1>7)  return 0;          //当后移的数大于有效数字的位数时结果为0
  1808.     else         // 否则按需移位
  1809.     {
  1810.       for(p=save1+2,r=resu[11];p<10;p++,r++) opera[0][p]=resu[r];
  1811.           opera[0][10]=2;opera[0][11]=9;opera[0][0]=resu[0];
  1812.     }                // 因有效数小于小数点后的数,所以首位为0  
  1813.   }       
  1814.   else          //如果小数点后的数在8位以内时分两种情况
  1815.   {       
  1816.     opera[0][0]=resu[0];  
  1817.     save1=10-resu[11];         // 记录有效位数
  1818.     if(resu[10]>=save1)         // 小数的在有效数字的左边
  1819.     {       
  1820.           for(p=resu[10]+1,r=9;r>=resu[11];p--,r--)
  1821.         opera[0][p]=resu[r];        // 从小数点的最后一位开始
  1822.       opera[0][10]=2;opera[0][11]=resu[10]+1;
  1823.     }
  1824.     else                                  // 小数点在有效数字内
  1825.     {  
  1826.           for(p=1,r=resu[11];r<10;p++,r++) opera[0][p]=resu[r];
  1827.             opera[0][11]=10-resu[11];
  1828.           if(resu[10]==0) opera[0][10]=opera[0][11]+1;
  1829.           else opera[0][10]=opera[0][11]-resu[10]+1;
  1830.     }
  1831.   }
  1832.   while(opera[0][11]>=opera[0][10]&&opera[0][opera[0][11]]==0)
  1833.     opera[0][11]--;          // 去除小数点后多余的0
  1834.   return 1;
  1835. }
  1836. /****************************************************************************************
  1837. 功能:  除法运算
  1838. 描述:  结果由左到右保存
  1839. 参数:  i , j , opera[i][j]
  1840. p,q,r, remainde, divisor, decimal
  1841. 返回值:1(成功),0(结果位0),-1(溢出)
  1842. *****************************************************************************************/
  1843. char divider()
  1844. {
  1845.   unsigned long int divisor=0,remainder=0;
  1846.   uchar p,q,r;
  1847.   char decimal=0;
  1848.   if(opera[1][11]==0) return -1;
  1849.   if(opera[0][11]==0) return 0;
  1850.   for(r=1;r<12;r++)                // 判断两数是否相等
  1851.   {
  1852.     if(opera[0][r]!=opera[1][r]) break;
  1853.   }
  1854.   if(r==12)
  1855.   {
  1856.     p=opera[0][0];
  1857.     removal_data(0,1);
  1858.     opera[0][0]=r;
  1859.     opera[0][1]=1;
  1860.     opera[0][10]=2;
  1861.     opera[0][11]=1;
  1862.     return 1;
  1863.   }  
  1864.   decimal=(opera[0][11]-opera[0][10])-(opera[1][11]-opera[1][10]);
  1865.   // 记录两操作数小数点后位数的差
  1866.   if(decimal>0)                // 若操0大于操1时重新记录小数点的位置
  1867.   {
  1868.     opera[0][10]=opera[0][11]-decimal+1;
  1869.     resu[10]=opera[0][10];
  1870.   }
  1871.   else          // 否则小数点后没有数,记录有效数的位数
  1872.   {       
  1873.     opera[0][11]-=decimal;
  1874.     opera[0][10]=opera[0][11]+1;
  1875.     resu[10]=opera[0][10];
  1876.   }
  1877.   q=1;
  1878.   divisor=0;
  1879.   while(q<=opera[1][11]) // 将操1的数整形化
  1880.   {
  1881.     divisor=divisor*10+opera[1][q];q++;
  1882.   }
  1883.   if(divisor==1)   
  1884.   {
  1885.     if(resu[10]>10)        return -1;
  1886.         else return 1;
  1887.   }
  1888.   r=1;p=1;
  1889.   remainder=(unsigned long int)opera[0][1]; // 先对余数寄存器附初值
  1890.   do
  1891.   {   
  1892.         if(r>9)  // 结果位已经到达最后1位
  1893.         {  
  1894.             if(resu[1]==0&&resu[10]!=2) // 判断是否有得移位
  1895.           {        
  1896.             for(r=1;r<9;r++) resu[r]=resu[r+1];       
  1897.             resu[9]=0;
  1898.             if(resu[10]!=0) resu[10]--;
  1899.             r=9;
  1900.           }
  1901.       else if(p>=opera[0][11]||p>=opera[0][10])  break; // 如果计算到最后一位,或者有小数点存在时结束
  1902.       else return -1; // 否则错误
  1903.         }
  1904.         resu[r]=(uchar)(remainder/divisor);        // 保存结果
  1905.     remainder=(remainder%divisor);                // 重新写入余数
  1906.         p++;r++;         
  1907.     if(p>opera[0][11]&&remainder==0) break; // 除尽后跳出
  1908.     else if(p<=opera[0][11]&&p<10)                // 余数*10后加后一位
  1909.       {remainder=remainder*10+opera[0][p];}
  1910.     else   remainder=remainder*10;         //超出后余数*10
  1911.   }while(1);
  1912.   resu[11]=r-1;
  1913.   resu[0]=opera[0][0];
  1914.   removal_data(0,1);
  1915.   r=1;   
  1916.   while(resu[r]==0&&resu[10]!=(r+1)&&r<resu[11]) r++;
  1917. //去除结果前端的0
  1918.   if(r==resu[11]) return 0;
  1919.   resu[10]=resu[10]-r+1;
  1920.   p=1;
  1921.   while(r<=resu[11]){opera[0][p]=resu[r];r++;p++;}
  1922.   opera[0][0]=resu[0];opera[0][10]=resu[10];opera[0][11]=p-1;
  1923.   while(opera[0][11]>=opera[0][10]&&opera[0][opera[0][11]]==0)
  1924.     opera[0][11]--;
  1925.   return 1;
  1926. }
  1927. /****************************************************************************************
  1928. 功能:  加法运算
  1929. 描述:  以小数点位中心两边相加
  1930. 参数:  i , j , opera[i][j],p,q,r
  1931. 返回值:1(成功),0(结果位0),-1(溢出)
  1932. /****************************************************************************************/
  1933. char adder()
  1934. {
  1935.   uchar p,q,r;
  1936.   if(opera[0][11]==0&&opera[1][11]==0)   return 0;
  1937.   else if(opera[0][11]==0)
  1938.     {for(q=0;q<12;q++) opera[0][q]=opera[1][q];return 1;}
  1939.   else if(opera[1][11]==0) return 1;
  1940.   else
  1941.   {
  1942.     p=opera[0][10]-1;
  1943.     q=opera[1][10]-1;
  1944.     p>q?(r=p):(r=q);
  1945.     resu[10]=r+1;                // 小数点位保存
  1946.     resu[0]=opera[0][0];        // 保存符号位
  1947.     while(r>0)                        // 将小数点前的数相应相加后放到结果中
  1948.     {
  1949.       if(p>0&&q>0){resu[r]=opera[0][p]+opera[1][q];p--;q--;}
  1950.       else if(p>0&&q==0){resu[r]=opera[0][p];p--;}
  1951.       else        {resu[r]=opera[1][q];q--;}
  1952.       r--;
  1953.     }
  1954.     r=resu[10];
  1955.     p=opera[0][10];
  1956.     q=opera[1][10];
  1957.     while(r<10)                        // 将小数点后的数放到结果中
  1958.     {
  1959.       if(p>opera[0][11]&&q>opera[1][11]) break;
  1960.       else if(p<=opera[0][11]&&q<=opera[1][11])
  1961.         {resu[r]=opera[0][p]+opera[1][q];p++;q++;}
  1962.       else if(p<=opera[0][11]&&q>opera[1][11])
  1963.         {resu[r]=opera[0][p];p++;}
  1964.       else        {resu[r]=opera[1][q];q++;}
  1965.       r++;
  1966.     }
  1967.     r--;
  1968.     resu[11]=r;
  1969.     p=0;
  1970.     while(r>0)                        // 由右到左将大于9的数进位
  1971.     {
  1972.       resu[r]+=p;                        // p为进位标记
  1973.       p=0;
  1974.       if(resu[r]>9) {resu[r]-=10;p=1;}
  1975.       r--;
  1976.     }
  1977.     if(p==1)                                // 溢出移位
  1978.     {
  1979.       if(resu[10]==10) return -1;
  1980.       else {
  1981.         for(r=9;r>1;r--) resu[r]=resu[r-1];
  1982.         resu[1]=1;resu[10]++;}
  1983.     }
  1984.    removal_data(0,1);
  1985.    r=0;
  1986.    while(r<12){opera[0][r]=resu[r];r++;}
  1987.    while(opera[0][11]>=opera[0][10]&&opera[0][opera[0][11]]==0)
  1988.      opera[0][11]--;
  1989.    return 1;
  1990.   }
  1991. }
  1992. /****************************************************************************************
  1993. 功能:  减法运算
  1994. 描述:  先比较两操作数的大小用one ,two互换
  1995. 参数:  i , j , opera[i][j],p,q,r,one,two
  1996. 返回值:1(成功),0(结果位0),-1(溢出)
  1997. /****************************************************************************************/
  1998. char subtraction()
  1999. {
  2000.   uchar p,q,r,one,two;
  2001.   if(opera[0][11]==0&&opera[1][11]==0)   return 0;
  2002.   else if(opera[0][11]==0)
  2003.   {
  2004.     for(q=1;q<12;q++)
  2005.     opera[0][q]=opera[1][q];
  2006.         opera[0][0]=!opera[0][0];return 1;
  2007.   }
  2008.   else if(opera[1][11]==0) return 1;
  2009.   else
  2010.   { // 比较大小(大放到one)
  2011.     if(opera[0][10]>opera[1][10]){one=0;two=1;}
  2012.     else if(opera[1][10]>opera[0][10]) {one=1;two=0;}
  2013.     else
  2014.     {
  2015.       r=1;
  2016.           while(r<10&&opera[0][r]==opera[1][r]) r++;
  2017.           if(r==10) {removal_data(0,1);return 0;}
  2018.       opera[0][r]>opera[1][r]?(one=0,two=1):(one=1,two=0);
  2019.     }
  2020.     p=opera[one][10]-1;
  2021.     q=opera[two][10]-1;
  2022.     r=p;                        // 保存小数点前的数
  2023.     resu[10]=r+1;        // 保存小数点位
  2024.     resu[0]=0;                // 用作借位标记
  2025.     while(r>0)                // 小数点前相减
  2026.     {
  2027.       if(p>0&&q>0)
  2028.           {
  2029.             opera[two][q]+=resu[0];
  2030.         resu[0]=0;
  2031.         if(opera[one][p]>=opera[two][q])
  2032.           resu[r]=opera[one][p]-opera[two][q];
  2033.             else
  2034.             {
  2035.                   resu[0]=1;
  2036.                   resu[r]=10+opera[one][p]-opera[two][q];
  2037.             }
  2038.             p--;q--;
  2039.           }
  2040.           else
  2041.           {            
  2042.         if(opera[one][p]<resu[0])
  2043.           {resu[r]=10+opera[one][p]-resu[0];}
  2044.             else
  2045.                   {resu[r]=opera[one][p]-resu[0];resu[0]=0;p--;}
  2046.           }
  2047.       r--;
  2048.     }
  2049.     r=resu[10];
  2050.     p=opera[one][10];
  2051.     q=opera[two][10];
  2052.     while(r<10)                                    // 将小数点后的数放到结果中
  2053.     {
  2054.       if(p>opera[one][11]&&q>opera[two][11]) break;
  2055.       else if(p<=opera[one][11]&&q<=opera[two][11])
  2056.           {
  2057.         if(opera[one][p]>=opera[two][q])  resu[r]=opera[one][p]-opera[two][q];
  2058.             else
  2059.             {
  2060.               resu[r]=10+opera[one][p]-opera[two][q];
  2061.               resu[0]=r;
  2062.               for(r-=1;r>0;r--)              // 向前借位
  2063.                   {
  2064.                 if(resu[r]==0) resu[r]=9;
  2065.                     else{resu[r]-=1;break;}
  2066.                   }
  2067.                   r=resu[0];       
  2068.             }
  2069.             p++;q++;
  2070.           }                                           
  2071.       else if(p<=opera[one][11]&&q>opera[two][11])
  2072.         {resu[r]=opera[one][p];p++;}
  2073.       else       
  2074.           {
  2075.             resu[r]=10-opera[two][q];  
  2076.             resu[0]=r;
  2077.             for(r-=1;r>0;r--)
  2078.         {
  2079.                   if(resu[r]==0) resu[r]=9;
  2080.               else{ resu[r]-=1;break;}
  2081.                 }
  2082.             r=resu[0];
  2083.             q++;       
  2084.           }
  2085.       if(r==9)                  // 结果溢出移位
  2086.           {
  2087.             if(resu[1]==0&&resu[10]!=2)
  2088.         {
  2089.           for(r=1;r<9;r++) resu[r]=resu[r+1];
  2090.                   resu[10]--;resu[9]=0;r=8;
  2091.         }
  2092.           }
  2093.       r++;
  2094.     }
  2095.     r--;
  2096.     resu[11]=r;
  2097.     if(one==0)resu[0]=opera[0][0];              // 符号位写入
  2098.     else resu[0]=!opera[0][0];
  2099.     removal_data(0,1);
  2100.     r=1;
  2101.     while(resu[r]==0&&resu[10]!=(r+1)) r++;   // 去除前端0
  2102.     resu[10]=resu[10]-r+1;                             // 重新写入小数点
  2103.     p=1;
  2104.     while(r<=resu[11]){opera[0][p]=resu[r];r++;p++;}
  2105.     opera[0][0]=resu[0];opera[0][10]=resu[10];opera[0][11]=p-1;
  2106.     while(opera[0][11]>=opera[0][10]&&opera[0][opera[0][11]]==0) opera[0][11]--;
  2107.     return 1;
  2108.   }
  2109.   }
  2110. /****************************************************************************************
  2111. 功能:  计算器主函数
  2112. 描述:  根据符号位,运算符调用函数
  2113. 参数:  state,save
  2114. 返回值:无
  2115. ****************************************************************************************/
  2116. void calculator(void)
  2117. {
  2118.   char data state;
  2119.   uchar data save;
  2120.   save1=0;
  2121.   dis_title_e();
  2122.   display_cnasc(0x82,3,tool_menu[0]);
  2123.   display_cnasc(0x96,2,"等于");
  2124.   display_cnasc(0x8e,2,"删除");
  2125.   display_cnasc(0x9e,2,"退出");
  2126.   removal_data(2,0);             // 0为清除显示
  2127.   removal_data(0,0);
  2128.   i=0;j=1;
  2129.   while(1)
  2130.   {       
  2131.     cal_run=0;
  2132.     state=input_data();
  2133.     if(state==1)          // 根据opera[1][0]的数值调用程序
  2134.     {
  2135.       if(opera[1][0]==12&&opera[0][0]==0||opera[1][0]==13&&opera[0][0]==1)
  2136.             state=adder();
  2137.       else if(opera[1][0]==12&&opera[0][0]==1||opera[1][0]==13&&opera[0][0]==0)
  2138.             state=subtraction();
  2139.       else if(opera[1][0]==14) state=multiplication();
  2140.       else state=divider();
  2141.     }
  2142.         if(state==0)  return;
  2143.     i=0;j=1;
  2144.     cal_run=1;
  2145.     switch(state)
  2146.     {
  2147.       case -1:                                                 // 结果溢出
  2148.                   removal_data(2,0);
  2149.               removal_data(0,0);  
  2150.                       display_cnasc(0x8a,3,"溢出!!");
  2151.                       save1=0;
  2152.                           break;
  2153.       case  0:                                                // 结果为零
  2154.                           if(save1==0)
  2155.                           {
  2156.                             removal_data(2,1);
  2157.                                 removal_data(0,1);
  2158.                             display_cnasc(0x98,1,"= ");
  2159.                             display_cnasc(0x9d,1," 0");
  2160.                           }
  2161.                           break;                                // 结果显示
  2162.       case  1:
  2163.                           if(save1==0)
  2164.                           {
  2165.                             cal_run=1;
  2166.                             display_cnasc(0x98,1,"= ");
  2167.                 dis_cdata(0x98);
  2168.                           }
  2169.                           break;
  2170.     }
  2171.         if(save1==0) save=gotkey();         // save1记录连续计算符
  2172.         cal_run=0;       
  2173.         if((save>11&&save<16&&state==1)||save1!=0)
  2174.         {
  2175.           removal_data(2,0);
  2176.           removal_data(1,0);
  2177.           display_cnasc(0x90,6,"               ");
  2178.           if(opera[0][11]==0) display_cnasc(0x95,1," 0");
  2179.           else dis_cdata(0x90);
  2180.           if(save1!=0)save=save1;
  2181.           save1=0;
  2182.           display_cnasc(0x88,1,tool_cal[save-12]);
  2183.           opera[1][0]=save;
  2184.           i=1;j=1;
  2185.         }
  2186.         else if(save>=0&&save<10&&state==1)
  2187.         {
  2188.           removal_data(2,0);
  2189.           removal_data(0,0);
  2190.           opera[0][1]=save;
  2191.           opera[0][11]++;
  2192.           dis_cdata(0x90);
  2193.           i=0;j=2;
  2194.         }
  2195.         else if(save==10)
  2196.         {  
  2197.           removal_data(2,0);
  2198.           removal_data(0,0);
  2199.       opera[i][10]=2;
  2200.           opera[i][11]=1;
  2201.       j=2;
  2202.         }
  2203.         else
  2204.         {
  2205.           removal_data(2,0);
  2206.           removal_data(0,0);
  2207.         }
  2208.   }                                                                                       
  2209. }
  2210. /*=============================================================================
  2211. 函数名称:温度功能
  2212. 功能描述:连续检查温度
  2213. 全局变量:temprun  oth_run  als_temp  adju_si
  2214. 参数说明:见函数
  2215. 返回说明:无
  2216. 设 计 人:LIJH
  2217. 版    本:1.0
  2218. 说    明:
  2219. =============================================================================*/
  2220. /********************* 温度显示 ************************/
  2221. uchar temp_func_dis(void)
  2222. {
  2223.   uchar save[2],k;
  2224.   clear_dis();
  2225.   dis_title_e();
  2226.   display_cnasc(0x82,3,"温度计");  
  2227.   display_cnasc(0x98,3,"设定");
  2228.   display_cnasc(0x9e,3,"退出");
  2229.   display_cnasc(0x8e,1," \x1f");
  2230.   num2_asc_dis(10,0x85);
  2231.   temprun=1;
  2232.   while(1)
  2233.   {
  2234.         if(ds18b20)
  2235.     {
  2236.       if(temp.t_data[0]>99)          // 温度值大于99时
  2237.           {
  2238.             save[0]=temp.t_data[0]/100;
  2239.         save[1]=(temp.t_data[0]/10)%10;
  2240.         num2_asc_dis(save[0],0x80);
  2241.             num2_asc_dis(save[1],0x81);
  2242.             save[0]=char_num[temp.t_data[0]%10];
  2243.             num2_asc_dis(save[0],0x82);
  2244.       }
  2245.           else                                         // 温度小于100
  2246.           {
  2247.         con_disp(0x00,0x00,0x80,0x90,1,16);
  2248.                 con_disp(0x00,0x00,0x88,0x90,1,16);
  2249.                 if(temp_pn) con_disp(0x3f,0xfc,0x80,0x9d,1,3);
  2250.             else  con_disp(0x00,0x00,0x80,0x9d,1,3);
  2251.             save[0]=temp.t_data[0]/10;
  2252.             save[1]=temp.t_data[0]%10;
  2253.             num2_asc_dis(save[0],0x81);
  2254.             num2_asc_dis(save[1],0x82);
  2255.           }
  2256.           save[0]='.';
  2257.           save[1]=char_num[temp.t_data[1]/10];
  2258.           display_cnasc(0x8b,1,save);
  2259.           save[0]=char_num[temp.t_data[1]%10];
  2260.           if(save[0]=='1') save[1]='2';                   // 补偿精度
  2261.           else if(save[0]=='7') save[1]='5';
  2262.           else if(save[0]=='8'||save[0]=='1') save[1]='7';
  2263.           else save[1]='0';
  2264.           display_cnasc(0x8c,1,save);
  2265.     }
  2266.         else
  2267.         {
  2268.       clear_dis();
  2269.       display_cnasc(0x92,4,"没有发现");
  2270.       display_cnasc(0x8c,4,"温感器!");
  2271.           delay_pw();
  2272.           temprun=0;
  2273.           return 0;
  2274.         }
  2275.         k=gotkey();
  2276.         if(k==2)         // 进入设置菜单
  2277.         {
  2278.           display_cnasc(0x8e,1," \x04");
  2279.           delay(210000);
  2280.           display_cnasc(0x8e,1," \x1e");
  2281.           display_cnasc(0x9a,4,"\x11 (ok) \x10");
  2282.           return 1;
  2283.         }
  2284.   }
  2285. }
  2286. /*************************** 警报温度设置 *****************************/
  2287. uchar temp_func_set(void)
  2288. {
  2289.   uchar save[2];
  2290.   temprun=0;
  2291.   oth_run=0;
  2292.   rds1302_data();
  2293.   while(1)
  2294.   {  
  2295.         if(oth_run)
  2296.         {
  2297.           con_disp (0x00,0x00,0x88,0x90,2,16);
  2298.           con_disp (0xff,0xff,0x8e,0x90,2,16);
  2299.         }
  2300.         else
  2301.         {
  2302.           con_disp (0xff,0xff,0x88,0x90,2,16);
  2303.           con_disp (0x00,0x00,0x8e,0x90,2,16);
  2304.         }       
  2305.         save[0]=gotkey();
  2306.         if(save[0]==1||save[0]==3) oth_run=!oth_run;
  2307.         if(save[0]==5) return 1;
  2308.         if(save[0]==11)
  2309.         {  
  2310.           if(oth_run) return 0;
  2311.           else  
  2312.           {
  2313.                 clear_dis();
  2314.                 dis_title_e();
  2315.                 save[1]=save[0]=0;
  2316.                 oth_run=0;
  2317.             dis_title_e();
  2318.         display_cnasc(0x82,3,"设  定");
  2319.             display_cnasc(0x90,5,"警报温度:");
  2320.                 display_cnasc(0x88,7,"高于【    】℃");
  2321.                 display_cnasc(0x98,8,"低于【    】℃ \x10");
  2322.                 while(1)
  2323.                 {
  2324.                   if(save[1]==2) con_disp(0x00,0x00,index_temp_set[save[1]].lnum,index_temp_set[save[1]].rnum,2,13);
  2325.                   else con_disp(0x00,0x00,index_temp_set[save[1]].lnum,index_temp_set[save[1]].rnum,2,13);
  2326.                   if(save[0]==2) con_disp(0x0f,0xff,index_temp_set[save[0]].lnum,index_temp_set[save[0]].rnum,1,13);
  2327.           else con_disp(0xff,0xff,index_temp_set[save[0]].lnum,index_temp_set[save[0]].rnum,2,13);
  2328.               save[1]=save[0];
  2329.           adju_si=0;
  2330.                   oth_run=0;
  2331.                   while(1)
  2332.                   {
  2333.                     for(i=0;i<2;i++)
  2334.                     {
  2335.                       j=0x8b+i*16;
  2336.                           if(als_temp[i]==255) display_cnasc(j,2," off"); // 255值为关闭值
  2337.                       else
  2338.                           {
  2339.                             save1=save[1];
  2340.                             if(als_temp[i]>127)         // 当数值大于127时温度值为负数
  2341.                             {
  2342.                                   display_cnasc(j,1,"- ");
  2343.                                   save[0]=char_num[(als_temp[i]-128)/10];
  2344.                                   save[1]=char_num[(als_temp[i]-128)%10];
  2345.                                   display_cnasc(j+1,1,save);
  2346.                             }
  2347.                             else
  2348.                             {
  2349.                                   save[0]=' ';
  2350.                                   save[1]=char_num[als_temp[i]/100];
  2351.                                   if(save[1]=='0') save[1]=' ';
  2352.                                   display_cnasc(j,1,save);
  2353.                                   save[0]=char_num[als_temp[i]/10%10];
  2354.                                   save[1]=char_num[als_temp[i]%10];
  2355.                                   display_cnasc(j+1,1,save);
  2356.                             }
  2357.                             save[1]=save1;
  2358.                           }
  2359.                     }               
  2360.                         save[0]=gotkey();
  2361.                         do                   // 输入符号等待数值输入或下一位
  2362.                         {
  2363.                           if(save[0]==13){ oth_run=1;display_cnasc(0x8b+save[1]*16,2,"-   ");}
  2364.                           else if(save[0]==12){ oth_run=0;display_cnasc(0x8b+save[1]*16,2,"    ");}
  2365.                           else break;
  2366.                           save[0]=gotkey();
  2367.                           if(save[0]>=0&&save[0]<10||save[0]==11) break;
  2368.                         }while(1);
  2369.                         if(save[0]==14){ als_temp[save[1]]=255;}  // 乘号直接将警报温度关闭
  2370.                         if(save[0]>=0&&save[0]<10&&save[1]<2)
  2371.                     {
  2372.                           if(adju_si)
  2373.                       {
  2374.                             adju_si=0;
  2375.                             if(oth_run) als_temp[save[1]]&=0x7f;    // 消去符号位
  2376.                                 if(als_temp[save[1]]>24&&!oth_run) als_temp[save[1]]=240;
  2377.                         else als_temp[save[1]]=als_temp[save[1]]*10+save[0];
  2378.                                 if(oth_run&&als_temp[save[1]]>50) als_temp[save[1]]=50;                
  2379.                                 if(!oth_run&&als_temp[save[1]]>120) als_temp[save[1]]=120;
  2380.                                 if(!oth_run&&als_temp[save[1]]<100) adju_si=1;           // 根据数值打开连写
  2381.                                 if(oth_run&&als_temp[save[1]]<10)  adju_si=1;
  2382.                           }
  2383.                           else
  2384.                           {
  2385.                             als_temp[save[1]]=save[0];
  2386.                                 adju_si=1;
  2387.                           }
  2388.                           if(oth_run) als_temp[save[1]]=als_temp[save[1]]|0x80;         // 写入符号
  2389.                           else als_temp[save[1]]=als_temp[save[1]]&0x7f;
  2390.                         }                       
  2391.                         if(save[0]==11)
  2392.                         {
  2393.                           if(als_temp[1]!=255&&als_temp[0]!=255)           // 上下限温度调整
  2394.                           {
  2395.                              if(save[1]==0&&als_temp[0]<als_temp[1]){als_temp[0]=als_temp[1];}
  2396.                             if(save[1]==1&&als_temp[1]>als_temp[0]){als_temp[1]=als_temp[0];}
  2397.                           }
  2398.                           save[0]=save[1]+1;adju_si=0;break;}
  2399.                 if(save[0]==10&&save[1]!=0) {save[0]=save[1]-1;adju_si=0;break;}
  2400.                   }
  2401.                   oth_run=0;
  2402.                   if(save[0]==3&&save[1]==2) break;
  2403.                 }
  2404.                 save_y_or_n();
  2405.                 if(oth_run)
  2406.                 {
  2407.                   wds1302_data(d02_temp,als_temp[0]);
  2408.                   wds1302_data(d02_temp+2,als_temp[1]);
  2409.                 }
  2410.                 return 1;
  2411.           }
  2412.         }
  2413.   }
  2414. }                  
  2415. /********************* 温度计主函数 *********************/                 
  2416. void temp_func(void)
  2417. {                 
  2418.   uchar t;       
  2419.   while(1)
  2420.   {
  2421.     oth_run=1;
  2422.         t=temp_func_dis();
  2423.     if(t==1)
  2424.         {
  2425.           t=temp_func_set();
  2426.           if(t==0) return;
  2427.         }
  2428.     else return;
  2429.   }
  2430. }
  2431. /*=============================================================================
  2432. 函数名称:闹铃功能
  2433. 功能描述:设定闹铃
  2434. 全局变量:alarm_time adju_si
  2435. 参数说明:见函数
  2436. 返回说明:无
  2437. 设 计 人:LIJH
  2438. 版    本:1.0
  2439. 说    明:
  2440. =============================================================================*/
  2441. void alarm_func(void)
  2442. {
  2443.   uchar save[2],a,d;
  2444.   clear_dis();
  2445.   dis_title_e();
  2446.   display_cnasc(0x82,3,"闹  钟");  
  2447.   display_cnasc(0x91,6,"状态:\x11    \x10");
  2448.   display_cnasc(0x89,3,"闹铃:");
  2449.   display_cnasc(0x9f,1,"→");
  2450.   display_cnasc(0x90,1,"『");
  2451.   display_cnasc(0x8f,1,"』");
  2452.   adju_si=0;
  2453.   a=0;d=0;
  2454.   save[0]=char_num[alarm_time[0]>>4];
  2455.   save[1]=char_num[alarm_time[0]&0x0f];
  2456.   display_cnasc(0x8c,1,save);
  2457.   display_cnasc(0x8d,1,": ");
  2458.   save[0]=char_num[alarm_time[1]>>4];
  2459.   save[1]=char_num[alarm_time[1]&0x0f];       
  2460.   display_cnasc(0x8e,1,save);
  2461.   do
  2462.   {
  2463.     if(a==0)
  2464.         {   
  2465.           display_cnasc(0x95,1,alm_sign[alm]);
  2466.       display_cnasc(0x94,1,"\x11 ");
  2467.       display_cnasc(0x96,1," \x10");
  2468.           con_disp(0x00,0x00,index_alm[d-1].lnum,index_alm[d-1].rnum,1,14);
  2469.         }
  2470.     if(a>0&&a<4)
  2471.         {
  2472.           if(d==0)
  2473.           {
  2474.                 display_cnasc(0x94,1,"  ");
  2475.         display_cnasc(0x96,1,"  ");
  2476.           }
  2477.           else
  2478.            con_disp(0x00,0x00,index_alm[d-1].lnum,index_alm[d-1].rnum,1,14);
  2479.          con_disp(0xff,0xff,index_alm[a-1].lnum,index_alm[a-1].rnum,1,14);       
  2480.     }                   
  2481.         d=a;
  2482.         while(1)
  2483.         {
  2484.           a=gotkey();
  2485.           if((a==1||a==3)&&d==0)
  2486.           {
  2487.             alm=!alm;
  2488.                 if(a==1) display_cnasc(0x94,1,"\x09 ");
  2489.                 else display_cnasc(0x96,1," \x09");
  2490.                 delay(210000);
  2491.                 if(a==1) display_cnasc(0x94,1,"\x11 ");
  2492.         else display_cnasc(0x96,1," \x10");
  2493.                 display_cnasc(0x95,1,alm_sign[alm]);
  2494.           }
  2495.           if(d>0&&d<3&&a>=0&&a<10)
  2496.           {
  2497.             if(adju_si)
  2498.                 {
  2499.                   alarm_time[d-1]<<=4;alarm_time[d-1]+=a;
  2500.                   if(d==1&&alarm_time[0]>0x23) alarm_time[0]=a;
  2501.                   else if(d==2&&alarm_time[1]>0x59) alarm_time[1]=a;
  2502.                   else adju_si=0;
  2503.                 }
  2504.             else  
  2505.                 {
  2506.                   alarm_time[d-1]=a;adju_si=1;
  2507.                 }
  2508.                 save[0]=char_num[alarm_time[d-1]>>4];
  2509.             save[1]=char_num[alarm_time[d-1]&0x0f];
  2510.             display_cnasc(0x8c+(d-1)*2,1,save);
  2511.           }
  2512.           if(a==11){a=d+1;break;}
  2513.           if(a==10&&d!=0){a=d-1;break;}
  2514.         }
  2515.         adju_si=0;
  2516.         if(a==4)
  2517.         {
  2518.           save_y_or_n();
  2519.           wds1302_data(d02_signs,signs);
  2520.           wds1302_data(d02_alm,alarm_time[0]);
  2521.           wds1302_data(d02_alm+2,alarm_time[1]);
  2522.           return;
  2523.         }
  2524.   }while(1);
  2525. }
  2526. /*=============================================================================
  2527. 函数名称:篮球器功能
  2528. 功能描述:分数  时间  24秒  
  2529. 全局变量:resu  opera
  2530. 参数说明:见函数
  2531. 返回说明:无
  2532. 设 计 人:LIJH
  2533. 版    本:1.0
  2534. 说    明:
  2535. =============================================================================*/
  2536. /*********************** 比赛设置 ****************************/
  2537. void nba_set(void)
  2538. {
  2539.   uchar nba,save1,key,save[2];
  2540.   clear_dis();
  2541.   dis_title_e();
  2542.   if(resu[7]==1) display_cnasc(0x82,3,"加  时");
  2543.   else  
  2544.   {
  2545.     display_cnasc(0x82,3,"设  定");
  2546.     opera[0][0]=0;
  2547.     opera[1][0]=1;
  2548.   }
  2549.   resu[6]=0;        // 赋初值
  2550.   resu[0]=1;
  2551.   resu[1]=4;
  2552.   resu[2]=12;
  2553.   resu[3]=0;
  2554.   resu[4]=24;
  2555.   display_cnasc(0x90,7,"队1:红  队2:白");
  2556.   display_cnasc(0x88,7,"24秒:Y  节数:4");
  2557.   display_cnasc(0x98,8,"每节时间: 12分钟");
  2558.   save1=0;nba=0;
  2559.   while(1)
  2560.   {
  2561.     if(save1==4) display_cnasc(0x9c,1,":");
  2562.         else display_cnasc(index_nba[save1],1,"  ");
  2563.         if(nba==4)  display_cnasc(0x9c,1,":\x10");
  2564.         else display_cnasc(index_nba[nba],1,"\x11 ");
  2565.         save1=nba;
  2566.         key=gotkey();       
  2567.         if(key==1||key==3)
  2568.         {          
  2569.           switch(nba)     // 导航更改数据
  2570.           {
  2571.             case 0:                            
  2572.                 case 1:
  2573.                         if(key==1){if(opera[nba][0]>0) opera[nba][0]--;
  2574.                                            else opera[nba][0]=7;}
  2575.                                 if(key==3){if(opera[nba][0]<7) opera[nba][0]++;
  2576.                                            else opera[nba][0]=0;}
  2577.                                 display_cnasc(index_nba[nba]-1,1,nba_oppo[opera[nba][0]]);
  2578.                                 break;
  2579.                 case 2:
  2580.                                 if(resu[0]>0) resu[0]=0;
  2581.                                 else resu[0]=1;
  2582.                                 if(resu[0]>0)         display_cnasc(0x8a,1,":Y");
  2583.                                 else display_cnasc(0x8a,1,":N");
  2584.                                 break;
  2585.                 case 3:
  2586.                                 if(key==1){if(resu[1]>1) resu[1]--;
  2587.                                             else  resu[1]=4;}
  2588.                             if(key==3){if(resu[1]<4) resu[1]++;
  2589.                                        else resu[1]=1;}
  2590.                                 save[0]=':';
  2591.                                 save[1]=char_num[resu[1]];
  2592.                                display_cnasc(0x8e,1,save);
  2593.                                 break;
  2594.                 case 4:
  2595.                                 if(key==1){if(resu[2]>0) resu[2]--;
  2596.                                             else  resu[2]=60;}
  2597.                             if(key==3){if(resu[2]<60) resu[2]++;
  2598.                                        else resu[2]=0;}
  2599.                                 save[0]=char_num[resu[2]/10];
  2600.                                 save[1]=char_num[resu[2]%10];
  2601.                                display_cnasc(0x9d,1,save);
  2602.                                 resu[5]=resu[2];
  2603.                                 break;
  2604.       }
  2605.         }
  2606.         if(key==11)
  2607.         {
  2608.           nba++; if(nba==5) return;                          
  2609.         }
  2610.         if(key==10&&nba!=0)  nba--;
  2611.   }
  2612. }
  2613. /************************ 界面其他元素 ***********************/
  2614. void nba_oth_dis(void)
  2615. {
  2616.   uchar save[2];
  2617.   if(resu[7]==1) display_cnasc(0x80,5,"加时时间:");
  2618.   else display_cnasc(0x80,5,"比赛时间:");
  2619.   display_cnasc(0x98,1,nba_oppo[opera[0][0]]);
  2620.   display_cnasc(0x9e,1,nba_oppo[opera[1][0]]);
  2621.   display_cnasc(0x99,1,"队");
  2622.   display_cnasc(0x9f,1,"队");
  2623.   save[0]='0';
  2624.   save[1]=char_num[resu[6]+1];
  2625.   display_cnasc(0x9b,1,save);
  2626.   display_cnasc(0x9c,1,"st");
  2627.   con_disp(0xff,0xff,0x83,0x90,2,1); // 画正方框
  2628.   con_disp(0xff,0xff,0x8b,0x8f,2,1);
  2629.   con_disp(0x80,0x00,0x83,0x91,1,15);
  2630.   con_disp(0x00,0x01,0x84,0x91,1,15);
  2631.   con_disp(0x80,0x00,0x8b,0x80,1,15);
  2632.   con_disp(0x00,0x01,0x8c,0x80,1,15);
  2633.   nba_dis_time();
  2634.   if(resu[0]==0) display_cnasc(0x93,2,"\x07--\x07");
  2635.   display_cnasc(0x8b,2," S! ");
  2636. }
  2637. /**********************篮球器主函数***********************/
  2638. void nba_timer(void)
  2639. {
  2640.   uchar save,key,nba=0;
  2641.   als=di0=1;alm=keb=di1=oth_run=0;
  2642.   time_init();  
  2643.   display_cnasc(0x82,3,"篮球器");
  2644.   dis_title_e();
  2645.   removal_data(0,1);
  2646.   while(1)          // 使用说明
  2647.   {
  2648.         display_cnasc(0x90,8,timer_tips[nba]);
  2649.         display_cnasc(0x88,8,timer_tips[nba+1]);
  2650.         display_cnasc(0x98,8,timer_tips[nba+2]);
  2651.         key=gotkey();
  2652.         if(key==11)
  2653.         {
  2654.           nba+=3;
  2655.           if(nba>9) break;
  2656.         }
  2657.         if(key==10)
  2658.         {
  2659.           if(nba>0) nba-=3 ;
  2660.         }
  2661.   }
  2662. nn:
  2663.   nba_set();
  2664.   clear_dis();
  2665.   nba_oth_dis();
  2666.   nba_tim=1;
  2667.   while(1)
  2668.   {       
  2669.         for(save=0x80,nba=0;nba<2;nba++)
  2670.         {
  2671.           if(opera[nba][1]>99)        // 分数显示
  2672.           {
  2673.             num2_asc_dis(opera[nba][1]/100,save);
  2674.                 num2_asc_dis(opera[nba][1]/10%10,save+1);
  2675.                 num2_asc_dis(opera[nba][1]%10,save+2);
  2676.           }
  2677.           else
  2678.           {
  2679.                 num2_asc_dis(opera[nba][1]/10,save);
  2680.                 num2_asc_dis(opera[nba][1]%10,save+1);
  2681.       }
  2682.           if(opera[1][1]>99) save=0x85;
  2683.           else save=0x86;
  2684.         }
  2685.         do
  2686.         {
  2687.         key=gotkey();
  2688.   ss:
  2689.         switch(key)
  2690.         {
  2691.           case 12:
  2692.           case 13:
  2693.                    if(key==12)
  2694.                              {if(opera[0][1]<250) opera[0][1]++;}
  2695.                    else
  2696.                              {if(opera[0][1]>0) opera[0][1]--;}
  2697.                            save=110;
  2698.                             break;
  2699.           case 14:
  2700.           case 15:
  2701.                    if(key==14)
  2702.                              {if(opera[1][1]<250) opera[1][1]++;}
  2703.                    else
  2704.                              {if(opera[1][1]>0) opera[1][1]--;}
  2705.                            save=110;
  2706.                            break;
  2707.           case  7:
  2708.                    TR1=TR0=EA=0;
  2709.                    if((++resu[3])>59)
  2710.                    {
  2711.                      resu[3]=0;
  2712.                          if((++resu[2])>59)
  2713.                                  {
  2714.                                    resu[3]=0;
  2715.                                    if(++resu[2]>60) resu[2]=0;
  2716.                                  }
  2717.                            }
  2718.                        if(resu[4]<24) resu[4]++;
  2719.                            nba_dis_time();
  2720.                            break;
  2721.           case  8:
  2722.                    if(resu[0]==1)
  2723.                            {
  2724.                              TL1=(time_count&0x00FF);
  2725.                  TH1=(time_count>>8);
  2726.                              resu[4]=24; nba_dis_time();
  2727.                                  TR0=TR1=EA=1;
  2728.                            }
  2729.                            break;
  2730.           case  9:
  2731.                    if(resu[2]==0&&resu[3]==0)
  2732.                    {
  2733.                      resu[2]=resu[5];resu[4]=24;
  2734.                                  if(resu[6]==resu[1])
  2735.                                  {                                                          // 判断比分进行加时赛
  2736.                                    if(opera[0][1]==opera[1][1]){nba_tim=0;resu[7]=1; goto nn;}
  2737.                                    while(gotkey()!=10);                  // 否则只能退出
  2738.                                    signs=r1302(d02_signs+1);
  2739.                                    nba_tim=0;
  2740.                                    return;
  2741.                                  }
  2742.                                  else nba_oth_dis();
  2743.                                  break;
  2744.                    }
  2745.                            if(EA) {TR0=TR1=EA=0;break;}
  2746.                    if(!EA&resu[4]!=0){ EA=TR0=1;if(resu[0]==1) TR1=1;}
  2747.                            break;                                                                                                                 
  2748.           case 10:
  2749.           case 11:
  2750.                    if(!EA)                        // 暂停状态下 ok键两次返回时钟界面
  2751.                            {                //  ./s 键两次退出
  2752.                              delay(36000);
  2753.                                  save=gotkey();
  2754.                                  if(save==key)
  2755.                                  {
  2756.                                    if(key==11)
  2757.                                    {
  2758.                                      clear_dis();oth_run=1;
  2759.                                      rds1302_time();
  2760.                                          init_d2=1;
  2761.                                      dis_mode2();
  2762.                                          init_d2=0;
  2763.                                      while(gotkey()!=11);
  2764.                                      oth_run=0;
  2765.                                          save=110;
  2766.                                      clear_dis();
  2767.                                      nba_oth_dis();
  2768.                                    }
  2769.                                    else{ signs=r1302(d02_signs+1); nba_tim=0;return;}
  2770.                              }
  2771.                                  else{ key=save;goto ss;}
  2772.                            }
  2773.                            break;          
  2774.         }
  2775.         if(save==110)  break;
  2776.     }while(1);       
  2777.   }  
  2778. }
  2779. /*=============================================================================
  2780. 函数名称:设置功能
  2781. 功能描述:系统状态设置  
  2782. 全局变量:signs
  2783. 参数说明:见函数
  2784. 返回说明:无
  2785. 设 计 人:LIJH
  2786. 版    本:1.0
  2787. 说    明:
  2788. =============================================================================*/
  2789. /*设置调整内容 参数格式:选中设置项,设置项子值*/
  2790. uchar set_dis(uchar menu,uchar sub)
  2791. {
  2792.   uchar save;
  2793.   con_disp(0xff,0xff,0x8e,0x80,2,16);
  2794.   con_disp(0x00,0x00,0x8a,0x80,4,16);
  2795.   display_cnasc(0x96,1,"\x1e ");
  2796.   display_cnasc(0x9e,1,"\x1f ");
  2797.   display_cnasc(0x92,1,"  ");
  2798.   display_cnasc(0x9a,1,"  ");
  2799.   display_cnasc(0x8d,1,"\x11 ");
  2800.   display_cnasc(0x8a,1,"  ");
  2801.   while(1)
  2802.   {
  2803.     if(menu<2)
  2804.       display_cnasc(0x8e,2,set_bl_dm[menu][sub]);
  2805.     else
  2806.           display_cnasc(0x8e,2,set_mka[menu-2][sub]);
  2807.         save=gotkey();
  2808.         if(save==5)
  2809.         {
  2810.           key_dis(0x96);
  2811.           if(sub==0&&menu<2) sub=2;
  2812.           else if(sub==0&&menu>1) sub=1;
  2813.           else sub--;
  2814.     }
  2815.         if(save==2)
  2816.         {
  2817.           key_dis(0x9e);
  2818.           if(sub==2&&menu<2) sub=0;
  2819.           else if(sub==1&&menu>1) sub=0;
  2820.           else sub++;
  2821.         }
  2822.         if(save==1||save==11)
  2823.         {
  2824.           display_cnasc(0x8d,1,"\x04 ");
  2825.         delay(180000);
  2826.           con_disp(0x00,0x00,0x8e,0x80,2,16);
  2827.       con_disp(0xff,0xff,0x8a,0x80,4,16);
  2828.       display_cnasc(0x92,1,"\x1e ");
  2829.       display_cnasc(0x9a,1,"\x1f ");
  2830.       display_cnasc(0x96,1,"  ");
  2831.       display_cnasc(0x9e,1,"  ");
  2832.           display_cnasc(0x8a,1,"【");
  2833.           display_cnasc(0x8d,3,"】\x10 \x04 ");
  2834.           return(sub);          // 返回设置值
  2835.         }
  2836.   }
  2837. }
  2838. /************************设置调整*************************/
  2839. void set_func(void)
  2840. {
  2841.   uchar d,key,save;
  2842.   display_cnasc(0x81,2,"设置");
  2843.   dis_title();
  2844.   display_cnasc(0x88,8,selected[1]);
  2845.   con_disp(0xff,0xff,0x8a,0x80,4,16);
  2846.   save=d=0;
  2847.   do
  2848.   {          
  2849.         display_cnasc(0x93,2,set_menu[index_s[save].lnum]);
  2850.         display_cnasc(0x8b,2,set_menu[save]);
  2851.         display_cnasc(0x9b,2,set_menu[index_s[save].rnum]);
  2852.         d=save;
  2853.         while(1)
  2854.         {
  2855.           key=gotkey();
  2856.           if(key==11||key==3){ enter_dis();break;}
  2857.           if(key==2){save=index_s[d].lnum;key_dis(0x92); break;}
  2858.           if(key==5){save=index_s[d].rnum;key_dis(0x9a); break;}
  2859.           if(key==1){ wds1302_data(d02_signs,signs); return;}
  2860.     }
  2861.         if(key==11||key==3)
  2862.         {
  2863.       save=0;
  2864.       for(key=0;key<2;key++)  //  进行两次比较 首次为现时值 其次为设定置更改
  2865.       {
  2866.         switch(d)
  2867.         {
  2868.           case 0:
  2869.                           if(key==1)
  2870.                           {
  2871.                                     bl0=bl1=0;
  2872.                                         if(save==1) bl0=1;
  2873.                                         if(save==2)        bl1=1;
  2874.                           }
  2875.                       else
  2876.                                   {if(bl0) save=1; if(bl1) save=2;}
  2877.                                   if(bl1) lcd_bl=close;
  2878.                                   else lcd_bl=open;
  2879.                               break;
  2880.               case 1:
  2881.                           if(key==1)
  2882.                           {
  2883.                                     di0=di1=0;
  2884.                                         if(save==1) di0=1;
  2885.                                         if(save==2)        di1=1;
  2886.                           }
  2887.                               else {if(di0) save=1; if(di1) save=2;}
  2888.                               break;
  2889.               case 2:
  2890.                           if(key==1) meu=(bit)save;
  2891.                       else {if(meu) save++;}             
  2892.                               break;
  2893.           case 3:
  2894.                           if(key==1) keb=(bit)save;
  2895.                       else{if(keb) save++;}             
  2896.                               break;
  2897.           case 4:
  2898.                           if(key==1) als=(bit)save;
  2899.                       else{if(als) save++;}             
  2900.                               break;
  2901.           case 5: wds1302_data(d02_signs,signs);
  2902.                       return;
  2903.         }
  2904.         if(key==0) save=set_dis(d,save);
  2905.       }
  2906.           save=d;
  2907.         }
  2908.   }while(1);
  2909. }
  2910. /*=============================================================================
  2911. 函数名称:保密功能
  2912. 功能描述:系统重设  密码锁  密码更改  
  2913. 全局变量:resu  
  2914. 参数说明:见函数
  2915. 返回说明:无
  2916. 设 计 人:LIJH
  2917. 版    本:1.0
  2918. =============================================================================*/
  2919. /*********************密码整理**********************/
  2920. void passwork_finish()
  2921. {
  2922.   uchar i;
  2923.   for(i=0;i<6;i+=2)
  2924.   {
  2925.     resu[i]<<=4;
  2926.         resu[i]+=resu[i+1];
  2927.   }
  2928. }
  2929. /*****************************读取密码***************/
  2930. uchar input_passwork()
  2931. {
  2932.   uchar i,save[2];
  2933.   save[0]=' ';
  2934.   display_cnasc(0x9d,3,"(./S)\x10");
  2935.   for(i=0;i<6;i++)
  2936.   {
  2937.     while(1)
  2938.         {
  2939.           resu[i]=gotkey();
  2940.           if(resu[i]>=0&&resu[i]<10) break;
  2941.           if(resu[i]==10) return 10;
  2942.         }
  2943.     save[1]=char_num[resu[i]];
  2944.         display_cnasc(0x89+i,1,save);
  2945.         delay(120000);
  2946.         display_cnasc(0x89+i,1," *");
  2947.   }
  2948.   return 11;
  2949. }
  2950. /*****************密码确认**********************/
  2951. void input_second_passwork()
  2952. {
  2953.   uchar i,save[2];
  2954.   save[0]=' ';
  2955.   display_cnasc(0x89,6,"            ");
  2956.   for(i=0;i<6;i++)
  2957.   {   
  2958.         if(resu[i]!=gotkey())        break;
  2959.         save[1]=char_num[resu[i]];
  2960.         display_cnasc(0x89+i,1,save);
  2961.         delay(120000);
  2962.         display_cnasc(0x89+i,1," *");
  2963.   }
  2964.   if(i!=6)
  2965.   {
  2966.     display_cnasc(0x89,6,"密码不相同!");
  2967.         delay(300000);
  2968.         display_cnasc(0x9a,6,"任意键 \x10    ");
  2969.         while(gotkey()==0xf0);
  2970.         return;
  2971.   }
  2972.   else
  2973.   {
  2974.         passwork_finish();
  2975.         for(i=0;i<6;i+=2)
  2976.           wds1302_data(d02_passw+i,resu[i]);
  2977.         for(i=0;i<6;i+=2)
  2978.           if(resu[i]!=r1302(d02_passw+i+1)) break;
  2979.         if(i==6)
  2980.          {display_cnasc(0x98,8,"\x10 更改成功!(OK) ");
  2981.           while(gotkey()!=11);return;}
  2982.         else
  2983.           display_cnasc(0x9a,6,"更改失败!  ");
  2984.   }
  2985.   delay_pw();
  2986. }                               
  2987. /**********************密码比较*********************/
  2988. uchar passwork_comp()
  2989. {
  2990.   uchar i;
  2991.   passwork_finish();
  2992.   for(i=0;i<6;i+=2)
  2993.         if(resu[i]!=r1302(d02_passw+i+1)) break;
  2994.   if(i==6)         return 1;
  2995.   else
  2996.   {
  2997.     display_cnasc(0x89,6,"  密码错误!");
  2998.         delay_pw();
  2999.         display_cnasc(0x89,6,"            ");
  3000.         return 110;
  3001.   }
  3002. }
  3003. /**********************保密导航**********************/
  3004. void passw_func(void)
  3005. {
  3006.   uchar save,d,key;
  3007.   d=0;save=0;
  3008.   do
  3009.   {
  3010.     clear_dis();
  3011.         display_cnasc(0x81,2,"保密");
  3012.     dis_title();
  3013.     display_cnasc(0x88,8,selected[0]);
  3014.     con_disp(0xff,0xff,0x8a,0x80,5,16);
  3015.     do
  3016.     {          
  3017.           display_cnasc(0x93,3,secrets_menu[index_p[save].lnum]);
  3018.           display_cnasc(0x8b,3,secrets_menu[save]);
  3019.           display_cnasc(0x9b,3,secrets_menu[index_p[save].rnum]);  
  3020.           d=save;
  3021.           while(1)
  3022.           {
  3023.             key=gotkey();
  3024.             if(key==11||key==3){enter_dis();break;}
  3025.             if(key==2){save=index_p[d].rnum; key_dis(0x9a);break;}
  3026.             if(key==5){save=index_p[d].lnum; key_dis(0x92);break;}
  3027.                 if(key==1){return;}
  3028.       }
  3029.       if(key==11||key==3)
  3030.           {       
  3031.                 if(d==3) return;               
  3032.                 clear_dis();
  3033.                 dis_title_e();
  3034.         switch(d)
  3035.         {
  3036.           case 0:
  3037.                           display_cnasc(0x82,3,"密码锁");
  3038.                                   display_cnasc(0x90,5,"输入密码:");
  3039.                                   while(1)
  3040.                                   {
  3041.                                     key=input_passwork();
  3042.                                     if(key==10) break;
  3043.                                     key=passwork_comp();
  3044.                                     if(key==1)
  3045.                             {
  3046.                                       display_cnasc(0x90,8,"处开启状态,按键");
  3047.                               display_cnasc(0x88,8,"□1-常开□2-关闭");
  3048.                                       display_cnasc(0x98,8,"■自动延时30秒  ");
  3049.                                           pw_oc=open;
  3050.                                       save1=i=0;   
  3051.                                       lock_op=1;   // 开启标记等待延时
  3052.                                       while(1)
  3053.                                       {
  3054.                                             key=gotkey(); // 返回255为延时时间到达
  3055.                                             if(key==255){ lock_op=0;pw_oc=close;break;}
  3056.                                             if(key==1)
  3057.                                             {
  3058.                                               display_cnasc(0x88,1,"■");
  3059.                                               display_cnasc(0x98,1,"□");
  3060.                                               lock_op=0;
  3061.                                             }
  3062.                                             if(key==2)
  3063.                                             {
  3064.                                               display_cnasc(0x88,1,"□");
  3065.                                                   display_cnasc(0x98,1,"□");
  3066.                                                   display_cnasc(0x8c,1,"■");
  3067.                                                   delay(360000);
  3068.                                                   clear_dis();
  3069.                                               dis_title_e();
  3070.                                   display_cnasc(0x82,3,"密码锁");
  3071.                                               display_cnasc(0x90,5,"密码锁将在");
  3072.                                                   display_cnasc(0x8a,6," 5秒后关闭:");
  3073.                                               for(save=0;save<5;save++)
  3074.                                               {
  3075.                                                 display_cnasc(0x99+save,1,"→");
  3076.                                                     delay_pw();
  3077.                                               }
  3078.                                                   display_cnasc(0x9e,1,"√");
  3079.                                                   pw_oc=open;
  3080.                                                   delay(180000);
  3081.                                                   pw_oc=close;
  3082.                                               lock_op=0;
  3083.                                               break;
  3084.                                             }
  3085.                                       }
  3086.                                           break;
  3087.                                     }
  3088.                                   }
  3089.                                break;
  3090.               case 1:
  3091.                           display_cnasc(0x82,3,"更  改");
  3092.                                   display_cnasc(0x90,6,"输入旧密码:");
  3093.                                   while(1)
  3094.                                   {
  3095.                                     key=input_passwork();
  3096.                                     if(key==10) break;
  3097.                                     key=passwork_comp();
  3098.                                     if(key==1)
  3099.                                     {
  3100.                                       display_cnasc(0x92,1,"新");
  3101.                                           display_cnasc(0x89,6,"            ");
  3102.                                       key=input_passwork();
  3103.                                           if(key==10) break;
  3104.                                           display_cnasc(0x90,6,"确认密码:  ");
  3105.                                           input_second_passwork();
  3106.                                           break;               
  3107.                                     }
  3108.                                   }
  3109.                                   break;
  3110.               case 2:
  3111.                           display_cnasc(0x82,3,"初始化");
  3112.                             display_cnasc(0x91,6,"是否初始化? ");
  3113.                   display_cnasc(0x89,6,"Y(OK)\\N(./S)");
  3114.                                   while(1)
  3115.                                   {
  3116.                                     key=gotkey();
  3117.                                         if(key==11)
  3118.                                         {
  3119.                                           clear_dis();
  3120.                                           dis_title_e();
  3121.                                           display_cnasc(0x82,3,"初始化");
  3122.                                           display_cnasc(0x90,5,"输入密码:");
  3123.                                           do
  3124.                                           {
  3125.                                             key=input_passwork();
  3126.                                             if(key==10) break;
  3127.                                             key=passwork_comp();
  3128.                                             if(key==1)
  3129.                                             {
  3130.                                                   display_cnasc(0x90,5,"密码正确!");
  3131.                                                   display_cnasc(0x89,7,"\x10 初始化中... ");
  3132.                                                   init_ds1302();
  3133.                                                   rds1302_data();
  3134.                                                   delay_pw();
  3135.                                                   display_cnasc(0x9a,6,"\x10 完成!(OK)");
  3136.                                                   while(gotkey()!=11);
  3137.                                                   key=10;
  3138.                                                   break;
  3139.                                             }
  3140.                                           }while(1);
  3141.                                         }
  3142.                                         if(key==10) break;
  3143.                                   }
  3144.                                   break;
  3145.                 }
  3146.                 key=99;save=d;
  3147.           }
  3148.           if(key==99) break;
  3149.         }while(1);
  3150.   }while(1);
  3151. }
  3152. /*=============================================================================
  3153. 函数名称:版本信息
  3154. 功能描述:  
  3155. 全局变量:
  3156. 参数说明:见函数
  3157. 返回说明:无
  3158. 设 计 人:LIJH
  3159. 版    本:1.0
  3160. 说    明:
  3161. =============================================================================*/
  3162. void version_func(void)
  3163. {
  3164.   uchar save,v=0;
  3165.   display_cnasc(0x82,3,"版  本");
  3166.   dis_title_e();
  3167.   do
  3168.   {
  3169.         display_cnasc(0x90,7,version[v]);
  3170.         display_cnasc(0x88,7,version[v+1]);
  3171.         display_cnasc(0x98,7,version[v+2]);
  3172.         if(v!=0) display_cnasc(0x97,1," \x1e");
  3173.         else if(v==0)
  3174.           display_cnasc(0x97,1,"  ");
  3175.         else display_cnasc(0x97,1,"  ");
  3176.         if(v!=7) display_cnasc(0x9f,1," \x1f");
  3177.         else display_cnasc(0x9f,1,"  ");
  3178.         save=gotkey();
  3179.         if(save==5&&v<7)
  3180.         {
  3181.           display_cnasc(0x9f,1," \x04");
  3182.       delay(180000);
  3183.           v++;
  3184.         }
  3185.         if(save==2&&v>0)
  3186.         {
  3187.           display_cnasc(0x97,1," \x04");
  3188.       delay(180000);
  3189.           v--;
  3190.         }
  3191.         if(save==1) return;
  3192.         if((save==11||save==3)&&v==7)
  3193.         {
  3194.           display_cnasc(0x9e,2,") \x09 ");
  3195.       delay(180000);
  3196.           return;          
  3197.         }
  3198.   }while(1);
  3199. }
  3200. /*=====================================================================================
  3201. 函数名称:系统主函数
  3202. 功能描述:  
  3203. 全局变量:
  3204. 参数说明:见函数
  3205. 返回说明:无
  3206. 设 计 人:LIJH
  3207. ===========================================================================*/
  3208. main()
  3209. {
  3210.   uchar key;                                                          
  3211.   init_lcd();                                                  // 初始化lcd
  3212.   lcd_bl=als_tl=als_th=buzzer=pw_oc=close;
  3213.   key=r1302(d02_initsi+1);            // 读出1302初始化标记位
  3214.   if(bl1) lcd_bl=close;
  3215.   else lcd_bl=open;
  3216.   display_cnasc(0x92,4,"欢迎使用");   // 显示开机画面“欢迎使用”
  3217.   display_cnasc(0x9d,3,"-zzh");
  3218.   if(key!=0xb4)  init_ds1302();       // DS1302初始化
  3219.   rds1302_data();                                          // 开机读回设置数据
  3220.   rds1302_date();
  3221.   rds1302_time();                     // 读日期时间   
  3222.   if(!ds18b20) init_ds18b20();                  // 初始化18b20
  3223.   if(ds18b20)
  3224.   {                                              
  3225.         ds18b20_func();                                           // 读出温度
  3226.   }
  3227.   time_init();                         // 定时器初始化
  3228.   delay_pw();resu[11]=0;
  3229.   while(1)
  3230.   {  
  3231.         EA=1;
  3232.         TR0=1;
  3233.         dis_sig=1;       
  3234.         clear_dis();
  3235.         if(di0){init_d2=1;dis_mode2();init_d2=0;}
  3236.     else if(di1) dis_mode3();
  3237.     else dis_mode1();       
  3238.         do
  3239.         {
  3240.           key=gotkey();
  3241.           if(key==255)                        // 键盘密码输入
  3242.           {
  3243.                 TR0=0;
  3244.                 dis_sig=0;
  3245.                 clear_dis();
  3246.                 dis_title_e();
  3247.                 display_cnasc(0x82,3,"键盘锁");
  3248.                 display_cnasc(0x90,5,"输入密码:");
  3249.                 while(1)
  3250.                 {
  3251.                   keb=0;
  3252.                   key=input_passwork();
  3253.                   if(key==10) {keb=1;resu[11]=2;break;}
  3254.                   key=passwork_comp();
  3255.                   if(key==1) {keb=1;resu[11]=0;break;}           
  3256.                 }
  3257.                 rds1302_date();
  3258.         rds1302_time();
  3259.             save_time=now;
  3260.                 break;
  3261.           }
  3262.           if(key==11)
  3263.           {
  3264.             dis_menu_key(1);
  3265.                 delay(210000);
  3266.                 do
  3267.                 {
  3268.                   dis_sig=0;
  3269.                   TR0=0;
  3270.                   clear_dis();
  3271.                   key=dis_menu();
  3272.                   clear_dis();
  3273.                   if(key==0) adjust_func();
  3274.                   else if(key==1) // 调用相应程序功能S
  3275.                   {
  3276.                     while(1)
  3277.                         {
  3278.                           clear_dis();
  3279.                       key=tool_func();
  3280.                           if(key==4) break;
  3281.                           clear_dis();
  3282.                           switch(key)
  3283.                           {
  3284.                             case 0:        calculator();
  3285.                                         break;
  3286.                                 case 1: temp_func();
  3287.                                             break;
  3288.                                 case 2: alarm_func();
  3289.                                         break;
  3290.                                 case 3: nba_timer();
  3291.                                         break;
  3292.                           }
  3293.                         }
  3294.                   }
  3295.                   else if(key==2)        set_func();
  3296.                   else if(key==3)        passw_func();
  3297.                   else if(key==4) version_func();
  3298.                   else
  3299.                   {
  3300.                     rds1302_date();
  3301.             rds1302_time();
  3302.                         save_time=now;
  3303.                         resu[11]=0;
  3304.                         dis_sig=1;
  3305.                         break;
  3306.                   }
  3307.                 }while(1);
  3308.           }
  3309.           if(dis_sig) break;
  3310.         }while(1);
  3311.   }
  3312. }
复制代码



评分

参与人数 1黑币 +5 收起 理由
madell + 5 赞一个!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏13 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:77776 发表于 2015-4-23 21:42 | 只看该作者
怎么又没有电路图,还得自己根据程序来找线路不过,还是谢谢了,51黑有你更精彩…………
回复

使用道具 举报

板凳
ID:92297 发表于 2015-10-12 23:36 | 只看该作者
感谢楼主,正要做一个实时时钟的,先下下来看看~
回复

使用道具 举报

地板
ID:92297 发表于 2015-10-12 23:41 | 只看该作者
感谢楼主,正要做一个实时时钟的,先下下来看看~
回复

使用道具 举报

5#
ID:44267 发表于 2015-10-18 16:09 | 只看该作者
感谢楼主,正要做一个实时时钟的,先下下来看看~
回复

使用道具 举报

6#
ID:79544 发表于 2015-10-21 00:12 | 只看该作者
好强大的功能,谢谢分享。下进去显示正常就是按键不工作,你的按键是接在P2.0-P2.3IO口吗?请指教谢谢!
回复

使用道具 举报

7#
ID:44267 发表于 2015-10-28 10:54 | 只看该作者
好东西顶起
回复

使用道具 举报

8#
ID:92810 发表于 2015-11-21 03:05 | 只看该作者
好多啊!!可不可以求打包啊??
回复

使用道具 举报

9#
ID:92810 发表于 2015-11-21 03:05 | 只看该作者
打包的话就更好了。。。。
回复

使用道具 举报

10#
ID:53825 发表于 2015-11-21 17:35 | 只看该作者
厉害谢谢你的分享
回复

使用道具 举报

11#
ID:99379 发表于 2015-12-24 12:55 | 只看该作者
谢谢分享!
回复

使用道具 举报

12#
ID:94208 发表于 2015-12-27 13:54 | 只看该作者
太牛了,程序写这么长
回复

使用道具 举报

13#
ID:64089 发表于 2015-12-30 13:46 | 只看该作者
非常给力的程序,支持作者无私奉献
回复

使用道具 举报

14#
ID:102817 发表于 2016-1-11 21:46 | 只看该作者
不错的学习案例
回复

使用道具 举报

15#
ID:75228 发表于 2016-2-28 15:33 | 只看该作者
楼主可不可以分享一下原理图,新手想做一个练练手,谢谢
回复

使用道具 举报

16#
ID:80921 发表于 2016-3-7 12:52 | 只看该作者
好东西
回复

使用道具 举报

17#
ID:110516 发表于 2016-3-24 12:05 | 只看该作者
厲害, 學習
回复

使用道具 举报

18#
ID:110816 发表于 2016-3-25 23:40 | 只看该作者
很厉害的样子  学习了
回复

使用道具 举报

19#
ID:99056 发表于 2016-3-30 23:04 | 只看该作者

好东西,值得学习
回复

使用道具 举报

20#
ID:111703 发表于 2016-3-31 23:26 | 只看该作者
对于初学者的我来说,虽说内容很多。但很赞
回复

使用道具 举报

21#
ID:111743 发表于 2016-4-1 13:19 | 只看该作者
楼主分享一下原理图吧,跪求啊
回复

使用道具 举报

22#
ID:114967 发表于 2016-4-18 16:02 | 只看该作者
正在找这个 谢谢了~学习~
回复

使用道具 举报

23#
ID:147403 发表于 2016-11-11 14:11 来自手机 | 只看该作者
刚好需要,多谢楼主
回复

使用道具 举报

24#
ID:117855 发表于 2016-11-14 19:08 | 只看该作者
好东西顶起
回复

使用道具 举报

25#
ID:152397 发表于 2016-12-5 21:39 | 只看该作者
求电路图
回复

使用道具 举报

26#
ID:153206 发表于 2016-12-8 16:04 来自手机 | 只看该作者
求电路图呀,楼主啊
回复

使用道具 举报

27#
ID:138443 发表于 2016-12-9 21:24 | 只看该作者
谢谢分享,支持支持51
回复

使用道具 举报

28#
ID:3802 发表于 2019-1-25 10:54 | 只看该作者
值得拥有
回复

使用道具 举报

29#
ID:479216 发表于 2019-2-22 10:56 来自手机 | 只看该作者
感谢楼主,正要在考虑要做个什么,对我有很大启发
回复

使用道具 举报

30#
ID:481306 发表于 2019-2-27 08:40 | 只看该作者
发帖已经有3年多了,建议楼主放一下电路图。
回复

使用道具 举报

31#
ID:125158 发表于 2019-11-9 12:28 | 只看该作者
延时时间设置的数都不正确,
回复

使用道具 举报

32#
ID:125158 发表于 2019-11-9 12:30 | 只看该作者
xqtop 发表于 2019-2-27 08:40
发帖已经有3年多了,建议楼主放一下电路图。

程序都有误,自己按照程序硬件连接,自己画就成,你要不能画,你有程序也做不出来!
回复

使用道具 举报

33#
ID:690571 发表于 2020-2-11 15:47 | 只看该作者
感谢楼主,正要做一个实时时钟的,先下下来看看~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表