0.png (111.51 KB, 下載次數: 52)
下載附件
2017-3-5 23:12 上傳
0.png (64.66 KB, 下載次數: 34)
下載附件
2017-3-5 23:13 上傳
完整代碼下載:
時間溫度控制系統源代碼.zip
(225.76 KB, 下載次數: 98)
2017-3-5 23:15 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
原理圖:
時間溫度控制系統原理圖及元器件.pdf
(312.48 KB, 下載次數: 59)
2017-3-5 23:15 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
源程序部分內容預覽:
- /**************************************************************************************
- 程序名稱:
- 時間 溫度控制系統(128*64LCD+ds1302+ds18b20)
- 主要功能:
- 溫度計 時鐘 鬧鈴 密碼鎖 籃球器 計算器 溫度控制 鍵盤鎖 系統設置等。
- 主要說明:
- 程序全部定義在一個C文件中。
- 作者:
- JZHG
- 時間:
- 12.19
- 版本:
- JZHG-V1.0
- /**************************************************************************************/
- #include<reg52.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define time_count 0x3cb0 //時間計數
- #define close 1 //開始標志
- #define open 0 //結束標志
- #define keyboard P1 //鍵盤數據口
- /*****************狀態控制及溫感器總線定義*****************************/
- sbit b20_io=P0^0; //ds18b20總線
- sbit pw_oc=P0^4; //密碼鎖開啟控制燈
- sbit buzzer=P0^5; //喇叭端口
- sbit lcd_bl=P0^6; //背光控制端口
- sbit als_th=P3^6; //上限溫度警報
- sbit als_tl=P3^7; //下限溫度警報
- /******************LCD12864定義**************************/
- #define lcd_data P2//lcd數據口
- #define comm 0 //lcd指令
- #define dat 1 //lcd數據
- sbit lcd_rst=P0^7; //lcd復位
- sbit lcd_e =P3^0; //lcd使能
- sbit lcd_rw =P3^1; //lcd讀寫
- sbit lcd_rs =P3^2; //lcd數據指令
- sbit busy =P2^7; //忙碌位
- /*****************ds1302定義**************************/
- sbit d02_rst =P0^1; //ds1302使能
- sbit d02_data=P0^2; //ds1302數據
- sbit d02_sclk=P0^3; //ds1302時鐘
- #define d02_wrc 0x8e //ds1302讀寫控制
- #define d02_year 0x8c //年
- #define d02_weeks 0x8a //星期
- #define d02_month 0x88 //月
- #define d02_day 0x86 //日
- #define d02_hour 0x84 //時
- #define d02_minute 0x82 //分
- #define d02_second 0x80 //秒
- #define d02_signs 0xc0 //系統狀態(記錄設計標記)
- #define d02_passw 0xc2 //密碼寄存器首位(有3位下位地址加2,初始值為741456)
- #define d02_alm 0xc8 //鬧鈴時間小時位(下位為分鐘下位加2)
- #define d02_temp 0xcc //溫度上限警報(有兩位下位加2)
- #define d02_initsi 0xd4 //1302初始化標志(為0xb4,說明已經初始化)
- #define ret_ds1302() d02_rst=0;d02_sclk=0;d02_rst=1 //1302讀寫復位
- #define end_ds1302() d02_sclk=1;d02_rst=0 //1302讀寫結束
- /*================================= 全局變量定義 ==================================*/
- typedef struct // 定義時間類型
- {
- uchar hour;
- uchar minute;
- uchar second;
- }time;
- typedef struct // 定義日期類型
- {
- uchar year;
- uchar month;
- uchar day;
- uchar week;
- }date;
- typedef union // 定義溫度類型
- {
- int temp_data;
- uchar t_data[2];
- }trdata;
- trdata bdata temp; // 溫度警報值暫存
- date idata today={'8',1,1,1}; // 日期暫存
- time idata now={0x12,0,0} , save_time={0x12,0,0};
- // 時間暫存(now是讀出時間暫存 save_time上一時間暫存)
- uchar idata time_tick=20,time_tick1=20,alarm_time[2],als_temp[2],
- // T0中斷數, T1中斷數, 鬧鈴時間, 警報溫度
- bl_delay=15,temp_delay=5,opera[2][12],resu[12],
- // 背光時間, 溫度更新時間, 計算器數據寄存, 結果寄存
- i,j,save1,temp_min=0;
- // 計算器i/j下標,中間暫存,溫度更新(分)
- uchar bdata signs=0; // 系統標記寄存器
- sbit bl1=signs^7; // bl1,bl0背光選擇位(00 延時,01 常開,10 關閉)
- sbit bl0=signs^6;
- sbit di1=signs^5; // di1,di0顯示模式(00模式1,01模式2,10模式3)
- sbit di0=signs^4;
- sbit meu=signs^3; // 菜單顯示方式(0 圖片,1 文字)
- sbit keb=signs^2; // 鍵盤鎖(0 無鎖,1加鎖)
- sbit alm=signs^1; // 鬧鐘啟動位(0 關閉,1開啟)
- sbit als=signs^0; // 報警啟動位(0 啟動,1關閉)
- uint bdata run_signs=0; // 運行標記寄存器
- sbit ds18b20=run_signs^0; // 溫感器存在標記(0不存在,1存在)
- sbit temp_pn=run_signs^1; // 溫度正負號標記(0正,1負)
- sbit temprun=run_signs^2; // 溫感器運行標記(0否,1啟動)
- sbit nba_tim=run_signs^3; // 籃球計時器標記(0關閉,1啟動)
- sbit adju_si=run_signs^4; // 數字更改連續標記(1連續)
- sbit cal_del=run_signs^5; // 計算器顯示點標記(0沒有顯示)
- sbit cal_run=run_signs^6; // 計算完畢標記(1有效)
- sbit oth_run=run_signs^7; // 其他標記
- sbit alm_run=run_signs^8; // 鬧鐘時間到達標記(1有效)
- sbit dis_sig=run_signs^9; // 顯示時間標記(1有效)
- sbit lock_op=run_signs^10; // 關鎖時間到標記(1有效)
- sbit b20time=run_signs^11; // 溫感器重新讀溫度標記(1有效)
- sbit t0_isr =run_signs^12; // TO中斷標記(1有效(1s)
- sbit thl_als=run_signs^13; // 溫度警報標記
- sbit init_d2=run_signs^14; // 模式2初始顯示
- sbit buzstop=run_signs^15; // 蜂鳴器停止標記
- /*================================= 字體顯示代碼 ==================================*/
- uchar code weeks[7][2]={"一","二","三","四","五","六","日"}; // 星期 //圖片中文
- uchar code menu_cn[6][8]={"調 整","工 具","設 置","保 密","版 本","退 出"};
- uchar code menu_cn_2[6][6]={"調 整","工 具","設 置","保 密","版 本","退 出"};// 菜單文字
- uchar code selected[2][16]={{"進入【 】\x04 "},{"設置【 】\x10 \x04 "}}; // 選框
- uchar code secrets_menu[4][6]={"開 鎖","更 改","初始化","退 出"}; // 保密菜單中文
- uchar code tool_menu[5][6]={"計算器","溫度計","鬧 鈴","籃球器","退 出"}; // 工具菜單中文
- uchar code char_num[10]={"0123456789"}; // 數字顯示代碼 // 每月天數
- uchar code dayofmonth[12]={0x31,0x28,0x31,0x30,0x31,0x30,0x31,0x31,0x30,0x31,0x30,0x31};
- uchar code key_code[]={0xD7,0x7E,0x7D,0x7B,0xBE,0xBD,0xBB,0xDE,0xDD,0xDB,0xB7,0x77,0xEE,0xED,0xEB,0xE7};
- uchar code ksp[4]={0x7F,0xBF,0xDF,0xEF}; // 按鍵掃描代碼
- uchar code tool_cal[4][2]={"+ ","- ","* ","/ "}; // 運算符號
- uchar code alm_sign[2][2]={"關","開"}; // 鬧鈴開關
- uchar code set_bl_dm[2][3][4]={{"30秒","常開","關閉"},{"模01","模02","模03"}};
- uchar code set_mka[3][2][4]={{"圖片","文字"},{"解鎖","加鎖"},{"開啟","關閉"}};
- uchar code nba_oppo[8][2]={"紅","白","藍","綠","紫","灰","黃","黑"};
- uchar code set_menu[6][4]={"背光","顯示","菜單","鍵盤","警報","退出"};
- uchar code version[9][16]={ // 版本信息
- {"湖南科技經貿學院"},
- {"電子信息工程學院"},
- {"11年電子技能大賽"},
- {" —10電子01班"},
- {"作者:蔣志高 "},
- {"版本:JZHG-V1.0 "},
- {" 2011/12/19 "},
- {"謝謝你的使用! "},
- {" (ok)\x10"},
- };
- uchar code timer_tips[12][16]={ // 籃球器使用說明
- {"使用方法: "},
- {" (+)(-)與(*)(/)"},
- {"分別是兩方的分數"},
- {"加與減,(7)鍵回退"},
- {"一秒,(8)鍵24秒復"},
- {"位,(9)鍵暫停與開"},
- {"始;暫停狀態下:"},
- {"按兩次(OK)鍵可返"},
- {"回時鐘模式-2界面"},
- {",(OK)鍵返回程序"},
- {"界面,(./S)鍵兩次"},
- {"退出程序. \x1f"}};
- /*================================= 操作導航代碼 ==================================*/
-
- typedef struct // 定義主菜單操作索引
- {
- uchar shaft_num;
- uchar left_num;
- uchar right_num;
- }menu_index;
- typedef struct // 定義導航更改索引
- {
- uchar lnum;
- uchar rnum;
- }index;
- menu_index code index_m[6]={{3,5,1},{4,0,2},{5,1,3},{0,2,4},{1,3,5},{2,4,0}}; // 菜單導航
- index code index_t[6]={{4,1},{0,2},{1,3},{2,4},{3,0}}; // 工具導航
- index code index_p[5]={{3,1},{0,2},{1,3},{2,0}}; // 保密導航
- index code index_s[6]={{5,1},{0,2},{1,3},{2,4},{3,5},{4,0}}; // 設置導航
- index code index_a[7]={{0x81,0x91},{0x83,0x91},{0x85,0x91},{0x89,0x81},
- {0x8b,0x81},{0x8d,0x81},{0x8f,0x91}}; // 調整下的坐標
- index code index_temp_set[3]={{0x8b,0x81},{0x8b,0x91},{0x8f,0x91}}; // 溫度設定下的坐標
- index code index_alm[3]={{0x8c,0x81},{0x8e,0x81},{0x8f,0x91}}; // 鬧鈴更改坐標
- index code index_cal[3]={{0x86,0x90},{0x8e,0x80},{0x8e,0x90}}; // 計算器操作坐標
- uchar code index_nba[4]={0x93,0x97,0x8b,0x8f}; // 籃球器設置導航
- /*========================== 菜單圖片(寬度x高度=32*24)=============================*/
- uchar code menu_pic[6][96]={
- {// 調整
- 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,
- 0x40,0x00,0x00,0x82,0x47,0xFF,0xE1,0xC2,0x47,0xFF,0xF3,0xE2,0x47,0x38,0x68,0x02,
- 0x46,0xDF,0x68,0x82,0x46,0xDF,0x69,0xC2,0x46,0xDE,0xE8,0x82,0x46,0xDD,0xE8,0x02,
- 0x46,0xDD,0xE8,0x02,0x47,0x3D,0xE8,0x02,0x47,0xFF,0xE8,0x02,0x47,0xFF,0xE9,0xC2,
- 0x42,0x00,0x18,0x02,0x41,0xFF,0xF3,0xE2,0x40,0x00,0x01,0xC2,0x40,0x00,0x00,0x82,
- 0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
-
- {// 工具
- 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x03,0x82,
- 0x41,0xF0,0x07,0xC2,0x43,0xFF,0xCF,0xE2,0x47,0x3F,0xFE,0x02,0x47,0x3F,0xFE,0x02,
- 0x43,0xFF,0xCF,0xE2,0x41,0xF0,0x0F,0xC2,0x40,0x00,0x03,0x82,0x40,0x00,0x00,0x02,
- 0x40,0x00,0x03,0xC2,0x40,0x00,0x03,0xC2,0x41,0x80,0x01,0x82,0x43,0xFF,0xF3,0xC2,
- 0x47,0xFF,0xFF,0xE2,0x47,0xFF,0xFF,0xE2,0x43,0xFF,0xF3,0xC2,0x41,0x80,0x01,0x82,
- 0x40,0x00,0x01,0x82,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
-
- {// 設置
- 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x43,0x18,0x00,0x02,
- 0x44,0xA4,0x0E,0x02,0x44,0xA4,0x1F,0x02,0x43,0x24,0x3F,0x02,0x40,0x00,0x7F,0x02,
- 0x40,0xF0,0xFC,0x02,0x43,0xF9,0xF0,0x02,0x43,0x03,0xE0,0x02,0x46,0x77,0x80,0x02,
- 0x46,0x7F,0x00,0x02,0x46,0x7E,0x00,0x02,0x46,0x7C,0x00,0x02,0x47,0x3D,0x00,0x02,
- 0x43,0x1D,0x81,0x22,0x43,0x81,0xB2,0x42,0x41,0xC3,0x4F,0xE2,0x40,0xFE,0x4A,0x42,
- 0x40,0x3C,0x32,0x42,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
-
- {// 保密
- 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0xFC,0x03,0x02,
- 0x41,0xFE,0x1F,0x02,0x43,0x87,0x03,0x82,0x43,0x03,0x03,0x02,0x43,0x03,0x03,0x02,
- 0x43,0x03,0x0F,0x02,0x43,0x03,0x03,0x02,0x43,0x03,0x03,0x02,0x47,0xFF,0x83,0x02,
- 0x47,0xFF,0x83,0x02,0x47,0xCF,0x83,0x02,0x47,0x87,0x83,0x02,0x47,0xCF,0x83,0x02,
- 0x47,0xCF,0x87,0x82,0x47,0xCF,0x8F,0xC2,0x47,0xCF,0x9C,0xE2,0x47,0xFF,0x8F,0xC2,
- 0x43,0xFF,0x07,0x82,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
-
- {// 版本
- 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x00,0x00,0x02,
- 0x40,0x0F,0x00,0x62,0x40,0x1D,0x80,0xF2,0x40,0x38,0x41,0xF2,0x40,0x70,0x23,0xE2,
- 0x40,0xE2,0x17,0xC2,0x41,0xE4,0x4F,0x82,0x41,0xF0,0x9F,0x02,0x41,0x59,0x16,0x02,
- 0x42,0x4C,0x1D,0x02,0x42,0x46,0x20,0x82,0x42,0x47,0x00,0x42,0x44,0x43,0x80,0xC2,
- 0x44,0x44,0xC1,0xC2,0x44,0xC8,0x63,0x82,0x45,0x50,0x37,0x02,0x46,0x60,0x1E,0x02,
- 0x40,0x40,0x0C,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00},
-
- {// 退出
- 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x40,0x00,0x00,0x02,0x40,0x40,0xFF,0xE2,
- 0x40,0x60,0x80,0x62,0x43,0xF0,0x80,0xA2,0x43,0xF0,0x81,0x22,0x40,0x60,0x82,0x22,
- 0x40,0x40,0x84,0x22,0x40,0x00,0x88,0x22,0x40,0x00,0x88,0x22,0x47,0xFF,0xF8,0x22,
- 0x47,0xFF,0xF8,0x22,0x46,0x2A,0x2A,0x22,0x46,0xE3,0x78,0x22,0x46,0x77,0x78,0x22,
- 0x46,0xE3,0x78,0x62,0x46,0x2A,0x38,0x82,0x47,0xFF,0xF9,0x02,0x47,0xFF,0xFA,0x02,
- 0x40,0x00,0x0C,0x02,0x40,0x00,0x00,0x02,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,}};
- /*================ 顯示模式2數字及溫度符號圖片(寬度x高度=16*32)=====================*/
- uchar code mode_2num[11][64]={
- {// 圖片數字0
- 0x00,0x00,0x3F,0xFC,0x5F,0xFA,0x6F,0xF6,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,
- 0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x60,0x06,0x40,0x02,0x00,0x00,
- 0x40,0x02,0x60,0x06,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,
- 0x70,0x0E,0x70,0x0E,0x70,0x0E,0x6F,0xF6,0x5F,0xFA,0x3F,0xFC,0x00,0x00,0x00,0x00},
-
- {// 圖片數字1
- 0x00,0x00,0x00,0x20,0x00,0x60,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,
- 0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0x60,0x00,0x20,0x00,0x00,0x00,0x20,
- 0x00,0x60,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,
- 0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0x60,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00},
-
- {// 圖片數字2
- 0x00,0x00,0x3F,0xFC,0x1F,0xFA,0x0F,0xF6,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,
- 0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x06,0x1F,0xFA,0x3F,0xFC,
- 0x5F,0xF8,0x60,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,
- 0x70,0x00,0x70,0x00,0x70,0x00,0x6F,0xF8,0x5F,0xFC,0x3F,0xFE,0x00,0x00,0x00,0x00},
-
- {// 圖片數字3
- 0x00,0x00,0x7F,0xFC,0x3F,0xFA,0x1F,0xF6,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,
- 0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x06,0x1F,0xFA,0x3F,0xFC,
- 0x1F,0xFA,0x00,0x06,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,
- 0x00,0x0E,0x00,0x0E,0x00,0x0E,0x1F,0xF6,0x3F,0xFA,0x7F,0xFC,0x00,0x00,0x00,0x00},
-
- {// 圖片數字4
- 0x00,0x00,0x40,0x02,0x60,0x06,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,
- 0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x60,0x06,0x5F,0xFA,0x3F,0xFC,
- 0x1F,0xFA,0x00,0x06,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,
- 0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x06,0x00,0x02,0x00,0x00,0x00,0x00},
-
- {// 圖片數字5
- 0x00,0x00,0x3F,0xFC,0x5F,0xF8,0x6F,0xF0,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,
- 0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x5F,0xF8,0x3F,0xFC,
- 0x1F,0xFA,0x00,0x06,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,
- 0x00,0x0E,0x00,0x0E,0x00,0x0E,0x0F,0xF6,0x1F,0xFA,0x3F,0xFC,0x00,0x00,0x00,0x00},
-
- {// 圖片數字6
- 0x00,0x00,0x3F,0xFC,0x5F,0xF8,0x6F,0xF0,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,
- 0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x5F,0xF8,0x3F,0xFC,
- 0x5F,0xFA,0x60,0x06,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,
- 0x70,0x0E,0x70,0x0E,0x70,0x0E,0x6F,0xF6,0x5F,0xFA,0x3F,0xFC,0x00,0x00,0x00,0x00},
-
- {// 圖片數字7
- 0x00,0x00,0x7F,0xFC,0x3F,0xFA,0x1F,0xF6,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,
- 0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x06,0x00,0x02,0x00,0x00,
- 0x00,0x02,0x00,0x06,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,
- 0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x06,0x00,0x02,0x00,0x00,0x00,0x00},
-
- {// 圖片數字8
- 0x00,0x00,0x3F,0xFC,0x5F,0xFA,0x6F,0xF6,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,
- 0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x60,0x06,0x5F,0xFA,0x3F,0xFC,
- 0x5F,0xFA,0x60,0x06,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,
- 0x70,0x0E,0x70,0x0E,0x70,0x0E,0x6F,0xF6,0x5F,0xFA,0x3F,0xFC,0x00,0x00,0x00,0x00},
-
- {// 圖片數字9
- 0x00,0x00,0x3F,0xFC,0x5F,0xFA,0x6F,0xF6,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,
- 0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x60,0x06,0x5F,0xFA,0x3F,0xFC,
- 0x1F,0xFA,0x00,0x06,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,
- 0x00,0x0E,0x00,0x0E,0x00,0x0E,0x1F,0xF6,0x3F,0xFA,0x7F,0xFC,0x00,0x00,0x00,0x00},
-
- {// 溫度符號
- 0x00,0x00,0x00,0x00,0x70,0xE0,0x53,0xF0,0x77,0xFA,0x0E,0x0E,0x0C,0x06,0x18,0x06,
- 0x18,0x02,0x38,0x02,0x30,0x00,0x30,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x60,0x00,
- 0x60,0x00,0x60,0x00,0x70,0x00,0x30,0x00,0x30,0x00,0x38,0x00,0x18,0x02,0x18,0x02,
- 0x0C,0x06,0x0E,0x06,0x07,0x0E,0x03,0xFA,0x00,0xF0,0x00,0x60,0x00,0x00,0x00,0x00}};
- /*===================== 顯示模式3數字圖片(寬度x高度=24*32)=========================*/
- uchar code mode_3num[10][96]={
- {// 圖片數字0
- 0x00,0x7E,0x00,0x01,0xE7,0x80,0x03,0xC3,0xC0,0x07,0x81,0xE0,0x0F,0x80,0xF0,0x0F,
- 0x00,0xF0,0x1F,0x00,0xF8,0x1E,0x00,0xF8,0x3E,0x00,0x78,0x3E,0x00,0x7C,0x3E,0x00,
- 0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x7C,
- 0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x3E,
- 0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x78,0x1E,0x00,0xF8,0x1F,0x00,0xF8,0x0F,0x00,
- 0xF0,0x0F,0x81,0xF0,0x07,0x81,0xE0,0x03,0xC3,0xC0,0x01,0xE7,0x80,0x00,0x7E,0x00},
- {// 圖片數字1
- 0x00,0x0C,0x00,0x00,0x1C,0x00,0x00,0x7C,0x00,0x07,0xFC,0x00,0x00,0x3C,0x00,0x00,
- 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,
- 0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,
- 0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,
- 0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,
- 0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3E,0x00,0x00,0x7F,0x00,0x07,0xFF,0xF0},
-
- {// 圖片數字2
- 0x00,0xFF,0x00,0x03,0xC7,0xC0,0x07,0x01,0xE0,0x0E,0x00,0xF0,0x1E,0x00,0xF8,0x1E,
- 0x00,0xF8,0x3E,0x00,0x78,0x3E,0x00,0x78,0x3F,0x00,0x78,0x3F,0x00,0x78,0x1F,0x00,
- 0xF8,0x00,0x00,0xF8,0x00,0x00,0xF0,0x00,0x01,0xF0,0x00,0x03,0xE0,0x00,0x03,0xC0,
- 0x00,0x07,0x80,0x00,0x0F,0x00,0x00,0x1E,0x00,0x00,0x3C,0x00,0x00,0x78,0x00,0x00,
- 0xF0,0x00,0x01,0xE0,0x00,0x03,0xC0,0x00,0x07,0x80,0x1C,0x07,0x00,0x1C,0x0E,0x00,
- 0x38,0x1C,0x00,0x38,0x3C,0x00,0x78,0x3F,0xFF,0xF8,0x3F,0xFF,0xF8,0x3F,0xFF,0xF8},
- {// 圖片數字3
- 0x00,0xFE,0x00,0x07,0x87,0x80,0x0F,0x03,0xC0,0x1E,0x01,0xE0,0x1E,0x01,0xF0,0x1E,
- 0x01,0xF0,0x1F,0x00,0xF0,0x1F,0x00,0xF0,0x1E,0x00,0xF0,0x00,0x00,0xF0,0x00,0x01,
- 0xF0,0x00,0x01,0xF0,0x00,0x03,0xE0,0x00,0x03,0xC0,0x00,0x0F,0x00,0x00,0xFE,0x00,
- 0x00,0x07,0x80,0x00,0x01,0xE0,0x00,0x00,0xF0,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,
- 0x00,0x78,0x00,0x00,0x7C,0x1E,0x00,0x7C,0x3F,0x00,0x7C,0x3F,0x00,0x7C,0x3F,0x00,
- 0x78,0x3E,0x00,0xF8,0x1E,0x00,0xF0,0x0F,0x01,0xE0,0x07,0x87,0xC0,0x01,0xFF,0x00},
- {// 圖片數字4
- 0x00,0x03,0xC0,0x00,0x03,0xC0,0x00,0x07,0xC0,0x00,0x0F,0xC0,0x00,0x0F,0xC0,0x00,
- 0x1F,0xC0,0x00,0x3F,0xC0,0x00,0x3F,0xC0,0x00,0x77,0xC0,0x00,0x77,0xC0,0x00,0xE7,
- 0xC0,0x01,0xC7,0xC0,0x01,0xC7,0xC0,0x03,0x87,0xC0,0x07,0x07,0xC0,0x07,0x07,0xC0,
- 0x0E,0x07,0xC0,0x1E,0x07,0xC0,0x1C,0x07,0xC0,0x38,0x07,0xC0,0x38,0x07,0xC0,0x7F,
- 0xFF,0xFE,0x7F,0xFF,0xFE,0x00,0x07,0xC0,0x00,0x07,0xC0,0x00,0x07,0xC0,0x00,0x07,
- 0xC0,0x00,0x07,0xC0,0x00,0x07,0xC0,0x00,0x07,0xC0,0x00,0x07,0xE0,0x00,0x7F,0xFE},
- {// 圖片數字5
- 0x0F,0xFF,0xF8,0x0F,0xFF,0xF8,0x0F,0xFF,0xF8,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,
- 0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,
- 0x00,0x0E,0x7F,0x00,0x0D,0xFF,0xC0,0x0F,0xC3,0xE0,0x1F,0x01,0xF0,0x1E,0x00,0xF8,
- 0x1E,0x00,0xF8,0x00,0x00,0x78,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,
- 0x00,0x7C,0x1E,0x00,0x7C,0x3F,0x00,0x7C,0x3F,0x00,0x78,0x3F,0x00,0x78,0x3E,0x00,
- 0xF8,0x1E,0x00,0xF0,0x1E,0x01,0xF0,0x0E,0x01,0xE0,0x07,0x87,0xC0,0x00,0xFF,0x00},
- {// 圖片數字6
- 0x00,0x3F,0xC0,0x00,0xF1,0xE0,0x03,0xC1,0xF0,0x07,0x81,0xF8,0x07,0x01,0xF8,0x0F,
- 0x00,0xF0,0x1F,0x00,0x00,0x1E,0x00,0x00,0x1E,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,
- 0x00,0x3E,0x00,0x00,0x3E,0x3F,0x80,0x3E,0xFF,0xE0,0x3F,0xE3,0xF0,0x3F,0x80,0xF8,
- 0x3F,0x00,0xF8,0x3F,0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x7C,0x3E,0x00,0x3C,0x3E,
- 0x00,0x3C,0x3E,0x00,0x3C,0x3E,0x00,0x3C,0x3E,0x00,0x7C,0x1E,0x00,0x7C,0x1F,0x00,
- 0x78,0x0F,0x00,0x78,0x0F,0x80,0xF0,0x07,0xC0,0xE0,0x03,0xE3,0xC0,0x00,0xFF,0x00},
- {// 圖片數字7
- 0x1F,0xFF,0xFC,0x1F,0xFF,0xFC,0x1F,0xFF,0xF8,0x1F,0x00,0x38,0x1C,0x00,0x70,0x1C,
- 0x00,0xE0,0x38,0x00,0xE0,0x38,0x01,0xC0,0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x03,
- 0x80,0x00,0x07,0x80,0x00,0x07,0x00,0x00,0x0F,0x00,0x00,0x0E,0x00,0x00,0x1E,0x00,
- 0x00,0x1E,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x7C,0x00,0x00,
- 0x78,0x00,0x00,0x78,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0xF8,
- 0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x78,0x00},
- {// 圖片數字8
- 0x00,0xFF,0x00,0x07,0xC3,0xC0,0x0F,0x00,0xE0,0x1E,0x00,0xF0,0x1E,0x00,0x78,0x3C,
- 0x00,0x78,0x3C,0x00,0x78,0x3C,0x00,0x7C,0x3E,0x00,0x78,0x3E,0x00,0x78,0x1F,0x00,
- 0x78,0x1F,0x80,0xF0,0x0F,0xE1,0xE0,0x07,0xFB,0xC0,0x01,0xFF,0x80,0x01,0xFF,0x80,
- 0x07,0xBF,0xC0,0x0F,0x0F,0xE0,0x1E,0x03,0xF0,0x3E,0x01,0xF8,0x3C,0x00,0xF8,0x3C,
- 0x00,0x7C,0x7C,0x00,0x7C,0x78,0x00,0x3C,0x78,0x00,0x3C,0x7C,0x00,0x3C,0x3C,0x00,
- 0x78,0x3C,0x00,0x78,0x1E,0x00,0x70,0x0F,0x00,0xE0,0x07,0xC3,0xC0,0x01,0xFF,0x00},
- {// 圖片數字9
- 0x01,0xFE,0x00,0x07,0xC7,0x80,0x0F,0x01,0xE0,0x1E,0x01,0xE0,0x1E,0x00,0xF0,0x3E,
- 0x00,0xF8,0x3C,0x00,0x78,0x3C,0x00,0x78,0x7C,0x00,0x7C,0x7C,0x00,0x7C,0x7C,0x00,
- 0x7C,0x7C,0x00,0x7C,0x7C,0x00,0x7C,0x3C,0x00,0xFC,0x3E,0x00,0xFC,0x3E,0x01,0xFC,
- 0x1F,0x03,0xFC,0x1F,0x8F,0xFC,0x0F,0xFF,0x7C,0x03,0xFC,0x7C,0x00,0x00,0x7C,0x00,
- 0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0xF0,0x00,0x01,0xF0,0x0F,0x01,
- 0xE0,0x1F,0x01,0xE0,0x1F,0x03,0xC0,0x1F,0x07,0x80,0x0F,0x9F,0x00,0x03,0xFC,0x00}};
- /*========================== 標記及點圖片(寬度x高度=16*16)===========================*/
- uchar code running[7][32]={
- {// 警報標記16*16
- 0x00,0x00,0x00,0x39,0x00,0x7B,0x00,0xFE,0x01,0xDC,0x0F,0x98,0x0F,0x18,0x0C,0x1F,
- 0x0C,0x1F,0x0F,0x18,0x0F,0x98,0x01,0xDC,0x00,0xFE,0x00,0x7B,0x00,0x39,0x00,0x00,},
- {// 鬧鈴開啟標記16*16
- 0x00,0x00,0x00,0x40,0x00,0xE0,0x01,0xB0,0x01,0xB0,0x03,0x18,0x03,0x18,0x06,0x0C,
- 0x0C,0x06,0x0C,0xE6,0x1B,0x1B,0x0C,0x06,0x06,0x0C,0x03,0xF8,0x00,0xE0,0x00,0x00},
- {// 鍵盤鎖標記16*16
- 0x00,0x00,0x01,0xF8,0x03,0xFC,0x03,0x0C,0x03,0x0C,0x03,0x0C,0x03,0xFC,0x06,0x96,
- 0x0E,0xA7,0x0E,0xC7,0x0E,0xA7,0x0E,0x97,0x07,0xFE,0x03,0xFC,0x01,0xF8,0x00,0x00,},
- {// 溫度計標記16*16
- 0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
- 0x01,0x90,0x01,0x98,0x01,0x9C,0x01,0x9E,0x01,0x9C,0x00,0x18,0x00,0x10,0x00,0x00},
- {// 模式3點16*16
- 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
- 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
- {// 模式2點16*16
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
- 0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
- {// 籃球器運行標記16*16
- 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x01,0x80,0x01,0x80,0x01,0x90,
- 0x01,0x98,0x01,0x9C,0x01,0x9E,0x01,0x9C,0x01,0x98,0x01,0x90,0x00,0x00,0x00,0x00}};
- /*========================== 菜單按鈕圖片(寬度x高度=16*8)============================*/
- uchar code menu_key[]=
- {//菜單按鈕
- 0x7F,0xFE,0x81,0x81,0x83,0xC1,0x87,0xE1,0x8F,0xF1,0x9F,0xF9,0x80,0x01,0x7F,0xFE
- };
- /*=====================================================================================
- 函數名稱:定時器中斷處理與初始化,延時
- 功能描述:時鐘更新、籃球器計時
- 全局變量:time_tick、time_tick1、resu[2]、resu[3]、resu[4]、temp_delay、temp_min
- 參數說明:無
- 返回說明:t0_isr(中斷標記)、b20time(溫度更新標記)
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*延時(一次10個機器周期不等) 參數格式:延時數*/
- void delay(unsigned int det)
- {
- while(det--);
- }
- /*1s延時*/
- void delay_pw()
- {
- delay(60000);
- delay(60000);
- }
- /*6個周期 6us */
- void delay_b20(uchar n)
- {
- while(n--);
- }
- /*主時鐘中斷處理*/
- void time0_isr(void) interrupt 1 using 1
- {
- TR0=0;
- TL0=(time_count&0x00FF);
- TH0=(time_count>>8);
- TR0=1;
- if(--time_tick) return;
- time_tick=20;
- t0_isr=1;
- if(nba_tim&!oth_run) // 當在籃球器界面時 nba_tim==1、oth_run==0
- {
- if(resu[3]==0)
- {
- resu[3]=59;
- if(resu[2]>0) resu[2]--;
- }
- else resu[3]--;
- if(resu[2]==0&resu[3]==0) // 比賽時間到后停止
- {
- TR0=0;TR1=0;EA=0;
- }
- return;
- }
- if((++temp_min)==60) // 實現溫度的更新
- {
- temp_min=0;
- temp_delay--;
- if(temp_delay==0)
- {
- b20time=1;temp_delay=5;
- }
- }
- }
- /*24時鐘中斷處理*/
- void time1_isr(void) interrupt 3 using 2
- {
- TR1=0;
- TL1=(time_count&0x00FF);
- TH1=(time_count>>8);
- TR1=1;
- if(--time_tick1) return;
- time_tick1=20;
- if(resu[4]>0)resu[4]--; // 籃球器24秒中斷
- t0_isr=1;
- if(resu[4]==0)
- { TR0=0;TR1=0;EA=0;}
- }
- /*定時器初始化*/
- void time_init()
- {
- EA=0;
- TR0=0;
- TR1=0;
- TMOD=0x11;
- TL0=(time_count&0x00FF);
- TH0=(time_count>>8);
- TL1=(time_count&0x00FF);
- TH1=(time_count>>8);
- IE=0;
- ET0=1;
- ET1=1;
- }
- /*=====================================================================================
- 函數名稱:LCD驅動
- 功能描述:基本驅動(寫1個字節、清屏、初始化)
- 全局變量:無
- 參數說明:dat_comm(0:命令 1:數據),content(數值)
- 返回說明:無返回值
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*檢查忙碌位*/
- void chk_busy (void)
- {
- lcd_data = 0xff;
- lcd_rs = 0; // 命令
- lcd_rw = 1; // 讀
- lcd_e = 1;
- while(busy==1);
- lcd_e = 0;
- }
- /*寫LCD 參數格式:0:命令,1:數值 ,數據*/
- void wr_lcd (uchar dat_comm,uchar content)
- {
- chk_busy ();
- lcd_rs=dat_comm;
- lcd_rw = 0; // 寫
- lcd_data=content; // 輸出數據或命令
- lcd_e=1;
- lcd_e=0;
- }
- /*清繪圖*/
- void clrgdram(void)
- {
- uchar i,j;
- for(j=0;j<32;j++)
- {
- wr_lcd(comm,0x34);
- wr_lcd(comm,0x80+j);
- wr_lcd(comm,0x80);
- wr_lcd(comm,0x30);
- for(i=0;i<32;i++)
- wr_lcd(dat,0x00); // 寫入0x00
- }
- wr_lcd(comm,0x36);
- }
- /*清除顯示*/
- void clear_dis(void)
- {
- wr_lcd(comm,0x30);
- wr_lcd(comm,0x01); // 清屏,地址指針指向00H
- clrgdram(); // 請繪圖RAM
- }
- /*開機LCD初始化*/
- void init_lcd (void)
- {
- lcd_rst=1;
- wr_lcd(comm,0x30); // 30---基本指令動作
- wr_lcd(comm,0x06); // 光標的移動方向
- wr_lcd(comm,0x0c); // 開顯示,關游標
- clear_dis();
- }
- /*=====================================================================================
- 函數名稱:DS1302驅動
- 功能描述:基本驅動(讀寫數據、讀寫日期,時間、初始化)
- 全局變量:無
- 參數說明:w_adder(寫地址),r_adder(讀地址),w_data(寫入數據)
- 返回說明:返回讀取的數據
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:上升沿寫入數值,下降沿讀出數值,沒用設立后背電池充電
- ======================================================================================*/
- /*向1302寫數據 參數格式:地址,數據*/
- void w1302(uchar w_adder,uchar w_data)
- {
- uchar d;
- ret_ds1302();
- for(d=0;d<16;d++)
- {
- if(d==8) w_adder=w_data;
- d02_data=(bit)(w_adder&0x01);
- d02_sclk=0; // 上升沿
- w_adder>>=1;
- d02_sclk=1;
- }
- end_ds1302();
- }
- /*接收1302一個字節的數據 參數格式:讀地址*/
- uchar r1302(uchar r_adder)
- {
- uchar d=0;
- ret_ds1302();
- for(d=0;d<8;d++) // 寫地址
- {
- d02_data=(bit)(r_adder&0x01);
- d02_sclk=0;
- r_adder>>=1;
- d02_sclk=1;
- }
- r_adder=0;
- for(d=0;d<8;d++) // 讀數據
- {
- d02_data=1;
- d02_sclk=1; // 下降沿
- r_adder>>=1;
- d02_sclk=0;
- if(d02_data) r_adder|=0x80;
- }
- end_ds1302();
- return(r_adder);
- }
- /*寫入時間與日期*/
- void wds1302_time_date(void)
- {
- w1302(d02_wrc,0x00); // 寫允許
- w1302(0x90,0xa5); // 單二極管2K電阻充電
- w1302(d02_year,today.year); // 年
- w1302(d02_weeks,today.week); // 星期
- w1302(d02_month,today.month); // 月
- w1302(d02_day,today.day); // 日
- w1302(d02_hour,0x7f&now.hour); // 時
- w1302(d02_minute,now.minute); // 分
- w1302(d02_second,0x7f&now.second); // 秒
- w1302(d02_wrc,0x80); // 寫禁止
- }
- /*初始化寫DS1302 RAM*/
- void init_wds1302_ram(void)
- {
- w1302(d02_wrc,0x00);
- w1302(0x90,0xa5); // 單二極管2K電阻充電
- w1302(d02_signs,0x00); // 狀態寄存
- w1302(d02_passw,0x62); // 密碼儲存首位
- w1302(d02_passw+2,0x18); // 初始值為:741456
- w1302(d02_passw+4,0x29); // 密碼最后一位
- w1302(d02_alm,0x12); // 鬧鈴時(12小時)
- w1302(d02_alm+2,0x00); // 鬧鈴分(0分)
- w1302(d02_temp,0xff); // 溫度上限(255為關閉)
- w1302(d02_temp+2,0xff); // 溫度下限(關閉)
- w1302(d02_initsi,0xb4); // 是否要初始化標記(0xb4為已經初始化)
- w1302(d02_wrc,0x80);
- }
- /*寫DS1302一字節的RAM*/
- void wds1302_data(uchar adder,uchar _data)
- {
- w1302(d02_wrc,0x00);
- w1302(adder,_data);
- w1302(d02_wrc,0x80);
- }
- /*讀取日期*/
- void rds1302_date(void)
- {
-
- today.year=r1302(d02_year+1);
- today.week=r1302(d02_weeks+1);
- today.month=r1302(d02_month+1);
- today.day=r1302(d02_day+1);
- }
- /*讀取時間*/
- void rds1302_time(void)
- {
- now.hour=(r1302(d02_hour+1));
- now.minute=r1302(d02_minute+1);
- now.second=r1302(d02_second+1);
- if(now.hour==alarm_time[0]&&now.minute==alarm_time[1]) alm_run=1;
- else // 鬧鈴時間比較
- {
- alm_run=0;buzstop=0;buzzer=close;
- }
- }
- /*開機讀數據*/
- void rds1302_data(void)
- {
- signs=r1302(d02_signs+1);
- alarm_time[0]=r1302(d02_alm+1);
- alarm_time[1]=r1302(d02_alm+3);
- als_temp[0]=r1302(d02_temp+1);
- als_temp[1]=r1302(d02_temp+3);
- }
-
- /*DS1302初始化*/
- void init_ds1302(void)
- {
- wds1302_time_date();
- init_wds1302_ram();
- }
- /*=====================================================================================
- 函數名稱:DS18b20驅動
- 功能描述:基本驅動(讀寫數據、數據轉換、初始化)
- 全局變量:無
- 參數說明:無
- 返回說明:返回讀取的數據
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:調試中。。。
- ======================================================================================*/
- /*18B20初始化*/
- void init_ds18b20()
- {
- b20_io=1;
- delay_b20(8);
- b20_io=0;
- delay_b20(120); // 延時≥480us
- b20_io=1;
- delay_b20(12); // 拉高為高電平后在15—60us出現低電平,并維持60—240us
- ds18b20=~b20_io;
- delay_b20(40);
- }
- /*向18B20發送一個字節*/
- void send18b20_byte(uchar data_send)
- {
- uchar d=0;
- for (d=0;d<8;d++)
- {
- b20_io=0; // 拉低電平后向總線寫入一個位,15us后18B20接收
- b20_io=data_send&0x01;
- delay_b20(10); // 延時60us后完成一次
- b20_io=1;
- data_send>>=1; // 下位開始
- }
- }
- /*從18B20讀出溫度值 12位分辨率*/
- void receive18b20(void)
- {
- uchar n=1,d;
- for (d=0;d<16;d++)
- {
- if(d==8) n=0;
- b20_io=0; // 拉低總線
- temp.t_data[n]>>=1;
- b20_io=1; // 拉高總線
- if(b20_io) // 讀入總線數值
- temp.t_data[n]|=0x80;
- delay_b20(10); // 等待60us
- }
-
- }
- /*數據轉化*/
- void conversion_t(void)
- {
- uchar save=0,save1=0;
- if(temp.temp_data<0) // 判斷數值符號
- {temp_pn=1;temp.temp_data=~temp.temp_data+1;}
- else temp_pn=0;
- if(temp.t_data[1]&0x01==1) save+=6; // 小數點后的值轉變
- if((temp.t_data[1]>>1)&0x01==1) save+=12;
- if((temp.t_data[1]>>2)&0x01==1) save+=25;
- if((temp.t_data[1]>>3)&0x01==1) save+=50;
- temp.temp_data>>=4;
- save1=temp.temp_data&0x00ff; // 整數部分數值
- temp.t_data[0]=save1;
- temp.t_data[1]=save;
- thl_als=1;
- if(save1>=(als_temp[0]&0x7f)) // 溫度比較
- {
- if(!temp_pn||(temp_pn&(als_temp[0]&0x80)!=0)){ als_th=open;als_tl=close;}
- }
- else if(save1<(als_temp[1]&0x7f)&&als_temp[1]!=255)
- {
- if(!temp_pn||(temp_pn&(als_temp[1]&0x80)!=0)) {als_tl=open;als_th=close;}
- }
- else {als_th=als_tl=close;thl_als=0;buzstop=0;buzzer=close;}
- }
- /*18b20功能*/
- void ds18b20_func(void)
- {
- EA=0;
- TR0=0;
- temp.temp_data=0;
- init_ds18b20();
- send18b20_byte(0xcc); // 跳過ROM
- send18b20_byte(0x44); // 溫度轉換
- delay_pw();
- init_ds18b20();
- send18b20_byte(0xcc);
- send18b20_byte(0xbe); // 讀RAM
- receive18b20(); // 讀取溫度值
- conversion_t(); // 數值轉換
- EA=1;
- TR0=1;
- }
- /*=====================================================================================
- 函數名稱:畫面構造
- 功能描述:界面1、2、3,圖片菜單,反白,標頭,16*16(32)圖片
- 全局變量:無
- 參數說明:函數說明
- 返回說明:無
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:X坐標每一格每次16點
- ======================================================================================*/
- /*反白或顯示圖片 參數格式:(H)8bit數據,(L)8bit數據,X0坐標(16bit),Y0坐標(1bit),X坐標(16bit),Y坐標(1bit)*/
- void con_disp (uchar data1,uchar data2,uchar x0,uchar y0,uchar xl,uchar yl)
- {
- uchar i,j;
- for(j=0;j<yl;j++)
- {
- for(i=0;i<xl;i++)
- {
- wr_lcd(comm,0x34); // 擴展功能
- wr_lcd(comm,y0+j); // 寫Y坐標
- wr_lcd(comm,x0+i); // 寫X坐標
- wr_lcd(comm,0x30); // 普通功能
- wr_lcd(dat,data1);
- wr_lcd(dat,data2);
- }
- }
- wr_lcd(comm,0x36); // 開繪圖顯示
- }
- /*顯示字體 參數格式: 顯示位置(0x80-0x9f),顯示個數,顯示內容指針*/
- void display_cnasc(uchar dis_bit,uchar num,uchar *cnasc)
- {
- wr_lcd(comm,0x30); // 普通功能
- wr_lcd(comm,dis_bit); // 寫地址
- while(num>0)
- {
- wr_lcd(dat,*(cnasc++));
- wr_lcd(dat,*(cnasc++));
- num--;
- }
- }
- /*導航標頭顯示*/
- void dis_title(void)
- {
- display_cnasc(0x80,1,"\x15 ");
- display_cnasc(0x90,1,"┏");
- display_cnasc(0x97,1,"┓");
- display_cnasc(0x98,1,"┗");
- display_cnasc(0x9f,1,"┛");
- display_cnasc(0x92,1,"\x1e ");
- display_cnasc(0x9a,1,"\x1f ");
- con_disp(0xff,0xff,0x80,0x80,3,16);
- con_disp(0xef,0xef,0x83,0x80,1,16);
- con_disp(0xde,0xf7,0x84,0x80,1,16);
- con_disp(0x76,0xdb,0x85,0x80,1,16);
- con_disp(0x55,0x55,0x86,0x80,1,16);
- con_disp(0x55,0x55,0x87,0x80,1,16);
- }
- /*圖片顯示標頭*/
- void dis_title_pic(void)
- {
- display_cnasc(0x80,2,"〓〓");
- display_cnasc(0x86,2,"〓〓");
- }
- /*功能實現顯示標頭*/
- void dis_title_e(void)
- {
- display_cnasc(0x80,1," \x15");
- con_disp(0xff,0xff,0x80,0x80,1,16);
- con_disp(0xff,0xc7,0x81,0x80,1,16);
- con_disp(0xff,0xff,0x82,0x80,3,16);
- con_disp(0xe3,0xff,0x85,0x80,1,16);
- con_disp(0xff,0xff,0x86,0x80,2,16);
- }
- /*顯示菜單圖片 格式:圖片反顯(1)或正常顯示(0),顯示圖片的號碼*/
- void anti_nor_pic (uchar cpl_sign,uchar menu_num)
- {
- uchar i,j,x,y;
- x=menu_num*3; // 計算圖片顯示坐標
- if(x>6) x--;
- if(menu_num<3) y=16; // 上下半屏顯示
- else y=8;
- if(cpl_sign==1) display_cnasc(0x82,4,menu_cn[menu_num]);
- for(j=0;j<24;j++)
- {
- for(i=0;i<2;i++)
- {
- wr_lcd(comm,0x34);
- wr_lcd(comm,0x80+y);
- wr_lcd(comm,0x80+x+i); // 分兩次顯示 16bit
- wr_lcd(comm,0x30);
- if(cpl_sign==1) // 圖片反選
- {
- wr_lcd(dat,~menu_pic[menu_num][j*4+i*2]);
- wr_lcd(dat,~menu_pic[menu_num][j*4+i*2+1]);
- }
- else // 正常顯示
- {
- wr_lcd(dat,menu_pic[menu_num][j*4+i*2]);
- wr_lcd(dat,menu_pic[menu_num][j*4+i*2+1]);
- }
- }
- y++;
- if(y==32&&menu_num<3) {x+=8;y=0;} // 上下屏切換
- }
- wr_lcd(comm,0x36);
- }
- /*狀態16*16圖片 格式:反色(1)或正常0,X坐標,Y坐標,狀態編碼(16*16)*/
- void dis_run_state(uchar cpl,uchar x0,uchar y0,uchar state_num)
- {
- uchar j;
- for(j=0;j<16;j++)
- {
- wr_lcd(comm,0x34); // 擴展功能
- wr_lcd(comm,y0++); // 寫Y地址
- wr_lcd(comm,x0); // 寫X地址
- wr_lcd(comm,0x30); // 普通功能
- if(cpl==1) // 寫數據
- {
- wr_lcd(dat,~running[state_num][j*2]);
- wr_lcd(dat,~running[state_num][j*2+1]);
- }
- else
- {
- wr_lcd(dat,running[state_num][j*2]);
- wr_lcd(dat,running[state_num][j*2+1]);
- }
- }
- wr_lcd(comm,0x36);
- }
-
- /*顯示菜單按鈕 參數格式:反色(1)或正常(0)*/
- void dis_menu_key(uchar d)
- {
- if(d==1)
- {
- for(d=0;d<8;d++) // 顯示菜單按鈕
- con_disp(~menu_key[d*2],~menu_key[d*2+1],0x9f,0x97+d,1,1);
- }
- else
- {
- for(d=0;d<8;d++) // 顯示菜單按鈕
- con_disp(menu_key[d*2],menu_key[d*2+1],0x9f,0x97+d,1,1);
- }
- }
- /*顯示模式3的界面*/
- void dis_mode3(void)
- {
- uchar i,j,h,l,x_0=0x80,y_0=0x90;
- h=now.hour>>4; // 分離十位 個位
- l=now.hour&0x0f;
- for(j=0;j<2;j++)
- {
- for(i=0;i<32;i++) // 十位個位一起讀入
- {
- wr_lcd(comm,0x34);
- wr_lcd(comm,y_0++);
- wr_lcd(comm,x_0);
- wr_lcd(comm,0x30);
- wr_lcd(dat,mode_3num[h][i*3]); // 連續寫數據,X坐標自動加1
- wr_lcd(dat,mode_3num[h][i*3+1]);
- wr_lcd(dat,mode_3num[h][i*3+2]);
- wr_lcd(dat,mode_3num[l][i*3]);
- wr_lcd(dat,mode_3num[l][i*3+1]);
- wr_lcd(dat,mode_3num[l][i*3+2]);
- if(y_0==0xa0){x_0=x_0+8;y_0=0x80;}
- }
- x_0=0x84,y_0=0x90;
- h=now.minute>>4; // 分離十位 個位
- l=now.minute&0x0f;
- }
- dis_run_state(0,0x83,0x90,4); // 顯示點
- dis_run_state(0,0x8b,0x80,4);
- y_0=0x80; // 顯示狀態標記
- if(keb) {dis_run_state(0,0x87,y_0,2);y_0+=16;}
- if(alm) {dis_run_state(0,0x87,y_0,1);y_0+=16;}
- if(y_0<0xa0&&!als){dis_run_state(0,0x87,y_0,0);}
- if(y_0==0xa0&&!als){dis_run_state(0,0x8f,0x80,0);}
- dis_menu_key(0);
- }
- /*顯示模式1和2的共用部分*/
- void mode1_2_union(void)
- {
- uchar x=0x9b;
- display_cnasc(0x98,2,"星期");
- if(nba_tim) dis_run_state(0,x,0x90,6);
- if(keb) {dis_run_state(0,x,0x90,2);x++;} // 顯示標記
- if(alm) {dis_run_state(0,x,0x90,1);x++;}
- if(!als){dis_run_state(0,x,0x90,0);}
- dis_menu_key(0); // 顯示菜單按鈕
- }
- /*顯示模式2的日期*/
- void dis_date_mode2(uchar d)
- {
- uchar save[2];
- display_cnasc(d+2,1,"年");
- display_cnasc(d+4,1,"月");
- display_cnasc(d+6,1,"日");
- display_cnasc(0x9a,1,weeks[today.week]); // 顯示星期
- save[0]=char_num[today.year>>4]; // 將顯示的數值存到數組中
- save[1]=char_num[today.year&0x0f];
- display_cnasc(d+1,1,save);
- save[0]=char_num[today.month>>4];
- save[1]=char_num[today.month&0x0f];
- display_cnasc(d+3,1,save);
- save[0]=char_num[today.day>>4];
- save[1]=char_num[today.day&0x0f];
- display_cnasc(d+5,1,save);
- }
- /*顯示模式2的時間數字顯示 16*32*/
- void num2_asc_dis(uchar num,uchar x_0)
- {
- uchar i,y_0=0x90;
- for(i=0;i<32;i++) // 十位個位一起讀入
- {
- wr_lcd(comm,0x36);
- wr_lcd(comm,y_0++);
- wr_lcd(comm,x_0);
- wr_lcd(comm,0x30);
- wr_lcd(dat,mode_2num[num][i*2]);
- wr_lcd(dat,mode_2num[num][i*2+1]);
- if(i==15){x_0+=8;y_0=0x80;}
- }
- wr_lcd(comm,0x36);
- }
- /*顯示模式2的時間*/
- void dis_time_mode2(void)
- {
- uchar h,l;
- if(now.hour!=save_time.hour||init_d2)
- {
- h=now.hour>>4; // 分離十位 個位
- l=now.hour&0x0f;
- num2_asc_dis(h,0x80);
- num2_asc_dis(l,0x80+1);
- }
- if(now.minute!=save_time.minute||init_d2)
- {
- h=now.minute>>4; // 分離十位 個位
- l=now.minute&0x0f;
- num2_asc_dis(h,0x83);
- num2_asc_dis(l,0x83+1);
- }
- if(now.second!=save_time.second||init_d2)
- {
- h=now.second>>4; // 分離十位 個位
- l=now.second&0x0f;
- num2_asc_dis(h,0x86);
- num2_asc_dis(l,0x86+1);
- }
- if(init_d2)
- {
- dis_run_state(0,0x82,0x90,5); // 顯示點
- dis_run_state(0,0x8a,0x80,5);
- dis_run_state(0,0x85,0x90,5); // 顯示點
- dis_run_state(0,0x8d,0x80,5);
- }
- }
- /*顯示模式2的界面*/
- void dis_mode2(void)
- {
- dis_date_mode2(0x81); // 顯示日期
- display_cnasc(0x81,1,"20");
- dis_time_mode2(); // 顯示時間
- mode1_2_union();
- }
- /*顯示模式1的日期*/
- void dis_date_mode1(void)
- {
- uchar save[2];
- display_cnasc(0x80,3,"日期:");
- display_cnasc(0x90,3,"時間:");
- display_cnasc(0x88,3,"溫度:");
- display_cnasc(0x9a,1,weeks[today.week]); // 顯示星期
- display_cnasc(0x83,1,"20");
- save[0]=char_num[today.year>>4];
- save[1]=char_num[today.year&0x0f];
- display_cnasc(0x84,1,save);
- save[0]='/';
- save[1]=char_num[today.month>>4];
- display_cnasc(0x85,1,save);
- save[0]=char_num[today.month&0x0f];
- save[1]='/';
- display_cnasc(0x86,1,save);
- save[0]=char_num[today.day>>4];
- save[1]=char_num[today.day&0x0f];
- display_cnasc(0x87,1,save);
- mode1_2_union();
- }
- /*顯示模式1的時間*/
- void dis_time_mode1(void)
- {
- uchar save[2];
- save[0]=char_num[now.hour>>4];
- save[1]=char_num[now.hour&0x0f];
- display_cnasc(0x93,1,save);
- save[0]=':';
- save[1]=char_num[now.minute>>4];
- display_cnasc(0x94,1,save);
- save[0]=char_num[now.minute&0x0f];
- save[1]=':';
- display_cnasc(0x95,1,save);
- save[0]=char_num[now.second>>4];
- save[1]=char_num[now.second&0x0f];
- display_cnasc(0x96,1,save);
- }
- /*顯示模式1的溫度*/
- void dis_temp_mode1(void)
- {
- uchar save[2];
- if(ds18b20)
- {
- if(temp.t_data[0]>99)
- {
- save[0]=char_num[temp.t_data[0]/100];
- save[1]=char_num[(temp.t_data[0]/10)%10];
- display_cnasc(0x8b,1,save);
- save[0]=char_num[temp.t_data[0]%10];
- save[1]='.';
- display_cnasc(0x8c,1,save);
- save[0]=char_num[temp.t_data[1]/10];
- save[1]=' ';
- display_cnasc(0x8d,1,save);
- display_cnasc(0x8e,1,"℃");
- }
- else
- {
- if(temp_pn) display_cnasc(0x8a,1,":-");
- else display_cnasc(0x8a,1,":");
- save[0]=char_num[temp.t_data[0]/10];
- save[1]=char_num[temp.t_data[0]%10];
- display_cnasc(0x8b,1,save);
- save[0]='.';
- save[1]=char_num[temp.t_data[1]/10];
- display_cnasc(0x8c,1,save);
- display_cnasc(0x8d,1,"℃");
- }
- }
- else display_cnasc(0x8b,3,"FF.F℃");
- }
- /*顯示模式1的界面*/
- void dis_mode1(void)
- {
- dis_date_mode1();
- dis_time_mode1();
- dis_temp_mode1();
- }
- /*籃球器時間顯示*/
- void nba_dis_time(void)
- {
- uchar d,dis[2];
- for(d=2;d<4;d++)
- {
- dis[0]=char_num[resu[d]/10];
- dis[1]=char_num[resu[d]%10];
- display_cnasc(0x81+d*2,1,dis);
- }
- display_cnasc(0x86,1,": ");
- if(resu[0]==1)
- {
- dis[0]='\x07';
- dis[1]=char_num[resu[4]/10];
- display_cnasc(0x93,1,dis);
- dis[1]='\x07';
- dis[0]=char_num[resu[4]%10];
- display_cnasc(0x94,1,dis);
- }
- }
- /*=====================================================================================
- 函數名稱:鍵盤掃描
- 功能描述:讀取鍵盤操作數據及部分狀態的實現
- 全局變量:dis_sig t0_isr temprun b20time alm_run als_temp buzstop als
- lock_op nba_tim
- 參數說明:無
- 返回說明:鍵盤鎖與密碼鎖時間到達后返回 255
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*掃描鍵盤*/
- uchar keypad_scan()
- {
- uchar key,dis[2];
- keyboard=0xf0;
- while (keyboard==0xf0) // 等待按鍵按下
- {
-
- /*--------------------- 背光燈關閉延時 -----------------------*/
-
- delay(1000);
- if((++dis[0])==0&&bl_delay!=0) bl_delay--; // 當有按鍵按下bl_delay重新賦值
- if(bl_delay==0&&!bl0) lcd_bl=close; // 背光時間到且不是常開模式時關閉背光
-
- /*----------------------- 鍵盤鎖延時 -------------------------*/
- if(keb&&dis_sig&&bl_delay==0&&resu[11]<2) resu[11]++; // 當有按鍵按下j清零
- if(bl_delay==0) bl_delay=15;
- /*--------------------- 密碼鎖30秒鎖延時 ---------------------*/
- if(lock_op)
- {
- if((++i)==0) save1++;
- if(save1==15) return(255);
- }
-
- /*---------------------- 時鐘界面時間顯示 ---------------------*/
-
- if(dis_sig&&t0_isr||nba_tim&&oth_run) // 正常時鐘界面與籃球器返回時鐘界面顯示
- {
- rds1302_date(); // 讀出日期
- rds1302_time(); // 讀出時間
- if(di0) // 模式2
- {
- dis_time_mode2();
- if(now.hour==0&&now.minute==0&&now.second==0) dis_date_mode2(0x81);
- }
- else if(di1) // 模式3
- {
- if(now.hour!=save_time.hour||now.minute!=save_time.minute) // 時,分變化后顯示
- dis_mode3();
- }
- else
- {
- dis_time_mode1(); // 模式1
- if(now.hour==0&&now.minute==0&&now.second==0) dis_date_mode1();
- }
- save_time=now; // 重新記錄作下次比較
- t0_isr=0;
- }
-
-
- /*-------------------- 溫度計提示按鍵操作 ----------------------*/
-
- if(temprun)
- {
- if(!oth_run)
- {
- display_cnasc(0x96,2," key"); // 溫度計時提示按鍵操作
- for(dis[1]=0;dis[1]<250;dis[1]++)
- {
- delay(1000);
- if(keyboard!=0xf0)
- {
- keyboard=0x7f;
- if(keyboard==0x7d) return 0x7d;
- else keyboard=0xf0;
- }
- }
- oth_run=1;
- display_cnasc(0x96,2," ");
- }
- }
-
-
- /*------------------------ 蜂鳴器警報 --------------------------*/
-
- if(((alm_run&&alm)||thl_als)&&!buzstop) // 溫度,鬧鈴蜂鳴器警報
- { // 有按鍵按下時停止
- if(now.second==0) lcd_bl=close;
- delay(15000); // 讀出溫度時間比較
- if(keyboard!=0xf0) break;
- delay(15000);
- if(keyboard!=0xf0) break;
- delay(15000);
- if(keyboard!=0xf0) break;
- delay(15000);
- if(alm_run) lcd_bl=!lcd_bl; // 只在鬧鈴功能閃
- if(!als)buzzer=!buzzer; // 警報開啟后蜂鳴器開啟
- }
- /*----------------------- 溫度刷新顯示 -------------------------*/
-
- if((temprun&&oth_run)||(b20time&&!di0&&!di1&&dis_sig)) // 溫度計功能于模式1界面
- {
-
- ds18b20_func(); // 溫度檢測功能
- oth_run=0; // 作交替標記用
- if(temprun) return 20; // 溫度計開啟后返回
- if(b20time){ dis_temp_mode1();b20time=0;} // 時鐘界面5分鐘更新一次,T0計時
- }
-
-
- /*------------------------ 籃球器顯示時間 ------------------------*/
-
- if(nba_tim&!oth_run) // 當籃球器模式下 oth_run==0為籃球器計時狀態
- {
- if(EA) display_cnasc(0x8b,2," R\x10 "); // 顯示運行狀態
- else display_cnasc(0x8b,2," S! ");
- if(t0_isr)
- { // 更新時間
- nba_dis_time();
- if(resu[2]==0&&resu[3]==0) // 判斷比賽情況
- {
- resu[6]++;
- if(resu[6]<resu[1]) display_cnasc(0x85,3,"休息 ");
- else display_cnasc(0x85,3,"完結 ");
- }
- if(resu[4]==0||(resu[2]==0&&resu[3]==0)) // 時間到達警報
- {
- buzzer=open;
- delay_pw();
- if(resu[2]==0&&resu[3]==0) // 24秒 總時間警報
- {
- delay_pw();
- }
- buzzer=close;
- if(resu[4]==0) resu[4]=24; // 重新賦值
- }
- t0_isr=0; // 清零等下次中斷產生
- }
- }
- }
-
- /*===== 以上等待按鍵 =====*/
- /*------------------------- 按鍵按下后 --------------------------*/
-
- delay(8000); // 消抖振
- if(!lock_op)bl_delay=15; // 背光時間賦值
- if(bl1) lcd_bl=close; // 不在背光燈關閉時亮起
- else lcd_bl=open;
- if(alm_run|thl_als) {buzstop=1;buzzer=close;}
- if(keb&&dis_sig)
- {
- if(resu[11]==2) return 255; // 要求輸入密碼
- else resu[11]=0; // 時間不到時重新計時
- }
- do
- {
- for(dis[0]=0;dis[0]<=3;dis[0]++)
- {
- keyboard=ksp[dis[0]];
- if(keyboard!=ksp[dis[0]])
- {
- key=keyboard;
- if(key!=ksp[dis[0]]) return(key);
- }
- }
- }while(1);
- }
-
- /*讀鍵盤數據*/
- uchar gotkey()
- {
- uchar save,n;
- keyboard=0xf0;
- while(keyboard!=0xf0); // 等待鍵盤松開
- delay(5000); // 消抖陣
- if(adju_si) // 連寫輸入
- {
- adju_si=0;
- for(n=0;n<60;n++)
- {
- delay(2000);
- if(keyboard!=0xf0)
- {
- adju_si=1; // 在更改時,在此時間內可連成多位數
- break;
- }
- }
- }
- save=keypad_scan(); // 掃描鍵盤
- if(save==255) return 255; // 要求輸入鍵盤鎖密碼或延時時間到達
- for (n=0;n<16;n++)
- {
- if(save==key_code[n])
- return(n);
- }
- return(20);
- }
- /*=====================================================================================
- 函數名稱:導航
- 功能描述:主菜單 工具導航 保存提示
- 全局變量:無
- 參數說明:
- 返回說明:無
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*按鍵按下顯示 參數格式:k 按鈕的顯示地址*/
- void key_dis(uchar k)
- {
- display_cnasc(k,1,"\x04 ");
- delay(10000);
- if(k==0x92||k==0x96) display_cnasc(k,1,"\x1e ");
- else display_cnasc(k,1,"\x1f ");
- }
- /*確定按鍵按下顯示*/
- void enter_dis(void)
- {
- display_cnasc(0x8f,1," \x09");
- delay(15000);
- }
- /*主菜單導航*/
- uchar dis_menu(void)
- {
- uchar d,save,key;
- if(meu)
- {
- display_cnasc(0x81,2,"菜單");
- dis_title();
- display_cnasc(0x88,8,selected[0]);
- con_disp(0xff,0xff,0x8a,0x80,5,16);
- }
- else // 顯示圖片菜單
- {
- dis_title_pic();
- for(d=0;d<6;d++)
- anti_nor_pic(0,d);
- anti_nor_pic(1,0);
- }
- save=d=0;
- do
- {
- if(meu) // 操作指示更新
- {
- display_cnasc(0x93,3,menu_cn_2[index_m[save].right_num]);
- display_cnasc(0x8b,3,menu_cn_2[save]);
- display_cnasc(0x9b,3,menu_cn_2[index_m[save].left_num]);
- }
- else
- {
- anti_nor_pic(0,d);
- anti_nor_pic(1,save);
- }
- d=save; // 保存上一索引
- while(1)
- {
- key=gotkey();
- if(key==11||(key==3&&meu))
- {
- if(meu) enter_dis();
- break;
- }
- else if(meu)
- {
- if(key==2)
- {
- save=index_m[d].left_num;
- key_dis(0x9a);
- break;
- }
- if(key==5)
- {
- save=index_m[d].right_num;
- key_dis(0x92);
- break;
- }
- if((key==1&&meu))
- {
- d=5;
- break;
- }
- }
- else
- {
- if(key==3){save=index_m[d].left_num; break;} // 根據導航鍵尋找索引
- if(key==1){save=index_m[d].right_num; break;}
- if(key==2||key==5){save=index_m[d].shaft_num; break;}
- }
- }
- if(key==11||((key==1|key==3)&&meu)) break;
- }while(1);
- return d;
- }
- /*工具導航*/
- uchar tool_func(void)
- {
- uchar save,d,key;
- display_cnasc(0x81,2,"工具");
- dis_title();
- display_cnasc(0x88,8,selected[0]);
- con_disp(0xff,0xff,0x8a,0x80,5,16);
- d=0;
- save=0;
- do
- {
- display_cnasc(0x93,3,tool_menu[index_t[save].lnum]);
- display_cnasc(0x8b,3,tool_menu[save]);
- display_cnasc(0x9b,3,tool_menu[index_t[save].rnum]);
- d=save;
- while(1)
- {
- key=gotkey();
- if(key==1){ d=4;break;} // 根據按鍵尋找索引
- if(key==11||key==3){enter_dis();break;}
- if(key==2){save=index_t[d].rnum; key_dis(0x9a);break;}
- if(key==5){save=index_t[d].lnum; key_dis(0x92);break;}
- }
- if(key==11||key==3||key==1) break;
- }while(1);
- return d;
- }
- /*更改后提示保存*/
- void save_y_or_n(void)
- {
- uchar key;
- clear_dis();
- oth_run=0;
- display_cnasc(0x92,5,"是否保存? ");
- display_cnasc(0x89,6,"Y(OK)\\N(./S)");
- while(1)
- {
- key=gotkey();
- if(key==11)
- {
- display_cnasc(0x9a,5,"保存成功! ");
- delay(50000);
- oth_run=1; // 要求保存時oth_run標記為1
- return;
- }
- if(key==10) return;
- }
- }
- /*=====================================================================================
- 函數名稱:調整功能
- 功能描述:時間日期調整
- 全局變量:today now
- 參數說明:見函數
- 返回說明:無
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*調整功能顯示時間*/
- void asjust_time()
- {
- uchar save[2];
- display_cnasc(0x8a,1,"時");
- display_cnasc(0x8c,1,"分");
- display_cnasc(0x8e,1,"秒");
- save[0]=char_num[now.hour>>4];
- save[1]=char_num[now.hour&0x0f];
- display_cnasc(0x89,1,save);
- save[0]=char_num[now.minute>>4];
- save[1]=char_num[now.minute&0x0f];
- display_cnasc(0x8b,1,save);
- save[0]=char_num[now.second>>4];
- save[1]=char_num[now.second&0x0f];
- display_cnasc(0x8d,1,save);
- }
- /*調整功能月天數比較*/
- uchar monthday(uchar year,uchar month)
- {
- if(month==2&&year%4==0)
- return(29);
- else
- { year=month&0x0f;
- month>>=4;
- month=month*10+year;
- return(dayofmonth[month-1]);}
- }
- /*星期推算*/
- void weeks_day()
- {
- uchar d,buffer,day=4;
- if(today.month>1)
- {
- buffer=(today.month>>4); // 將BCD碼轉為十進制
- buffer=buffer*10;
- buffer+=(today.month&0x0f);
- for(d=0;d<buffer-1;d++)
- {
- today.week=(dayofmonth[d]>>4);
- today.week=today.week*10;
- today.week+=(dayofmonth[d]&0x0f);
- day+=(today.week%7);
- }
- }
- buffer=(today.year>>4);
- buffer*=10;
- buffer+=(today.year&0x0f);
- if(today.year!=0)
- {
- day+=((buffer-1)/4)+buffer+1;
- }
- if(buffer%4==0&&today.month>2) day++;
- buffer=today.day>>4;
- buffer*=10;
- buffer+=(today.day&0x0f);
- today.week=(day+buffer)%7;
- }
- /*調整功能*/
- void adjust_func(void)
- {
- uchar d,save,b=0;
- dis_title_e();
- display_cnasc(0x82,3,menu_cn_2[0]);
- rds1302_date();
- rds1302_time();
- dis_date_mode2(0x90);
- display_cnasc(0x9a,1," ");
- asjust_time();
- display_cnasc(0x9f,1,"→");
- display_cnasc(0x90,1,"『");
- display_cnasc(0x8f,1,"』");
- d=0;save=0;
- adju_si=0;
- do
- {
- con_disp(0x00,0x00,index_a[d].lnum,index_a[d].rnum,1,13);
- con_disp(0xff,0xff,index_a[save].lnum,index_a[save].rnum,1,13);
- d=save;
- while(1)
- {
- save=gotkey();
- if(save>=0&&save<10)
- {
- switch(d)
- {
- case 0: if(adju_si) // adju_si==1時兩次輸入連成一個數
- {
- today.year<<=4;
- today.year+=save;adju_si=0;
- }
- else
- {
- today.year=save;adju_si=1;
- }
- break;
- case 1: if(adju_si)
- {
- today.month<<=4;today.month+=save;
- if(today.month>0x12) today.month=save;
- else adju_si=0;
- }
- else
- {
- today.month=save;adju_si=1;
- }
- break;
- case 2: if(adju_si)
- {
- today.day<<=4;today.day+=save; // 月天數比較
- if(today.year%4==0&&today.month==2&&today.day==29) ;
- else if(today.day>monthday(today.year,today.month))
- today.day=save;
- else adju_si=0;
- }
- else {today.day=save;adju_si=1;}
- break;
- case 3: if(adju_si)
- {
- now.hour<<=4;now.hour+=save;
- if(now.hour>0x23) now.hour=save;
- else adju_si=0;
- }
- else {now.hour=save;adju_si=1;}
- break;
- case 4: if(adju_si)
- {
- now.minute<<=4;now.minute+=save;
- if(now.minute>0x59) now.minute=save;
- else adju_si=0;
- }
- else {now.minute=save;adju_si=1;}
- break;
- case 5: if(adju_si)
- {
- now.second<<=4;now.second+=save;
- if(now.second>0x59) now.second=save;
- else adju_si=0;
- }
- else {now.second=save;adju_si=1;}
- break;
- }
- if(today.day>monthday(today.year,today.month)) today.day=1; // 更改月份時判斷天數
- if(today.month==0) today.month=1;
- if(today.day==0) today.day=1;
- if(d<3) dis_date_mode2(0x90); // 更新顯示
- else asjust_time();
- display_cnasc(0x9a,1," "); // 消去星期顯示
- }
- if(save==11){save=d+1;adju_si=0;break;}
- if(save==10&&d!=0){save=d-1;adju_si=0;break;}
- }
- if(save==7&d==6) break;
- }while(1);
- weeks_day(); // 計算星期
- save_y_or_n(); // 需要保存時oth_run設為1
- if(oth_run) wds1302_time_date();
- }
- /*=====================================================================================
- 函數名稱:計算器功能
- 功能描述:10位帶符號數的加減乘除運算
- 全局變量:opera resu i j
- 參數說明:見函數
- 返回說明:無
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*清寄存器 參數格式:m=2時結果寄存器,當m=1時操作數1,當m=0時操作數0(1),
- n=1時,只清寄存器不清顯示, 0兩清*/
- void removal_data(uchar m,uchar n)
- {
- uchar l; // 當n=1時,只清寄存器不清顯示, 0兩清
- if(m==2) // 當m=2時結果寄存器
- { // 當m=1時操作數1
- if(n==0) // 當m=0時操作數0 ,1
- for(l=0;l<6;l++)
- display_cnasc(0x98+l,1," ");
- for(l=0;l<12;l++)
- resu[l]=0;
- }
- while(m<2)
- {
- if(n==0)
- {
- if(m==0)
- {
- for(l=0;l<6;l++)
- display_cnasc(0x90+l,1," ");
- display_cnasc(0x95,1," 0");
- }
- else
- for(l=0;l<6;l++)
- display_cnasc(0x88+l,1," ");
- }
- for(l=0;l<12;l++)
- opera[m][l]=0;
- m++;
- }
- }
- /*顯示數值 參數格式:顯示首地址*/
- void dis_cdata(uchar ass)
- {
- uchar p,d,save[2];
- if(i==0&&opera[0][0]==1) // 顯示符號
- {
- if(cal_run) display_cnasc(0x98,1,"=-");
- else display_cnasc(0x90,1," -");
- }
- d=opera[i][11]; // 計算位數
- if(opera[i][10]!=0&&opera[i][10]!=opera[i][11]+1) d++;
- save[0]=d/2;ass=ass-save[0]+5; // 計算顯示的開始位置
- p=1;
- cal_del=0; // 顯示點標記 (0為沒有顯示)
- if(d%2==1) // 對位數位奇數先處理首位
- {
- save[0]=' ';
- save[1]=char_num[opera[i][1]];
- display_cnasc(ass,1,save);
- p++;
- }
- ass++; // 顯示地址加一
- while(p<=opera[i][11])
- {
- if(opera[i][10]==p&&(!cal_del)) { // 顯示點且作標記
- save[0]='.';cal_del=1;}
- else {
- save[0]=char_num[opera[i][p]]; p++;}
- if(opera[i][10]==p&&(!cal_del)) {
- save[1]='.';cal_del=1;}
- else{
- save[1]=char_num[opera[i][p]];p++;}
- display_cnasc(ass,1,save);
- ass++;
- }
- }
- /*從鍵盤中寫入數據*/
- char input_data()
- {
- uchar save=20,c;
- for(;i<2;i++)
- {
- while(1)
- {
- pp: save=gotkey(); // 讀鍵盤
- if(save==20) continue;
- if(save==11) // 按鍵為確定時,選擇計算或刪除
- {
- c=save=0;
- while(1) // 反色選擇
- {
- con_disp (0x00,0x00,index_cal[save].lnum,index_cal[save].rnum,2,16);
- con_disp (0xff,0xff,index_cal[c].lnum,index_cal[c].rnum,2,16);
- save=gotkey();
- if(save==10)
- {
- save=c;
- if(++c==3) c=0;
- }
- else if(save==11)
- {
- if(c==0) save=11;
- else if(c==1) save=16;
- else return 0;
- break;
- }
- else break;
- }
- con_disp (0x00,0x00,index_cal[c].lnum,index_cal[c].rnum,2,16);
- }
- if(save>=0&&save<=9&&j<10)
- {
- if(i==1&&opera[1][0]==15&&j>8) goto pp;
- if(j==2&&opera[i][1]==0&&opera[i][10]==0)
- opera[i][1]=save; // 防止小數位不在時首位為零
- else{
- opera[i][j]=save;opera[i][11]=j;j++;}
- if(i==0) // 顯示
- dis_cdata(0x90);
- else
- dis_cdata(0x88);
- }
- else if(save==10&&j<10)
- {
- if(opera[i][10]==0) // 小數點空時保存
- {
- if(opera[i][11]==0) {opera[i][10]=2;j++;}
- else opera[i][10]=j;
- }
- }
- else if(save==16)
- { // 刪除數據
- removal_data(i,0);j=1;
- if(i!=0){i--;j=10;}
- }
- else if(i==1&&opera[1][11]!=0&&save>11&&save<16)
- { save1=save;break; } // 連續計算時保存運算符
- else if(save==11&&opera[1][11]==0) continue;// 操作數1為0時不理會
- else if(save==11&&opera[1][11]!=0) break;
- else if((i==0||i==1&&j==1)&&save>11&&save<16){i=0; break;}
- // 當操作數0由運算符結束輸入,再按符號鍵更改
- else continue;
- }
- if(opera[i][10]>opera[i][11]||opera[i][10]==0)
- opera[i][10]=opera[i][11]+1; // 整數時小數位保存到最后
- while(opera[i][11]>=opera[i][10]&&opera[i][opera[i][11]]==0)
- opera[i][11]--; // 去除小數點后多余的0
- if(i==0)
- {
- opera[1][0]=save; // 保存運算符并顯示
- display_cnasc(0x88,1,tool_cal[save-12]);
- }
- if(opera[0][11]==0) display_cnasc(0x95,1," 0");
- j=1;
- while(j<=opera[i][11]&&opera[i][j]==0) j++;//判斷是否操作數是否全為0
- j--;
- if(j==opera[i][11]) opera[i][11]=0;
- j=1;
- }
- return 1;
- }
- /****************************************************************************************
- 功能: 乘法運算
- 描述: 結果由右到左保存
- 參數: i , j , opera[i][j],p,q,r,k,save1
- 返回值:1(成功),0(結果位0),-1(溢出)
- /****************************************************************************************/
- char multiplication()
- {
- uchar p,q,r,k,save1=0; // p指向操作數0 ,q指向操作數1,r指向結果
- if(opera[0][11]==0||opera[1][11]==0) return 0;
- resu[10]=opera[0][11]+opera[1][11]-opera[0][10]-opera[1][10]+2; // RESU記錄小數點后的位數
- q=opera[1][11]; // 記錄操1的位數
- r=9;
- opera[1][11]=1;
- k=1;
- while(opera[1][k]==0) {opera[1][11]=opera[1][11]+1;k++;} // 去除前端的0
- k=1;
- while(opera[0][k]==0) k++; // 去除前端的0
- resu[11]=9;
- for(resu[0]=9;q>=opera[1][11];q--,resu[0]--)
- {
- if(opera[1][q]==0) continue; // 操1此位數為0時直接比較
- for(p=opera[0][11],r=resu[0];p>=k;p--)
- {
- save1=opera[0][p]*opera[1][q]; // 將相乘后的數保存
- resu[r]+=(save1%10);//將緩存中的數取余后加到結果中R指向的位
- save1/=10;
- save1=save1+(resu[r]/10); // 保存進位的數
- resu[r]%=10; // 重新寫入
- if(r==1) //結果有溢出時移位
- {
- if(save1==0&&p==k) break; // 計算到最后位且沒進位跳出
- else if(resu[10]>0) // 要求有小數存在
- {
- for(r=9;r>1;r--) resu[r]=resu[r-1];
- r=1;
- resu[r]=save1;
- resu[11]=1;
- resu[10]--;
- resu[0]++;
- }
- else return -1; // 否則溢出
- }
- if(r>1&&(r-1)<resu[11]) // 保存結果位的最高位
- {
- if(save1!=0) resu[11]=r-1;
- else resu[11]=r;
- }
- if(r>1){ r--;resu[r]+=save1;}// 當R為1時只需要移位記錄結果
- }
- }
- while(resu[resu[11]]==0) resu[11]++; // 去除前端的0
- resu[0]=opera[0][0]; // 保存符號位
- removal_data(0,1); // 清數據不清顯示
- if(resu[10]>8) //如果小數點后的數有9 位或以上時,需后移到使小數點放到2的位置
- {
- save1=resu[10]-10+resu[11]; // 記錄后移位數
- if(save1>7) return 0; //當后移的數大于有效數字的位數時結果為0
- else // 否則按需移位
- {
- for(p=save1+2,r=resu[11];p<10;p++,r++) opera[0][p]=resu[r];
- opera[0][10]=2;opera[0][11]=9;opera[0][0]=resu[0];
- } // 因有效數小于小數點后的數,所以首位為0
- }
- else //如果小數點后的數在8位以內時分兩種情況
- {
- opera[0][0]=resu[0];
- save1=10-resu[11]; // 記錄有效位數
- if(resu[10]>=save1) // 小數的在有效數字的左邊
- {
- for(p=resu[10]+1,r=9;r>=resu[11];p--,r--)
- opera[0][p]=resu[r]; // 從小數點的最后一位開始
- opera[0][10]=2;opera[0][11]=resu[10]+1;
- }
- else // 小數點在有效數字內
- {
- for(p=1,r=resu[11];r<10;p++,r++) opera[0][p]=resu[r];
- opera[0][11]=10-resu[11];
- if(resu[10]==0) opera[0][10]=opera[0][11]+1;
- else opera[0][10]=opera[0][11]-resu[10]+1;
- }
- }
- while(opera[0][11]>=opera[0][10]&&opera[0][opera[0][11]]==0)
- opera[0][11]--; // 去除小數點后多余的0
- return 1;
- }
- /****************************************************************************************
- 功能: 除法運算
- 描述: 結果由左到右保存
- 參數: i , j , opera[i][j]
- p,q,r, remainde, divisor, decimal
- 返回值:1(成功),0(結果位0),-1(溢出)
- *****************************************************************************************/
- char divider()
- {
- unsigned long int divisor=0,remainder=0;
- uchar p,q,r;
- char decimal=0;
- if(opera[1][11]==0) return -1;
- if(opera[0][11]==0) return 0;
- for(r=1;r<12;r++) // 判斷兩數是否相等
- {
- if(opera[0][r]!=opera[1][r]) break;
- }
- if(r==12)
- {
- p=opera[0][0];
- removal_data(0,1);
- opera[0][0]=r;
- opera[0][1]=1;
- opera[0][10]=2;
- opera[0][11]=1;
- return 1;
- }
- decimal=(opera[0][11]-opera[0][10])-(opera[1][11]-opera[1][10]);
- // 記錄兩操作數小數點后位數的差
- if(decimal>0) // 若操0大于操1時重新記錄小數點的位置
- {
- opera[0][10]=opera[0][11]-decimal+1;
- resu[10]=opera[0][10];
- }
- else // 否則小數點后沒有數,記錄有效數的位數
- {
- opera[0][11]-=decimal;
- opera[0][10]=opera[0][11]+1;
- resu[10]=opera[0][10];
- }
- q=1;
- divisor=0;
- while(q<=opera[1][11]) // 將操1的數整形化
- {
- divisor=divisor*10+opera[1][q];q++;
- }
- if(divisor==1)
- {
- if(resu[10]>10) return -1;
- else return 1;
- }
- r=1;p=1;
- remainder=(unsigned long int)opera[0][1]; // 先對余數寄存器附初值
- do
- {
- if(r>9) // 結果位已經到達最后1位
- {
- if(resu[1]==0&&resu[10]!=2) // 判斷是否有得移位
- {
- for(r=1;r<9;r++) resu[r]=resu[r+1];
- resu[9]=0;
- if(resu[10]!=0) resu[10]--;
- r=9;
- }
- else if(p>=opera[0][11]||p>=opera[0][10]) break; // 如果計算到最后一位,或者有小數點存在時結束
- else return -1; // 否則錯誤
- }
- resu[r]=(uchar)(remainder/divisor); // 保存結果
- remainder=(remainder%divisor); // 重新寫入余數
- p++;r++;
- if(p>opera[0][11]&&remainder==0) break; // 除盡后跳出
- else if(p<=opera[0][11]&&p<10) // 余數*10后加后一位
- {remainder=remainder*10+opera[0][p];}
- else remainder=remainder*10; //超出后余數*10
- }while(1);
- resu[11]=r-1;
- resu[0]=opera[0][0];
- removal_data(0,1);
- r=1;
- while(resu[r]==0&&resu[10]!=(r+1)&&r<resu[11]) r++;
- //去除結果前端的0
- if(r==resu[11]) return 0;
- resu[10]=resu[10]-r+1;
- p=1;
- while(r<=resu[11]){opera[0][p]=resu[r];r++;p++;}
- opera[0][0]=resu[0];opera[0][10]=resu[10];opera[0][11]=p-1;
- while(opera[0][11]>=opera[0][10]&&opera[0][opera[0][11]]==0)
- opera[0][11]--;
- return 1;
- }
- /****************************************************************************************
- 功能: 加法運算
- 描述: 以小數點位中心兩邊相加
- 參數: i , j , opera[i][j],p,q,r
- 返回值:1(成功),0(結果位0),-1(溢出)
- /****************************************************************************************/
- char adder()
- {
- uchar p,q,r;
- if(opera[0][11]==0&&opera[1][11]==0) return 0;
- else if(opera[0][11]==0)
- {for(q=0;q<12;q++) opera[0][q]=opera[1][q];return 1;}
- else if(opera[1][11]==0) return 1;
- else
- {
- p=opera[0][10]-1;
- q=opera[1][10]-1;
- p>q?(r=p):(r=q);
- resu[10]=r+1; // 小數點位保存
- resu[0]=opera[0][0]; // 保存符號位
- while(r>0) // 將小數點前的數相應相加后放到結果中
- {
- if(p>0&&q>0){resu[r]=opera[0][p]+opera[1][q];p--;q--;}
- else if(p>0&&q==0){resu[r]=opera[0][p];p--;}
- else {resu[r]=opera[1][q];q--;}
- r--;
- }
- r=resu[10];
- p=opera[0][10];
- q=opera[1][10];
- while(r<10) // 將小數點后的數放到結果中
- {
- if(p>opera[0][11]&&q>opera[1][11]) break;
- else if(p<=opera[0][11]&&q<=opera[1][11])
- {resu[r]=opera[0][p]+opera[1][q];p++;q++;}
- else if(p<=opera[0][11]&&q>opera[1][11])
- {resu[r]=opera[0][p];p++;}
- else {resu[r]=opera[1][q];q++;}
- r++;
- }
- r--;
- resu[11]=r;
- p=0;
- while(r>0) // 由右到左將大于9的數進位
- {
- resu[r]+=p; // p為進位標記
- p=0;
- if(resu[r]>9) {resu[r]-=10;p=1;}
- r--;
- }
- if(p==1) // 溢出移位
- {
- if(resu[10]==10) return -1;
- else {
- for(r=9;r>1;r--) resu[r]=resu[r-1];
- resu[1]=1;resu[10]++;}
- }
- removal_data(0,1);
- r=0;
- while(r<12){opera[0][r]=resu[r];r++;}
- while(opera[0][11]>=opera[0][10]&&opera[0][opera[0][11]]==0)
- opera[0][11]--;
- return 1;
- }
- }
- /****************************************************************************************
- 功能: 減法運算
- 描述: 先比較兩操作數的大小用one ,two互換
- 參數: i , j , opera[i][j],p,q,r,one,two
- 返回值:1(成功),0(結果位0),-1(溢出)
- /****************************************************************************************/
- char subtraction()
- {
- uchar p,q,r,one,two;
- if(opera[0][11]==0&&opera[1][11]==0) return 0;
- else if(opera[0][11]==0)
- {
- for(q=1;q<12;q++)
- opera[0][q]=opera[1][q];
- opera[0][0]=!opera[0][0];return 1;
- }
- else if(opera[1][11]==0) return 1;
- else
- { // 比較大小(大放到one)
- if(opera[0][10]>opera[1][10]){one=0;two=1;}
- else if(opera[1][10]>opera[0][10]) {one=1;two=0;}
- else
- {
- r=1;
- while(r<10&&opera[0][r]==opera[1][r]) r++;
- if(r==10) {removal_data(0,1);return 0;}
- opera[0][r]>opera[1][r]?(one=0,two=1):(one=1,two=0);
- }
- p=opera[one][10]-1;
- q=opera[two][10]-1;
- r=p; // 保存小數點前的數
- resu[10]=r+1; // 保存小數點位
- resu[0]=0; // 用作借位標記
- while(r>0) // 小數點前相減
- {
- if(p>0&&q>0)
- {
- opera[two][q]+=resu[0];
- resu[0]=0;
- if(opera[one][p]>=opera[two][q])
- resu[r]=opera[one][p]-opera[two][q];
- else
- {
- resu[0]=1;
- resu[r]=10+opera[one][p]-opera[two][q];
- }
- p--;q--;
- }
- else
- {
- if(opera[one][p]<resu[0])
- {resu[r]=10+opera[one][p]-resu[0];}
- else
- {resu[r]=opera[one][p]-resu[0];resu[0]=0;p--;}
- }
- r--;
- }
- r=resu[10];
- p=opera[one][10];
- q=opera[two][10];
- while(r<10) // 將小數點后的數放到結果中
- {
- if(p>opera[one][11]&&q>opera[two][11]) break;
- else if(p<=opera[one][11]&&q<=opera[two][11])
- {
- if(opera[one][p]>=opera[two][q]) resu[r]=opera[one][p]-opera[two][q];
- else
- {
- resu[r]=10+opera[one][p]-opera[two][q];
- resu[0]=r;
- for(r-=1;r>0;r--) // 向前借位
- {
- if(resu[r]==0) resu[r]=9;
- else{resu[r]-=1;break;}
- }
- r=resu[0];
- }
- p++;q++;
- }
- else if(p<=opera[one][11]&&q>opera[two][11])
- {resu[r]=opera[one][p];p++;}
- else
- {
- resu[r]=10-opera[two][q];
- resu[0]=r;
- for(r-=1;r>0;r--)
- {
- if(resu[r]==0) resu[r]=9;
- else{ resu[r]-=1;break;}
- }
- r=resu[0];
- q++;
- }
- if(r==9) // 結果溢出移位
- {
- if(resu[1]==0&&resu[10]!=2)
- {
- for(r=1;r<9;r++) resu[r]=resu[r+1];
- resu[10]--;resu[9]=0;r=8;
- }
- }
- r++;
- }
- r--;
- resu[11]=r;
- if(one==0)resu[0]=opera[0][0]; // 符號位寫入
- else resu[0]=!opera[0][0];
- removal_data(0,1);
- r=1;
- while(resu[r]==0&&resu[10]!=(r+1)) r++; // 去除前端0
- resu[10]=resu[10]-r+1; // 重新寫入小數點
- p=1;
- while(r<=resu[11]){opera[0][p]=resu[r];r++;p++;}
- opera[0][0]=resu[0];opera[0][10]=resu[10];opera[0][11]=p-1;
- while(opera[0][11]>=opera[0][10]&&opera[0][opera[0][11]]==0) opera[0][11]--;
- return 1;
- }
- }
- /****************************************************************************************
- 功能: 計算器主函數
- 描述: 根據符號位,運算符調用函數
- 參數: state,save
- 返回值:無
- ****************************************************************************************/
- void calculator(void)
- {
- char data state;
- uchar data save;
- save1=0;
- dis_title_e();
- display_cnasc(0x82,3,tool_menu[0]);
- display_cnasc(0x96,2,"等于");
- display_cnasc(0x8e,2,"刪除");
- display_cnasc(0x9e,2,"退出");
- removal_data(2,0); // 0為清除顯示
- removal_data(0,0);
- i=0;j=1;
- while(1)
- {
- cal_run=0;
- state=input_data();
- if(state==1) // 根據opera[1][0]的數值調用程序
- {
- if(opera[1][0]==12&&opera[0][0]==0||opera[1][0]==13&&opera[0][0]==1)
- state=adder();
- else if(opera[1][0]==12&&opera[0][0]==1||opera[1][0]==13&&opera[0][0]==0)
- state=subtraction();
- else if(opera[1][0]==14) state=multiplication();
- else state=divider();
- }
- if(state==0) return;
- i=0;j=1;
- cal_run=1;
- switch(state)
- {
- case -1: // 結果溢出
- removal_data(2,0);
- removal_data(0,0);
- display_cnasc(0x8a,3,"溢出!!");
- save1=0;
- break;
- case 0: // 結果為零
- if(save1==0)
- {
- removal_data(2,1);
- removal_data(0,1);
- display_cnasc(0x98,1,"= ");
- display_cnasc(0x9d,1," 0");
- }
- break; // 結果顯示
- case 1:
- if(save1==0)
- {
- cal_run=1;
- display_cnasc(0x98,1,"= ");
- dis_cdata(0x98);
- }
- break;
- }
- if(save1==0) save=gotkey(); // save1記錄連續計算符
- cal_run=0;
- if((save>11&&save<16&&state==1)||save1!=0)
- {
- removal_data(2,0);
- removal_data(1,0);
- display_cnasc(0x90,6," ");
- if(opera[0][11]==0) display_cnasc(0x95,1," 0");
- else dis_cdata(0x90);
- if(save1!=0)save=save1;
- save1=0;
- display_cnasc(0x88,1,tool_cal[save-12]);
- opera[1][0]=save;
- i=1;j=1;
- }
- else if(save>=0&&save<10&&state==1)
- {
- removal_data(2,0);
- removal_data(0,0);
- opera[0][1]=save;
- opera[0][11]++;
- dis_cdata(0x90);
- i=0;j=2;
- }
- else if(save==10)
- {
- removal_data(2,0);
- removal_data(0,0);
- opera[i][10]=2;
- opera[i][11]=1;
- j=2;
- }
- else
- {
- removal_data(2,0);
- removal_data(0,0);
- }
- }
- }
-
- /*=====================================================================================
- 函數名稱:溫度功能
- 功能描述:連續檢查溫度
- 全局變量:temprun oth_run als_temp adju_si
- 參數說明:見函數
- 返回說明:無
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*溫度顯示*/
- uchar temp_func_dis(void)
- {
- uchar save[2],k;
- clear_dis();
- dis_title_e();
- display_cnasc(0x82,3,"溫度計");
- display_cnasc(0x98,3,"設定");
- display_cnasc(0x9e,3,"退出");
- display_cnasc(0x8e,1," \x1f");
- num2_asc_dis(10,0x85);
- temprun=1;
- while(1)
- {
- if(ds18b20)
- {
- if(temp.t_data[0]>99) // 溫度值大于99時
- {
- save[0]=temp.t_data[0]/100;
- save[1]=(temp.t_data[0]/10)%10;
- num2_asc_dis(save[0],0x80);
- num2_asc_dis(save[1],0x81);
- save[0]=char_num[temp.t_data[0]%10];
- num2_asc_dis(save[0],0x82);
- }
- else // 溫度小于100
- {
- con_disp(0x00,0x00,0x80,0x90,1,16);
- con_disp(0x00,0x00,0x88,0x90,1,16);
- if(temp_pn) con_disp(0x3f,0xfc,0x80,0x9d,1,3);
- else con_disp(0x00,0x00,0x80,0x9d,1,3);
- save[0]=temp.t_data[0]/10;
- save[1]=temp.t_data[0]%10;
- num2_asc_dis(save[0],0x81);
- num2_asc_dis(save[1],0x82);
- }
- save[0]='.';
- save[1]=char_num[temp.t_data[1]/10];
- display_cnasc(0x8b,1,save);
- save[0]=char_num[temp.t_data[1]%10];
- if(save[0]=='1') save[1]='2'; // 補償精度
- else if(save[0]=='7') save[1]='5';
- else if(save[0]=='8'||save[0]=='1') save[1]='7';
- else save[1]='0';
- display_cnasc(0x8c,1,save);
- }
- else
- {
- clear_dis();
- display_cnasc(0x92,4,"沒有發現");
- display_cnasc(0x8c,4,"溫感器!");
- delay_pw();
- delay_pw();
- delay_pw();
- temprun=0;
- return 0;
- }
- k=gotkey();
- if(k==2) // 進入設置菜單
- {
- display_cnasc(0x8e,1," \x04");
- delay(35000);
- display_cnasc(0x8e,1," \x1e");
- display_cnasc(0x9a,4,"\x11 (ok) \x10");
- return 1;
- }
- }
- }
- /*警報溫度設置*/
- uchar temp_func_set(void)
- {
- uchar save[2];
- temprun=0;
- oth_run=0;
- rds1302_data();
- while(1)
- {
- if(oth_run)
- {
- con_disp (0x00,0x00,0x88,0x90,2,16);
- con_disp (0xff,0xff,0x8e,0x90,2,16);
- }
- else
- {
- con_disp (0xff,0xff,0x88,0x90,2,16);
- con_disp (0x00,0x00,0x8e,0x90,2,16);
- }
- save[0]=gotkey();
- if(save[0]==1||save[0]==3) oth_run=!oth_run;
- if(save[0]==5) return 1;
- if(save[0]==11)
- {
- if(oth_run) return 0;
- else
- {
- clear_dis();
- dis_title_e();
- save[1]=save[0]=0;
- oth_run=0;
- dis_title_e();
- display_cnasc(0x82,3,"設 定");
- display_cnasc(0x90,5,"警報溫度:");
- display_cnasc(0x88,7,"高于【 】℃");
- display_cnasc(0x98,8,"低于【 】℃ \x10");
- while(1)
- {
- if(save[1]==2) con_disp(0x00,0x00,index_temp_set[save[1]].lnum,index_temp_set[save[1]].rnum,2,13);
- else con_disp(0x00,0x00,index_temp_set[save[1]].lnum,index_temp_set[save[1]].rnum,2,13);
- if(save[0]==2) con_disp(0x0f,0xff,index_temp_set[save[0]].lnum,index_temp_set[save[0]].rnum,1,13);
- else con_disp(0xff,0xff,index_temp_set[save[0]].lnum,index_temp_set[save[0]].rnum,2,13);
- save[1]=save[0];
- adju_si=0;
- oth_run=0;
- while(1)
- {
- for(i=0;i<2;i++)
- {
- j=0x8b+i*16;
- if(als_temp[i]==255) display_cnasc(j,2," off"); // 255值為關閉值
- else
- {
- save1=save[1];
- if(als_temp[i]>127) // 當數值大于127時溫度值為負數
- {
- display_cnasc(j,1,"- ");
- save[0]=char_num[(als_temp[i]-128)/10];
- save[1]=char_num[(als_temp[i]-128)%10];
- display_cnasc(j+1,1,save);
- }
- else
- {
- save[0]=' ';
- save[1]=char_num[als_temp[i]/100];
- if(save[1]=='0') save[1]=' ';
- display_cnasc(j,1,save);
- save[0]=char_num[als_temp[i]/10%10];
- save[1]=char_num[als_temp[i]%10];
- display_cnasc(j+1,1,save);
- }
- save[1]=save1;
- }
- }
- save[0]=gotkey();
- do // 輸入符號等待數值輸入或下一位
- {
- if(save[0]==13){ oth_run=1;display_cnasc(0x8b+save[1]*16,2,"- ");}
- else if(save[0]==12){ oth_run=0;display_cnasc(0x8b+save[1]*16,2," ");}
- else break;
- save[0]=gotkey();
- if(save[0]>=0&&save[0]<10||save[0]==11) break;
- }while(1);
- if(save[0]==14){ als_temp[save[1]]=255;} // 乘號直接將警報溫度關閉
- if(save[0]>=0&&save[0]<10&&save[1]<2)
- {
- if(adju_si)
- {
- adju_si=0;
- if(oth_run) als_temp[save[1]]&=0x7f; // 消去符號位
- if(als_temp[save[1]]>24&&!oth_run) als_temp[save[1]]=240;
- else als_temp[save[1]]=als_temp[save[1]]*10+save[0];
- if(oth_run&&als_temp[save[1]]>50) als_temp[save[1]]=50;
- if(!oth_run&&als_temp[save[1]]>120) als_temp[save[1]]=120;
- if(!oth_run&&als_temp[save[1]]<100) adju_si=1; // 根據數值打開連寫
- if(oth_run&&als_temp[save[1]]<10) adju_si=1;
- }
- else
- {
- als_temp[save[1]]=save[0];
- adju_si=1;
- }
- if(oth_run) als_temp[save[1]]=als_temp[save[1]]|0x80; // 寫入符號
- else als_temp[save[1]]=als_temp[save[1]]&0x7f;
- }
- if(save[0]==11)
- {
- if(als_temp[1]!=255&&als_temp[0]!=255) // 上下限溫度調整
- {
- if(save[1]==0&&als_temp[0]<als_temp[1]){als_temp[0]=als_temp[1];}
- if(save[1]==1&&als_temp[1]>als_temp[0]){als_temp[1]=als_temp[0];}
- }
- save[0]=save[1]+1;adju_si=0;break;}
- if(save[0]==10&&save[1]!=0) {save[0]=save[1]-1;adju_si=0;break;}
- }
- oth_run=0;
- if(save[0]==3&&save[1]==2) break;
- }
- save_y_or_n();
- if(oth_run)
- {
- wds1302_data(d02_temp,als_temp[0]);
- wds1302_data(d02_temp+2,als_temp[1]);
- }
- return 1;
- }
- }
- }
- }
-
-
- /*溫度計主函數*/
- void temp_func(void)
- {
- uchar t;
- while(1)
- {
- oth_run=1;
- t=temp_func_dis();
- if(t==1)
- {
- t=temp_func_set();
- if(t==0) return;
- }
- else return;
- }
- }
- /*=====================================================================================
- 函數名稱:鬧鈴功能
- 功能描述:設定鬧鈴
- 全局變量:alarm_time adju_si
- 參數說明:見函數
- 返回說明:無
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- void alarm_func(void)
- {
- uchar save[2],a,d;
- clear_dis();
- dis_title_e();
- display_cnasc(0x82,3,"鬧 鐘");
- display_cnasc(0x91,6,"狀態:\x11 \x10");
- display_cnasc(0x89,3,"鬧鈴:");
- display_cnasc(0x9f,1,"→");
- display_cnasc(0x90,1,"『");
- display_cnasc(0x8f,1,"』");
- adju_si=0;
- a=0;d=0;
- save[0]=char_num[alarm_time[0]>>4];
- save[1]=char_num[alarm_time[0]&0x0f];
- display_cnasc(0x8c,1,save);
- display_cnasc(0x8d,1,": ");
- save[0]=char_num[alarm_time[1]>>4];
- save[1]=char_num[alarm_time[1]&0x0f];
- display_cnasc(0x8e,1,save);
- do
- {
- if(a==0)
- {
- display_cnasc(0x95,1,alm_sign[alm]);
- display_cnasc(0x94,1,"\x11 ");
- display_cnasc(0x96,1," \x10");
- con_disp(0x00,0x00,index_alm[d-1].lnum,index_alm[d-1].rnum,1,14);
- }
- if(a>0&&a<4)
- {
- if(d==0)
- {
- display_cnasc(0x94,1," ");
- display_cnasc(0x96,1," ");
- }
- else
- con_disp(0x00,0x00,index_alm[d-1].lnum,index_alm[d-1].rnum,1,14);
- con_disp(0xff,0xff,index_alm[a-1].lnum,index_alm[a-1].rnum,1,14);
- }
- d=a;
- while(1)
- {
- a=gotkey();
- if((a==1||a==3)&&d==0)
- {
- alm=!alm;
- if(a==1) display_cnasc(0x94,1,"\x09 ");
- else display_cnasc(0x96,1," \x09");
- delay(35000);
- if(a==1) display_cnasc(0x94,1,"\x11 ");
- else display_cnasc(0x96,1," \x10");
- display_cnasc(0x95,1,alm_sign[alm]);
- }
- if(d>0&&d<3&&a>=0&&a<10)
- {
- if(adju_si)
- {
- alarm_time[d-1]<<=4;alarm_time[d-1]+=a;
- if(d==1&&alarm_time[0]>0x23) alarm_time[0]=a;
- else if(d==2&&alarm_time[1]>0x59) alarm_time[1]=a;
- else adju_si=0;
- }
- else
- {
- alarm_time[d-1]=a;adju_si=1;
- }
- save[0]=char_num[alarm_time[d-1]>>4];
- save[1]=char_num[alarm_time[d-1]&0x0f];
- display_cnasc(0x8c+(d-1)*2,1,save);
- }
- if(a==11){a=d+1;break;}
- if(a==10&&d!=0){a=d-1;break;}
- }
- adju_si=0;
- if(a==4)
- {
- save_y_or_n();
- wds1302_data(d02_signs,signs);
- wds1302_data(d02_alm,alarm_time[0]);
- wds1302_data(d02_alm+2,alarm_time[1]);
- return;
- }
- }while(1);
- }
- /*=====================================================================================
- 函數名稱:籃球器功能
- 功能描述:分數 時間 24秒
- 全局變量:resu opera
- 參數說明:見函數
- 返回說明:無
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*比賽設置*/
- void nba_set(void)
- {
- uchar nba,save1,key,save[2];
- clear_dis();
- dis_title_e();
- if(resu[7]==1) display_cnasc(0x82,3,"加 時");
- else
- {
- display_cnasc(0x82,3,"設 定");
- opera[0][0]=0;
- opera[1][0]=1;
- }
- resu[6]=0; // 賦初值
- resu[0]=1;
- resu[1]=4;
- resu[2]=12;
- resu[3]=0;
- resu[4]=24;
- display_cnasc(0x90,7,"隊1:紅 隊2:白");
- display_cnasc(0x88,7,"24秒:Y 節數:4");
- display_cnasc(0x98,8,"每節時間: 12分鐘");
- save1=0;nba=0;
- while(1)
- {
- if(save1==4) display_cnasc(0x9c,1,":");
- else display_cnasc(index_nba[save1],1," ");
- if(nba==4) display_cnasc(0x9c,1,":\x10");
- else display_cnasc(index_nba[nba],1,"\x11 ");
- save1=nba;
- key=gotkey();
- if(key==1||key==3)
- {
- switch(nba) // 導航更改數據
- {
- case 0:
- case 1:
- if(key==1){if(opera[nba][0]>0) opera[nba][0]--;
- else opera[nba][0]=7;}
- if(key==3){if(opera[nba][0]<7) opera[nba][0]++;
- else opera[nba][0]=0;}
- display_cnasc(index_nba[nba]-1,1,nba_oppo[opera[nba][0]]);
- break;
- case 2:
- if(resu[0]>0) resu[0]=0;
- else resu[0]=1;
- if(resu[0]>0) display_cnasc(0x8a,1,":Y");
- else display_cnasc(0x8a,1,":N");
- break;
- case 3:
- if(key==1){if(resu[1]>1) resu[1]--;
- else resu[1]=4;}
- if(key==3){if(resu[1]<4) resu[1]++;
- else resu[1]=1;}
- save[0]=':';
- save[1]=char_num[resu[1]];
- display_cnasc(0x8e,1,save);
- break;
- case 4:
- if(key==1){if(resu[2]>0) resu[2]--;
- else resu[2]=60;}
- if(key==3){if(resu[2]<60) resu[2]++;
- else resu[2]=0;}
- save[0]=char_num[resu[2]/10];
- save[1]=char_num[resu[2]%10];
- display_cnasc(0x9d,1,save);
- resu[5]=resu[2];
- break;
- }
- }
- if(key==11)
- {
- nba++; if(nba==5) return;
- }
- if(key==10&&nba!=0) nba--;
- }
- }
- /*界面其他元素*/
- void nba_oth_dis(void)
- {
- uchar save[2];
- if(resu[7]==1) display_cnasc(0x80,5,"加時時間:");
- else display_cnasc(0x80,5,"比賽時間:");
- display_cnasc(0x98,1,nba_oppo[opera[0][0]]);
- display_cnasc(0x9e,1,nba_oppo[opera[1][0]]);
- display_cnasc(0x99,1,"隊");
- display_cnasc(0x9f,1,"隊");
- save[0]='0';
- save[1]=char_num[resu[6]+1];
- display_cnasc(0x9b,1,save);
- display_cnasc(0x9c,1,"st");
- con_disp(0xff,0xff,0x83,0x90,2,1); // 畫正方框
- con_disp(0xff,0xff,0x8b,0x8f,2,1);
- con_disp(0x80,0x00,0x83,0x91,1,15);
- con_disp(0x00,0x01,0x84,0x91,1,15);
- con_disp(0x80,0x00,0x8b,0x80,1,15);
- con_disp(0x00,0x01,0x8c,0x80,1,15);
- nba_dis_time();
- if(resu[0]==0) display_cnasc(0x93,2,"\x07--\x07");
- display_cnasc(0x8b,2," S! ");
- }
- /*籃球器主函數*/
- void nba_timer(void)
- {
- uchar save,key,nba=0;
- als=di0=1;alm=keb=di1=oth_run=0;
- time_init();
- display_cnasc(0x82,3,"籃球器");
- dis_title_e();
- removal_data(0,1);
- while(1) // 使用說明
- {
- display_cnasc(0x90,8,timer_tips[nba]);
- display_cnasc(0x88,8,timer_tips[nba+1]);
- display_cnasc(0x98,8,timer_tips[nba+2]);
- key=gotkey();
- if(key==11)
- {
- nba+=3;
- if(nba>9) break;
- }
- if(key==10)
- {
- if(nba>0) nba-=3 ;
- }
- }
- nn:
- nba_set();
- clear_dis();
- nba_oth_dis();
- nba_tim=1;
- while(1)
- {
- for(save=0x80,nba=0;nba<2;nba++)
- {
- if(opera[nba][1]>99) // 分數顯示
- {
- num2_asc_dis(opera[nba][1]/100,save);
- num2_asc_dis(opera[nba][1]/10%10,save+1);
- num2_asc_dis(opera[nba][1]%10,save+2);
- }
- else
- {
- num2_asc_dis(opera[nba][1]/10,save);
- num2_asc_dis(opera[nba][1]%10,save+1);
- }
- if(opera[1][1]>99) save=0x85;
- else save=0x86;
- }
-
- do
- {
- key=gotkey();
- ss:
- switch(key)
- {
- case 12:
- case 13:
- if(key==12)
- {if(opera[0][1]<250) opera[0][1]++;}
- else
- {if(opera[0][1]>0) opera[0][1]--;}
- save=110;
- break;
- case 14:
- case 15:
- if(key==14)
- {if(opera[1][1]<250) opera[1][1]++;}
- else
- {if(opera[1][1]>0) opera[1][1]--;}
- save=110;
- break;
- case 7:
- TR1=TR0=EA=0;
- if((++resu[3])>59)
- {
- resu[3]=0;
- if((++resu[2])>59)
- {
- resu[3]=0;
- if(++resu[2]>60) resu[2]=0;
- }
- }
- if(resu[4]<24) resu[4]++;
- nba_dis_time();
- break;
- case 8:
- if(resu[0]==1)
- {
- TL1=(time_count&0x00FF);
- TH1=(time_count>>8);
- resu[4]=24; nba_dis_time();
- TR0=TR1=EA=1;
- }
- break;
- case 9:
- if(resu[2]==0&&resu[3]==0)
- {
- resu[2]=resu[5];resu[4]=24;
- if(resu[6]==resu[1])
- { // 判斷比分進行加時賽
- if(opera[0][1]==opera[1][1]){nba_tim=0;resu[7]=1; goto nn;}
- while(gotkey()!=10); // 否則只能退出
- signs=r1302(d02_signs+1);
- nba_tim=0;
- return;
- }
- else nba_oth_dis();
- break;
- }
- if(EA) {TR0=TR1=EA=0;break;}
- if(!EA&resu[4]!=0){ EA=TR0=1;if(resu[0]==1) TR1=1;}
- break;
- case 10:
- case 11:
- if(!EA) // 暫停狀態下 ok鍵兩次返回時鐘界面
- { // ./s 鍵兩次退出
- delay(6000);
- save=gotkey();
- if(save==key)
- {
- if(key==11)
- {
- clear_dis();oth_run=1;
- rds1302_time();
- init_d2=1;
- dis_mode2();
- init_d2=0;
- while(gotkey()!=11);
- oth_run=0;
- save=110;
- clear_dis();
- nba_oth_dis();
- }
- else{ signs=r1302(d02_signs+1); nba_tim=0;return;}
- }
- else{ key=save;goto ss;}
- }
- break;
- }
- if(save==110) break;
- }while(1);
- }
- }
-
- /*=====================================================================================
- 函數名稱:設置功能
- 功能描述:系統狀態設置
- 全局變量:signs
- 參數說明:見函數
- 返回說明:無
- 設 計 人:JZHG
- 版 本:1.0
- 說 明:
- ======================================================================================*/
- /*設置調整內容 參數格式:選中設置項,設置項子值*/
- uchar set_dis(uchar menu,uchar sub)
- {
- uchar save;
- con_disp(0xff,0xff,0x8e,0x80,2,16);
- con_disp(0x00,0x00,0x8a,0x80,4,16);
- display_cnasc(0x96,1,"\x1e ");
- display_cnasc(0x9e,1,"\x1f ");
- display_cnasc(0x92,1," ");
- display_cnasc(0x9a,1," ");
- display_cnasc(0x8d,1,"\x11 ");
- display_cnasc(0x8a,1," ");
- while(1)
- {
-
- if(menu<2)
- display_cnasc(0x8e,2,set_bl_dm[menu][sub]);
- else
- display_cnasc(0x8e,2,set_mka[menu-2][sub]);
- save=gotkey();
- if(save==5)
- {
- key_dis(0x96);
- if(sub==0&&menu<2) sub=2;
- else if(sub==0&&menu>1) sub=1;
- else sub--;
- }
- if(save==2)
- {
- key_dis(0x9e);
- if(sub==2&&menu<2) sub=0;
- else if(sub==1&&menu>1) sub=0;
- else sub++;
- }
- if(save==1||save==11)
- {
- display_cnasc(0x8d,1,"\x04 ");
- delay(30000);
- con_disp(0x00,0x00,0x8e,0x80,2,16);
- con_disp(0xff,0xff,0x8a,0x80,4,16);
- display_cnasc(0x92,1,"\x1e ");
- display_cnasc(0x9a,1,"\x1f ");
- display_cnasc(0x96,1," ");
- display_cnasc(0x9e,1," ");
- display_cnasc(0x8a,1,"【");
- display_cnasc(0x8d,3,"】\x10 \x04 ");
- return(sub); // 返回設置值
- }
- }
- }
- /*設置調整*/
- void set_func(void)
- {
- uchar d,key,save;
- display_cnasc(0x81,2,"設置");
- dis_title();
- display_cnasc(0x88,8,selected[1]);
- con_disp(0xff,0xff,0x8a,0x80,4,16);
- save=d=0;
- do
- {
- display_cnasc(0x93,2,set_menu[index_s[save].lnum]);
- display_cnasc(0x8b,2,set_menu[save]);
- display_cnasc(0x9b,2,set_menu[index_s[save].rnum]);
- d=save;
- while(1)
- {
- key=gotkey();
- if(key==11||key==3){ enter_dis();break;}
- if(key==5){save=index_s[d].lnum;key_dis(0x92); break;}
- if(key==2){save=index_s[d].rnum;key_dis(0x9a); break;}
- if(key==1){ wds1302_data(d02_signs,signs); return;}
- }
- if(key==11||key==3)
- {
- save=0;
- for(key=0;key<2;key++) // 進行兩次比較 首次為現時值 其次為設定置更改
- {
- …………余下代碼請下載附件…………
復制代碼
|