分享個(gè)51單片機(jī)做的萬(wàn)年歷給大家伙,資料僅供參考,用于任何商業(yè)用途概不負(fù)責(zé)。
QQ截圖20160511172449.jpg (880.35 KB, 下載次數(shù): 201)
下載附件
2016-5-11 17:28 上傳
QQ截圖20160511172500.jpg (1.05 MB, 下載次數(shù): 149)
下載附件
2016-5-11 17:29 上傳
萬(wàn)年歷原理圖:
0.png (88.1 KB, 下載次數(shù): 148)
下載附件
2016-5-11 19:16 上傳
電路.jpg (101.48 KB, 下載次數(shù): 184)
下載附件
2016-5-11 19:11 上傳
0.png (101.22 KB, 下載次數(shù): 147)
下載附件
2016-5-11 19:15 上傳
萬(wàn)年歷所有資料打包下載:
12864萬(wàn)年歷.rar
(4.1 MB, 下載次數(shù): 810)
2016-5-11 17:32 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
12864萬(wàn)年歷V5.2版本:多功能菜單、多風(fēng)格主界面,生日、節(jié)日、節(jié)氣、農(nóng)歷時(shí)段多功能提示,鬧鐘、音樂(lè)、溫度、屏幕自檢 一、電源電壓4.8V—5.2V,可以直接用電腦USB供電。 二、程序修改說(shuō)明 1、如果你編譯通不過(guò),就是你用的KEIL庫(kù)文件不全,請(qǐng)換個(gè)完整版本的KEIL,或到我店鋪購(gòu)買(mǎi),本程序是完全編譯通過(guò),且沒(méi)有1個(gè)警告; 2、本程序由于農(nóng)歷,節(jié)氣等數(shù)據(jù)很占空間,編譯后有19K多,請(qǐng)使用程序存儲(chǔ)器20K以上的51單片機(jī),比如STC89C55、STC89C58,STC89C516,AT89C55,AT89S54,SST89C58等; 3、如果你的漢字顯示不全或亂碼,比如“三“顯示不了,那是你的KEIL沒(méi)有打補(bǔ)丁,并不是程序問(wèn)題,至于什么補(bǔ)丁你可以網(wǎng)上搜或向我索要; 4、在修改位定義的時(shí)候需要將Soundplay.h文件下的sbit BeepIO = P3^7; sbit KEY_1 = P2^7;一起修改; 5、蜂鳴器請(qǐng)最好使用無(wú)源蜂鳴器或小喇叭,這樣音質(zhì)會(huì)很好。 三、生日、節(jié)氣和節(jié)日提示說(shuō)明 1、本萬(wàn)年歷的各種提示會(huì)在主界面第四行交替顯示,其中生日和節(jié)氣優(yōu)先顯示。
元件清單:
名稱(chēng) | 數(shù)量 | 說(shuō)明 | STC89C54(STC89C516)單片機(jī) | 1 | 內(nèi)存≥20K的51單片機(jī)都可以 | DS1302 | 1 |
| DS18B20 | 1 |
| 40DIP座 | 1 |
| 8DIP座 | 1 |
| 3DIP座 | 1 |
| 20芯座 | 1 |
| 20芯插針 | 1 |
| 10K排阻 | 1 | 可以不安裝 | 無(wú)源蜂鳴器 | 1 |
| CR2032電池 | 1 |
| 電池座 | 1 |
| 電源座 | 1 |
| 按鍵 | 4 |
| 開(kāi)關(guān) | 1 |
| 32768HZ晶振 | 1 |
| 11.0592MHZ晶振 | 1 |
| S8050三極管 | 1 |
| 30P電容 | 2 |
| 103電容 | 1 | 可以不安裝 | 10uF電解 | 1 |
| 4.7K電阻 | 1 |
| 10K電阻 | 2 |
| 220uF電解 | 1 | 可以不安裝 | PCB | 1 |
| 12864液晶 | 1 | ST7920驅(qū)動(dòng)字庫(kù)液晶 | 柱子 | 4 |
|
部分源碼預(yù)覽:
- /*****************************************************************************/
- //12864液晶萬(wàn)年歷 時(shí)鐘2010年最新 V5.2版
- //設(shè)計(jì): 楊黎民
- //程序部分開(kāi)始
- //更新日期:2016
- //主要特點(diǎn):多功能菜單、多風(fēng)格主界面,生日、節(jié)日、節(jié)氣、農(nóng)歷時(shí)段多功能提示,鬧鐘、音樂(lè)、溫度、屏幕自檢
- //5.1增加了調(diào)整時(shí)間反白和鬧鐘設(shè)置反白顯示
- //5.2調(diào)整了生日和節(jié)氣優(yōu)先顯示
- /****************************************************************************/
- //頭文件
- #include <AT89X52.h>
- #include <string.h>
- #include <intrins.h>
- #include "SoundPlay.h"//音樂(lè)文件
- #define uchar unsigned char
- #define uint unsigned int
- /*****************************************************************************/
- //揚(yáng)聲器定義
- sbit beep = P3^7;//揚(yáng)聲器
- /*****************************************************************************/
- //溫度傳感器定義
- sbit DQ = P2 ^ 0;//ds18B20
- uint tvalue;//溫度值
- uchar tflag,flagdat,t,hh1;//溫度正負(fù)標(biāo)志
- /*****************************************************************************/
- //鍵盤(pán)引腳定義
- //sbit KEY_1 = P2^7; //左上,在音樂(lè)文件SoundPlay.h中已定義
- sbit KEY_2 = P2^6; //左下
- sbit KEY_3 = P2^5; //右上
- sbit KEY_4 = P2^4; //右下
- /****************************************************************************/
- //定義DS1302時(shí)鐘接口
- sbit clock_clk = P2 ^ 1;//ds1302_clk(時(shí)鐘線(xiàn))
- sbit clock_dat = P2 ^ 2;//ds1302_dat(數(shù)據(jù)線(xiàn))
- sbit clock_Rst = P2 ^ 3;//ds1302_Rst(復(fù)位線(xiàn))
- //定義累加器A中的各位
- sbit a0 = ACC ^ 0;
- sbit a1 = ACC ^ 1;
- sbit a2 = ACC ^ 2;
- sbit a3 = ACC ^ 3;
- sbit a4 = ACC ^ 4;
- sbit a5 = ACC ^ 5;
- sbit a6 = ACC ^ 6;
- sbit a7 = ACC ^ 7;
- /****************************************************************************/
- //定義全局變量
- unsigned char yy,mo,dd,xq,hh,year,year1;//定義時(shí)間映射全局變量(專(zhuān)用寄存器)
- unsigned char shi,ge,sec_temp,min_temp,hour_temp,secl,selx,e=0,hh1,mm1,k,mm,ss,n;
- char n1,n2;
- bit w = 0; //調(diào)時(shí)標(biāo)志位
- static unsigned char menu = 0;//定義靜態(tài)小時(shí)更新用數(shù)據(jù)變量
- static unsigned char keys = 0;//定義靜態(tài)小時(shí)更新用數(shù)據(jù)變量
- static unsigned char timecount = 0;//定義靜態(tài)軟件計(jì)數(shù)器變量
- /****************************************************************************/
- //-----------------------------------------------
- //TS12864并口相關(guān)設(shè)定//
- #define BUSY_FLAG P0_7 //液晶模塊忙標(biāo)志
- #define MPU_RS_CH P1_5 //寄存器選擇輸入
- #define MPU_RW_CH P1_6 //讀寫(xiě)控制
- #define MPU_ENABLE P1_7 //使能控制
- #define LCD_DATA P0 //液晶數(shù)據(jù)口
- //-----------------------------------------------
- #define LOW 0 //低電平
- #define HIGH 1 //高電平
- #define OFF 0 //邏輯關(guān)
- #define ON 1 //邏輯開(kāi)
- //-----------------------------------------------
- //液晶模塊指令集定義
- #define cClearDisplay 0x01 //清顯示指令
- #define cEntryModeSet 0x06 //設(shè)置輸入模式
- #define cDisplayOnCtrl 0x0c //設(shè)置開(kāi)顯控制
- #define cFunctionSetB 0x30 //功能設(shè)定(基本指令)
- #define cFunctionSetE 0x34 //功能設(shè)定(擴(kuò)充指令)
- #define cFuncDrawOn 0x36 //設(shè)置繪圖功能
- //-----------------------------------------------
- uchar xdata lcdPosX, lcdPosY; //X,Y坐標(biāo)
- uchar xdata halfScr, halfLineCnt, basicBlock; //半屏,半屏行數(shù),N*8塊
- //-----------------------------------------------
- //子程序聲明和用法
- bit scanKey1 (void);
- //按鍵1檢測(cè)
- void procKey (void);
- //按鍵處理子程序
- void lcdInit (void);
- //初始化LCD子程序
- void lcdClear (void);
- //清除LCD文本屏幕子程序
- void lcdWriteCommand (uchar Command);
- //寫(xiě)入控制命令到LCD子程序
- //輸入?yún)?shù):LCD控制指令
- void lcdWriteData (uchar Data);
- //寫(xiě)入顯示數(shù)據(jù)到LCD子程序
- //輸入?yún)?shù):顯示數(shù)據(jù)
- void checkLcdBusy (void);
- //檢測(cè)LCD忙碌子程序
- void displayPhoto (uchar *bmp, uchar bmpCls);
- //全屏顯示圖形子程序
- //輸入?yún)?shù):*bmp=圖形數(shù)據(jù)
- //bmpCls=清除圖形屏幕選項(xiàng)(OFF為不清屏,即顯示圖形,ON為清屏)
- void convertChar (uchar CX, CY, width);
- //字符反白顯示
- //輸入?yún)?shù):CX=要反白字符的行(0-3)
- //CY=要反白字符的列(0-7)
- //width=要反白字符的長(zhǎng)度(1-16)
- void wrPosition (void);
- //坐標(biāo)寫(xiě)入子程序
- void dispString (uchar X, Y, speed, uchar *msg);
- //顯示字符串子程序
- //輸入?yún)?shù):X=行(0-3), Y=列(0-7), speed=顯示速度(毫秒), msg=字符數(shù)據(jù)
- void beepBl (void);
- //蜂鳴器響一聲子程序
- void delayMs (uchar ms);
- //延時(shí)(毫秒)子程序
- //輸入?yún)?shù):毫秒數(shù)
- void delaySec (uchar sec);
- //延時(shí)(秒)子程序
- //輸入?yún)?shù):秒數(shù)
- void init_dz();
- void clear_img();
- //===============================================
- //12864液晶驅(qū)動(dòng)
- //===============================================
- void lcdInit (void)
- {
- lcdWriteCommand(cFunctionSetE);
- lcdWriteCommand(cFunctionSetB);
- lcdClear();
- lcdWriteCommand(cEntryModeSet);
- lcdWriteCommand(cDisplayOnCtrl);
- if(k==1){clear_img();lcdClear();
- }
- if(k==0){lcdClear(); clear_img();init_dz();
- }
- }
- //===============================================
- void lcdClear (void)
- {
- lcdWriteCommand(cClearDisplay);
- }
- //===============================================
- void lcdWriteCommand (uchar Command)
- {
- checkLcdBusy();
- MPU_RS_CH = LOW;
- MPU_RW_CH = LOW;
- LCD_DATA = Command;
- MPU_ENABLE = HIGH;
- delayMs(1);
- MPU_ENABLE = LOW;
- }
- //===============================================
- void lcdWriteData (uchar Data)
- {
- checkLcdBusy();
- MPU_RS_CH = HIGH;
- MPU_RW_CH = LOW;
- LCD_DATA = Data;
- MPU_ENABLE = HIGH;
- delayMs(1);
- MPU_ENABLE = LOW;
- }
- //===============================================
- void checkLcdBusy (void)
- {
- LCD_DATA = 0xff;
- MPU_RS_CH = LOW;
- MPU_RW_CH = HIGH;
- MPU_ENABLE = HIGH;
- while (BUSY_FLAG);
- MPU_ENABLE = LOW;
- }
- //===============================================
- void displayPhoto (uchar *bmp, uchar bmpCls)
- {
- lcdPosX = 0x80;
- halfScr = 2;
-
- for (;halfScr != 0; halfScr--)
- {
- lcdPosY = 0x80;
- halfLineCnt = 32;
-
- for (;halfLineCnt != 0; halfLineCnt--)
- {
- basicBlock = 16;
- wrPosition ();
-
- for (; basicBlock != 0; basicBlock--)
- {
- if (bmpCls == OFF)
- {
- lcdWriteData (*bmp++);
- }
- else if (bmpCls == ON)
- {
- lcdWriteData (0x00);
- }
- }
- lcdPosY++;
- }
- lcdPosX = 0x88;
- }
- lcdWriteCommand(cFuncDrawOn);
- lcdWriteCommand(cFunctionSetB);
- }
- //===============================================
- void convertChar (uchar CX, CY, width)
- {
- displayPhoto(OFF,ON);
- lcdPosY = 0x80;
- if (CX == 0)
- {
- CX = 0x80;
- halfLineCnt = 16;
- }
- else if (CX == 1)
- {
- CX = 0x80;
- halfLineCnt = 32;
- }
- else if (CX == 2)
- {
- CX = 0x88;
- halfLineCnt = 16;
- }
- else if (CX == 3)
- {
- CX = 0x88;
- halfLineCnt = 32;
- }
- lcdPosX = CX + CY;
-
- for (; halfLineCnt != 0; halfLineCnt--)
- {
- basicBlock = width;
- wrPosition();
-
- for (;basicBlock != 0; basicBlock--)
- {
- if (halfLineCnt > 16)
- {
- lcdWriteData(0x00);
- }
- else
- {
- lcdWriteData (0xff);
- }
- }
- lcdPosY++;
- }
- lcdWriteCommand(cFuncDrawOn);
- lcdWriteCommand(cFunctionSetB);
- }
- //===============================================
- void wrPosition (void)
- {
- lcdWriteCommand(cFunctionSetE);
- lcdWriteCommand(lcdPosY);
- lcdWriteCommand(lcdPosX);
- lcdWriteCommand(cFunctionSetB);
- }
- //===============================================
- void dispString (uchar X, Y, speed, uchar *msg)
- {
- if (X == 0)
- {
- X = 0x80;
- }
- else if (X == 1)
- {
- X = 0x90;
- }
- else if (X == 2)
- {
- X = 0x88;
- }
- else if (X == 3)
- {
- X = 0x98;
- }
- Y = X + Y;
- lcdWriteCommand(Y);
- while (*msg)
- {
- lcdWriteData(*msg++);
- delayMs(speed);
- }
- }
- //===============================================
- void delayMs (uchar ms)
- {
- uchar i;
- while (--ms)
- {
- for (i = 0; i < 125; i++);
- }
- }
- /********************************************************************************************************
- 清理圖片緩沖區(qū)
- ********************************************************************************************************/
- void clear_img()
- {
- uchar i,j;
- for(i=0;i<32;i++)
- {
- lcdWriteCommand(0x80+i);
- lcdWriteCommand(0x80);
- for(j=0;j<16;j++)
- {
- lcdWriteData(0x00);
- }
- }
- for(i=0;i<32;i++)
- {
- lcdWriteCommand(0x80+i);
- lcdWriteCommand(0x88);
- for(j=0;j<16;j++)
- {
- lcdWriteData(0x00);
- }
- }
- }
- /******************************************************************************/
- uchar code powerOnPhoto []={
- /*-- 一幅圖像 KISS- 正向取模,字節(jié)正序*/
- /*-- 寬度x高度=128x64 --*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xFF,0xFF,0xFF,0x9F,0x00,0x00,0x0F,0x0E,0x00,0x00,0x00,0x00,0x19,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xBF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFD,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xFF,0xFF,0xF3,0xE0,0x00,0x00,0x1F,0xFD,0x80,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFA,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xFF,0xFF,0xF0,0x00,0x00,0x00,0x03,0xF8,0x01,0xFF,0xFF,0xE0,0x00,0x07,0xFF,0xFF,
- 0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0xF0,0x3F,0xFF,0xFF,0xFE,0x00,0x30,0x00,0x00,
- 0x00,0x00,0x00,0x7F,0xFF,0xFF,0x80,0x41,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
- 0xFF,0xFF,0x01,0xFF,0xFF,0xFF,0xF0,0x02,0x7F,0xFF,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,
- 0x00,0x00,0x03,0xFF,0xFF,0xFF,0xF8,0x04,0x3F,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,
- 0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFC,0x08,0x73,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,
- 0xFF,0xE4,0x3F,0x7F,0xFF,0xFF,0xFF,0x30,0x2F,0xFF,0xFF,0xFF,0xFE,0x00,0x7F,0xFF,
- 0x00,0x00,0xFE,0x9F,0xFF,0xFF,0xFF,0xB0,0x1D,0xFF,0xFF,0xFF,0x3F,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0x7F,0xFF,0xFF,0xFF,0xC2,0x23,0x3F,0xFF,0xFE,0x1F,0x80,0x00,0x00,
- 0xFF,0xE1,0xFF,0xFF,0xFF,0xFF,0xFC,0xC5,0x92,0xFF,0xB7,0xB8,0xC9,0x80,0x7F,0xFF,
- 0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFC,0x4F,0xEF,0x3F,0xC8,0x1A,0x20,0xC0,0x00,0x00,
- 0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xF8,0x7F,0xFF,0xFF,0x75,0x86,0xF6,0xC0,0x00,0x00,
- 0xFF,0x03,0xEF,0x9F,0xFB,0xFF,0xF8,0x7F,0xFF,0xFF,0xFB,0xDF,0xFE,0xC0,0x7F,0xFF,
- 0x00,0x07,0xDE,0x7F,0xC7,0xFF,0xF0,0x7E,0x7F,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,
- 0x00,0x07,0x1C,0xF7,0x9F,0xDF,0xF0,0x7E,0x7F,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,
- 0xFC,0x07,0x00,0x8C,0x1F,0xBF,0xE7,0x3C,0x3F,0xFF,0xFF,0xFF,0xFF,0xC0,0x7F,0xFF,
- 0x00,0x07,0x00,0x08,0x1C,0x3F,0x88,0x3C,0x7F,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,
- 0x00,0x06,0x0C,0x08,0x98,0x7F,0x80,0x0D,0x9F,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,
- 0xFC,0x06,0x1C,0xE3,0x99,0xFF,0x00,0x0C,0x0F,0xFF,0xFF,0xFF,0xFF,0xC0,0x5F,0xFF,
- 0x00,0x06,0xF1,0xE3,0x83,0xFE,0x00,0x08,0x03,0xDF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,
- 0x00,0x06,0xF1,0xF7,0xC7,0xFE,0x00,0x08,0x01,0xCF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,
- 0xFC,0x06,0xF3,0xF7,0xC7,0xFC,0x03,0x08,0x00,0x01,0xFF,0xFF,0xFF,0xC0,0xBF,0xFF,
- 0x00,0x07,0xF3,0xFF,0xE7,0xF0,0x03,0x09,0x80,0x00,0xFF,0xFF,0xFF,0xC0,0x00,0x00,
- 0x00,0x07,0xFF,0xFF,0xFF,0xE0,0x03,0x09,0x80,0x00,0x3F,0xFF,0xFF,0x80,0x00,0x00,
- 0xFC,0x07,0xFF,0xFF,0xFF,0xC0,0x03,0x09,0x80,0x00,0x0F,0xFF,0xFF,0x83,0xFF,0xFF,
- 0x00,0x07,0xFF,0xE0,0xFE,0x00,0x03,0x09,0x80,0x00,0x07,0xFF,0xFF,0x80,0x00,0x00,
- 0x00,0x07,0xFF,0x80,0x7C,0x00,0x07,0xB1,0x80,0x00,0x07,0x83,0xFF,0x00,0x00,0x00,
- 0xFF,0x07,0xFF,0x0C,0x00,0x00,0x7F,0xB3,0xC0,0x00,0x06,0x01,0xFE,0x03,0xFF,0xFF,
- 0x00,0x07,0xFF,0x03,0x00,0x00,0x1F,0x43,0xFC,0x00,0x06,0x38,0xFE,0x00,0x00,0x00,
- 0x00,0x07,0xFF,0x03,0x00,0x00,0x00,0x81,0xF0,0x00,0x04,0x40,0xF8,0x00,0x00,0x00,
- 0xFC,0x87,0xFF,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x04,0x40,0xF0,0x07,0xFF,0xFF,
- 0x00,0x07,0xFF,0x80,0x00,0x2C,0x00,0x80,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,
- 0x00,0x07,0xFF,0x80,0x00,0x52,0x00,0x40,0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
- 0xFF,0x83,0xFF,0xF0,0x80,0x2C,0x00,0x40,0x00,0x00,0x00,0x01,0xC0,0x7F,0xFF,0xFF,
- 0x00,0x03,0xFF,0xFF,0x80,0x00,0x00,0x30,0x00,0x00,0x01,0x86,0x00,0x00,0x00,0x00,
- 0x00,0x03,0xFF,0xFF,0x80,0x00,0x00,0x38,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0x00,
- 0xFF,0xA3,0xFF,0xFF,0x80,0x00,0x00,0x44,0x00,0x00,0x01,0xFF,0x00,0x7F,0xFF,0xFF,
- 0x00,0x03,0xFF,0xFF,0x80,0x00,0x03,0x82,0x00,0x00,0x01,0xC0,0xC0,0x00,0x00,0x00,
- 0x00,0x03,0xFF,0xFF,0x80,0x00,0x1C,0x01,0xC0,0x00,0x00,0x78,0xC0,0x00,0x00,0x00,
- 0xFF,0x81,0xFF,0xFF,0xC0,0x3F,0xE0,0x00,0x3C,0x00,0x07,0x80,0x20,0x7F,0xFF,0xFF,
- 0x00,0x01,0xFF,0xFF,0xE0,0x40,0x00,0x00,0x03,0xFE,0x78,0x00,0x20,0x00,0x00,0x00,
- 0x00,0x01,0xFF,0xFF,0xF8,0x40,0x00,0x00,0x00,0x21,0x80,0x00,0x10,0x00,0x00,0x00,
- 0xFF,0xC1,0xFF,0xFF,0xFC,0x40,0x00,0x00,0x00,0x2E,0x00,0x00,0x10,0x4F,0xFF,0xFF,
- 0x00,0x01,0xFF,0xFF,0xFE,0x20,0x00,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0xFF,0xFF,0xA0,0x00,0x00,0x00,0xC0,0x00,0x01,0xF8,0x00,0x00,0x00,
- 0xFF,0xE0,0xFF,0xFF,0xFB,0xE0,0x00,0x00,0x00,0xC0,0x00,0x03,0xFE,0x07,0xFF,0xFF,
- 0x00,0x00,0xFF,0xFF,0xFD,0xE0,0x00,0x00,0x00,0xC0,0x00,0x1F,0xFF,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0xFF,0xFE,0x70,0x00,0x00,0x01,0xE0,0x00,0x3F,0xFF,0x80,0x00,0x00,
- 0xFF,0xC0,0xFF,0xFF,0xFF,0xB0,0x00,0x00,0x01,0xE0,0x00,0x7F,0xFF,0xC0,0x3F,0xFF,
- 0x00,0x00,0xFF,0xFF,0xFF,0xDC,0x00,0x00,0x03,0xF7,0x81,0xFF,0xFF,0xF0,0x00,0x00,
- 0x00,0x01,0xFF,0x80,0x7F,0xDC,0x00,0x00,0x0F,0xFF,0xC3,0xFF,0xFF,0xF8,0x00,0x00,
- 0xFF,0x01,0xFF,0x00,0x1F,0xEE,0x00,0x00,0x13,0xFF,0xF7,0xFF,0xFF,0xFC,0x07,0xFF,
- 0x00,0x01,0xFE,0x00,0x07,0xEF,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
- 0x00,0x01,0xFC,0x00,0x03,0xF3,0x00,0x00,0x13,0xFF,0xBF,0xFF,0xFF,0xFF,0x80,0x00,
- 0xFF,0x01,0xFC,0x00,0x01,0xF3,0x80,0x00,0x1F,0xFF,0xBF,0xFF,0xFF,0xFF,0x83,0xFF,
- 0x00,0x01,0xF0,0x00,0x01,0xFD,0x80,0x00,0x0F,0xFF,0x7F,0xFF,0xFF,0xFF,0xC0,0x00,
- 0x00,0x03,0xF0,0x00,0x00,0x72,0xE0,0x00,0x03,0xFE,0xFF,0xFF,0xFF,0xFF,0xC0,0x00
- };
- uchar code powerOnPhoto1[]={
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x80,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x0C,0x43,0x01,0x80,0x00,0x7F,0xFF,0xF0,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x19,0xFF,0x07,0x00,0x07,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,0x3F,0xFC,0x1E,0x00,0x1F,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,0xBF,0xFF,0xFC,0x00,0x7F,0xFC,0x00,0x7F,0xC0,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x00,0xFF,0xC0,0x00,0x0F,0xE0,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,0xFC,0x01,0xF0,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,0xDF,0xFF,0xC0,0x07,0xFF,0xFF,0xFF,0x80,0xF0,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x03,0xFF,0xFF,0x00,0x0F,0xFF,0xFF,0xFF,0xE0,0x38,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x07,0xFF,0xF8,0x00,0x1F,0xFF,0xF0,0x03,0xF8,0x38,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,0x3F,0xFF,0xFF,0xC0,0x7C,0x18,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x04,0x7F,0xF0,0x00,0x3F,0xFF,0xFF,0xF8,0x1E,0x08,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,0xFF,0xF8,0x00,0x7F,0xFF,0xFF,0xFE,0x0F,0x08,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,0x87,0x08,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x1F,0xFF,0xFE,0x00,0xFF,0xFF,0xFF,0xFF,0x83,0x88,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x3F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xC3,0x88,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x7F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00,
- 0x00,0x00,0x00,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00,
- 0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF1,0x88,0x00,0x00,0x00,
- 0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF3,0x08,0x00,0x00,0x00,
- 0x00,0x00,0x01,0xFF,0xFF,0xFF,0x07,0xFF,0xFF,0xFF,0xFF,0xF2,0x10,0x00,0x00,0x00,
- 0x00,0x00,0x01,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xF0,0x20,0x00,0x00,0x00,
- 0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x70,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x7E,0x20,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x3E,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF,0x3C,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x30,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x7C,0x20,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x1E,0x78,0x00,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x1E,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xDA,0x3C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF2,0x30,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF1,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x7C,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x78,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x72,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x40,0x04,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x02,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x02,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x0C,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x38,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x0F,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- };
- uchar code tab[12][64]={
- {// 圖片數(shù)字0
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x0E,0x70,
- 0x1C,0x38,0x3C,0x3C,0x38,0x1C,0x78,0x1E,0x78,0x1E,0x78,0x1E,0x78,0x1E,0x78,0x1E,
- 0x78,0x1E,0x78,0x1E,0x78,0x1E,0x78,0x1E,0x78,0x1E,0x78,0x1C,0x38,0x1C,0x3C,0x3C,
- 0x1C,0x38,0x0E,0x70,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字1
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xC0,
- 0x1F,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
- 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
- 0x03,0xC0,0x03,0xC0,0x1F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字2
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x1C,0x78,
- 0x38,0x3C,0x78,0x3C,0x78,0x1C,0x7C,0x1C,0x38,0x1C,0x00,0x3C,0x00,0x3C,0x00,0x78,
- 0x00,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x07,0x00,0x0E,0x0E,0x1C,0x0E,0x38,0x0C,
- 0x70,0x1C,0x7F,0xFC,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字3
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0xF0,
- 0x38,0x78,0x38,0x3C,0x38,0x3C,0x38,0x3C,0x00,0x3C,0x00,0x78,0x00,0xF0,0x07,0xE0,
- 0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0x1E,0x00,0x1E,0x38,0x1E,0x78,0x1E,0x78,0x1C,
- 0x38,0x3C,0x3C,0x78,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字4
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xF0,
- 0x00,0xF0,0x01,0xF0,0x01,0xF0,0x03,0xF0,0x07,0x70,0x06,0x70,0x0E,0x70,0x1C,0x70,
- 0x18,0x70,0x38,0x70,0x30,0x70,0x60,0x70,0xFF,0xFF,0x00,0x70,0x00,0x70,0x00,0x70,
- 0x00,0x70,0x00,0x70,0x00,0xF8,0x07,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字5
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFC,0x1F,0xFC,
- 0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x3F,0xF0,0x3E,0x78,0x38,0x3C,
- 0x38,0x1C,0x00,0x1E,0x00,0x1E,0x00,0x1E,0x00,0x1E,0x38,0x1E,0x78,0x1C,0x78,0x3C,
- 0x38,0x3C,0x1C,0x78,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字6
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x0F,0x38,
- 0x1C,0x3C,0x3C,0x3C,0x38,0x00,0x38,0x00,0x78,0x00,0x78,0x00,0x7B,0xF0,0x7E,0x78,
- 0x7C,0x3C,0x78,0x1E,0x78,0x1E,0x78,0x1E,0x78,0x1E,0x78,0x1E,0x78,0x1E,0x38,0x1C,
- 0x3C,0x3C,0x1E,0x78,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字7
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFE,0x3F,0xFC,
- 0x38,0x1C,0x30,0x18,0x70,0x38,0x70,0x30,0x00,0x70,0x00,0x60,0x00,0xE0,0x00,0xC0,
- 0x01,0xC0,0x01,0xC0,0x03,0xC0,0x03,0x80,0x03,0x80,0x07,0x80,0x07,0x80,0x07,0x80,
- 0x07,0x80,0x07,0x80,0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字8
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0x78,
- 0x38,0x1C,0x78,0x1C,0x70,0x1E,0x78,0x1E,0x78,0x1C,0x3C,0x1C,0x1F,0x38,0x0F,0xE0,
- 0x0F,0xF0,0x3C,0xF8,0x38,0x3C,0x70,0x1C,0x70,0x1E,0x70,0x1E,0x70,0x1E,0x70,0x1E,
- 0x38,0x1C,0x1C,0x38,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片數(shù)字9
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0x70,
- 0x38,0x38,0x78,0x1C,0x78,0x1C,0x70,0x1E,0x70,0x1E,0x70,0x1E,0x78,0x1E,0x78,0x3E,
- 0x78,0x3E,0x3C,0x7E,0x0F,0xDE,0x00,0x1E,0x00,0x1C,0x00,0x3C,0x00,0x3C,0x3C,0x38,
- 0x3C,0x70,0x3C,0xE0,0x1F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},
-
- {// 圖片":"
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
- {// 圖片" "
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
- };
- /******************************************************************************/
- /*
- 公歷年對(duì)應(yīng)的農(nóng)歷數(shù)據(jù),每年三字節(jié),
- 格式第一字節(jié)BIT7-4 位表示閏月月份,值為0 為無(wú)閏月,BIT3-0 對(duì)應(yīng)農(nóng)歷第1-4 月的大小
- 第二字節(jié)BIT7-0 對(duì)應(yīng)農(nóng)歷第5-12 月大小,第三字節(jié)BIT7 表示農(nóng)歷第13 個(gè)月大小
- 月份對(duì)應(yīng)的位為1 表示本農(nóng)歷月大(30 天),為0 表示小(29 天)
- 第三字節(jié)BIT6-5 表示春節(jié)的公歷月份,BIT4-0 表示春節(jié)的公歷日期
- */
- code uchar year_code[] = {
- 0x0C,0x96,0x45, //2000
- 0x4d,0x4A,0xB8, //2001
- 0x0d,0x4A,0x4C, //2002
- 0x0d,0xA5,0x41, //2003
- 0x25,0xAA,0xB6, //2004
- 0x05,0x6A,0x49, //2005
- 0x7A,0xAd,0xBd, //2006
- 0x02,0x5d,0x52, //2007
- 0x09,0x2d,0x47, //2008
- 0x5C,0x95,0xBA, //2009
- 0x0A,0x95,0x4e, //2010
- 0x0B,0x4A,0x43, //2011
- 0x4B,0x55,0x37, //2012
- 0x0A,0xd5,0x4A, //2013
- 0x95,0x5A,0xBf, //2014
- 0x04,0xBA,0x53, //2015
- 0x0A,0x5B,0x48, //2016
- 0x65,0x2B,0xBC, //2017
- 0x05,0x2B,0x50, //2018
- 0x0A,0x93,0x45, //2019
- 0x47,0x4A,0xB9, //2020
- 0x06,0xAA,0x4C, //2021
- 0x0A,0xd5,0x41, //2022
- 0x24,0xdA,0xB6, //2023
- 0x04,0xB6,0x4A, //2024
- 0x69,0x57,0x3d, //2025
- 0x0A,0x4e,0x51, //2026
- 0x0d,0x26,0x46, //2027
- 0x5e,0x93,0x3A, //2028
- 0x0d,0x53,0x4d, //2029
- 0x05,0xAA,0x43, //2030
- 0x36,0xB5,0x37, //2031
- 0x09,0x6d,0x4B, //2032
- 0xB4,0xAe,0xBf, //2033
- 0x04,0xAd,0x53, //2034
- 0x0A,0x4d,0x48, //2035
- 0x6d,0x25,0xBC, //2036
- 0x0d,0x25,0x4f, //2037
- 0x0d,0x52,0x44, //2038
- 0x5d,0xAA,0x38, //2039
- 0x0B,0x5A,0x4C, //2040
- 0x05,0x6d,0x41, //2041
- 0x24,0xAd,0xB6, //2042
- 0x04,0x9B,0x4A, //2043
- 0x7A,0x4B,0xBe, //2044
- 0x0A,0x4B,0x51, //2045
- 0x0A,0xA5,0x46, //2046
- 0x5B,0x52,0xBA, //2047
- 0x06,0xd2,0x4e, //2048
- 0x0A,0xdA,0x42, //2049
- 0x35,0x5B,0x37, //2050
- 0x09,0x37,0x4B, //2051
- 0x84,0x97,0xC1, //2052
- 0x04,0x97,0x53, //2053
- 0x06,0x4B,0x48, //2054
- 0x66,0xA5,0x3C, //2055
- 0x0e,0xA5,0x4f, //2056
- 0x06,0xB2,0x44, //2057
- 0x4A,0xB6,0x38, //2058
- 0x0A,0xAe,0x4C, //2059
- 0x09,0x2e,0x42, //2060
- 0x3C,0x97,0x35, //2061
- 0x0C,0x96,0x49, //2062
- 0x7d,0x4A,0xBd, //2063
- 0x0d,0x4A,0x51, //2064
- 0x0d,0xA5,0x45, //2065
- 0x55,0xAA,0xBA, //2066
- 0x05,0x6A,0x4e, //2067
- 0x0A,0x6d,0x43, //2068
- 0x45,0x2e,0xB7, //2069
- 0x05,0x2d,0x4B, //2070
- 0x8A,0x95,0xBf, //2071
- 0x0A,0x95,0x53, //2072
- 0x0B,0x4A,0x47, //2073
- 0x6B,0x55,0x3B, //2074
- 0x0A,0xd5,0x4f, //2075
- 0x05,0x5A,0x45, //2076
- 0x4A,0x5d,0x38, //2077
- 0x0A,0x5B,0x4C, //2078
- 0x05,0x2B,0x42, //2079
- 0x3A,0x93,0xB6, //2080
- 0x06,0x93,0x49, //2081
- 0x77,0x29,0xBd, //2082
- 0x06,0xAA,0x51, //2083
- 0x0A,0xd5,0x46, //2084
- 0x54,0xdA,0xBA, //2085
- 0x04,0xB6,0x4e, //2086
- 0x0A,0x57,0x43, //2087
- 0x45,0x27,0x38, //2088
- 0x0d,0x26,0x4A, //2089
- 0x8e,0x93,0x3e, //2090
- 0x0d,0x52,0x52, //2091
- 0x0d,0xAA,0x47, //2092
- 0x66,0xB5,0x3B, //2093
- 0x05,0x6d,0x4f, //2094
- 0x04,0xAe,0x45, //2095
- 0x4A,0x4e,0xB9, //2096
- 0x0A,0x4d,0x4C, //2097
- 0x0d,0x15,0x41, //2098
- 0x2d,0x92,0xB5, //2099
- };
- ///月份數(shù)據(jù)表
- code uchar day_code1[9]={0x0,0x1f,0x3b,0x5a,0x78,0x97,0xb5,0xd4,0xf3};
- code uint day_code2[3]={0x111,0x130,0x14e};
- /*
- 函數(shù)功能:輸入BCD陽(yáng)歷數(shù)據(jù),輸出BCD陰歷數(shù)據(jù)(只允許1901-2099年)
- 調(diào)用函數(shù)示例:Conversion(c_sun,year_sun,month_sun,day_sun)
- 如:計(jì)算2004年10月16日Conversion(0,0x4,0x10,0x16);
- c_sun,year_sun,month_sun,day_sun均為BCD數(shù)據(jù),c_sun為世紀(jì)標(biāo)志位,c_sun=0為21世
- 紀(jì),c_sun=1為19世紀(jì)
- 調(diào)用函數(shù)后,原有數(shù)據(jù)不變,讀c_moon,year_moon,month_moon,day_moon得出陰歷BCD數(shù)據(jù)
- */
- bit c_moon;
- data uchar year_moon,month_moon,day_moon,week;
- /*子函數(shù),用于讀取數(shù)據(jù)表中農(nóng)歷月的大月或小月,如果該月為大返回1,為小返回0*/
- bit get_moon_day(uchar month_p,uint table_addr)
- {
- uchar temp;
- switch (month_p)
- {
- case 1:{temp=year_code[table_addr]&0x08;
- if (temp==0)return(0);else return(1);}
- case 2:{temp=year_code[table_addr]&0x04;
- if (temp==0)return(0);else return(1);}
- case 3:{temp=year_code[table_addr]&0x02;
- if (temp==0)return(0);else return(1);}
- case 4:{temp=year_code[table_addr]&0x01;
- if (temp==0)return(0);else return(1);}
- case 5:{temp=year_code[table_addr+1]&0x80;
- if (temp==0) return(0);else return(1);}
- case 6:{temp=year_code[table_addr+1]&0x40;
- if (temp==0)return(0);else return(1);}
- case 7:{temp=year_code[table_addr+1]&0x20;
- if (temp==0)return(0);else return(1);}
- case 8:{temp=year_code[table_addr+1]&0x10;
- if (temp==0)return(0);else return(1);}
- case 9:{temp=year_code[table_addr+1]&0x08;
- if (temp==0)return(0);else return(1);}
- case 10:{temp=year_code[table_addr+1]&0x04;
- if (temp==0)return(0);else return(1);}
- case 11:{temp=year_code[table_addr+1]&0x02;
- if (temp==0)return(0);else return(1);}
- case 12:{temp=year_code[table_addr+1]&0x01;
- if (temp==0)return(0);else return(1);}
- case 13:{temp=year_code[table_addr+2]&0x80;
- if (temp==0)return(0);else return(1);}
- }
- }
- /*
- 函數(shù)功能:輸入BCD陽(yáng)歷數(shù)據(jù),輸出BCD陰歷數(shù)據(jù)(只允許1901-2099年)
- 調(diào)用函數(shù)示例:Conversion(c_sun,year_sun,month_sun,day_sun)
- 如:計(jì)算2004年10月16日Conversion(0,0x4,0x10,0x16);
- c_sun,year_sun,month_sun,day_sun均為BCD數(shù)據(jù),c_sun為世紀(jì)標(biāo)志位,c_sun=0為21世
- 紀(jì),c_sun=1為19世紀(jì)
- 調(diào)用函數(shù)后,原有數(shù)據(jù)不變,讀c_moon,year_moon,month_moon,day_moon得出陰歷BCD數(shù)據(jù)
- */
- void Conversion(bit c,uchar year,uchar month,uchar day)
- { //c=0 為21世紀(jì),c=1 為19世紀(jì) 輸入輸出數(shù)據(jù)均為BCD數(shù)據(jù)
- uchar temp1,temp2,temp3,month_p;
- uint temp4,table_addr;
- bit flag2,flag_y;
- temp1=year/16; //BCD->hex 先把數(shù)據(jù)轉(zhuǎn)換為十六進(jìn)制
- temp2=year%16;
- year=temp1*10+temp2;
- temp1=month/16;
- temp2=month%16;
- month=temp1*10+temp2;
- temp1=day/16;
- temp2=day%16;
- day=temp1*10+temp2;
- //定位數(shù)據(jù)表地址
- if(c==0)
- {
- table_addr=(year)*0x3;
- }
- //else
- //{
- //table_addr=(year-1)*0x3;
- //}
- //定位數(shù)據(jù)表地址完成
- //取當(dāng)年春節(jié)所在的公歷月份
- temp1=year_code[table_addr+2]&0x60;
- temp1=_cror_(temp1,5);
- //取當(dāng)年春節(jié)所在的公歷月份完成
- //取當(dāng)年春節(jié)所在的公歷日
- temp2=year_code[table_addr+2]&0x1f;
- //取當(dāng)年春節(jié)所在的公歷日完成
- // 計(jì)算當(dāng)年春年離當(dāng)年元旦的天數(shù),春節(jié)只會(huì)在公歷1月或2月
- if(temp1==0x1)
- {
- temp3=temp2-1;
- }
- else
- {
- temp3=temp2+0x1f-1;
- }
- // 計(jì)算當(dāng)年春年離當(dāng)年元旦的天數(shù)完成
- //計(jì)算公歷日離當(dāng)年元旦的天數(shù),為了減少運(yùn)算,用了兩個(gè)表
- //day_code1[9],day_code2[3]
- //如果公歷月在九月或前,天數(shù)會(huì)少于0xff,用表day_code1[9],
- //在九月后,天數(shù)大于0xff,用表day_code2[3]
- //如輸入公歷日為8月10日,則公歷日離元旦天數(shù)為day_code1[8-1]+10-1
- //如輸入公歷日為11月10日,則公歷日離元旦天數(shù)為day_code2[11-10]+10-1
- if (month<10)
- {
- temp4=day_code1[month-1]+day-1;
- }
- else
- {
- temp4=day_code2[month-10]+day-1;
- }
- if ((month>0x2)&&(year%0x4==0))
- { //如果公歷月大于2月并且該年的2月為閏月,天數(shù)加1
- temp4+=1;
- }
- //計(jì)算公歷日離當(dāng)年元旦的天數(shù)完成
- //判斷公歷日在春節(jié)前還是春節(jié)后
- if (temp4>=temp3)
- { //公歷日在春節(jié)后或就是春節(jié)當(dāng)日使用下面代碼進(jìn)行運(yùn)算
- temp4-=temp3;
- month=0x1;
- month_p=0x1; //month_p為月份指向,公歷日在春節(jié)前或就是春節(jié)當(dāng)日month_p指向首月
- flag2=get_moon_day(month_p,table_addr);
- //檢查該農(nóng)歷月為大小還是小月,大月返回1,小月返回0
- flag_y=0;
- if(flag2==0)temp1=0x1d; //小月29天
- else temp1=0x1e; //大小30天
- temp2=year_code[table_addr]&0xf0;
- temp2=_cror_(temp2,4); //從數(shù)據(jù)表中取該年的閏月月份,如為0則該年無(wú)閏月
- while(temp4>=temp1)
- {
- temp4-=temp1;
- month_p+=1;
- if(month==temp2)
- {
- flag_y=~flag_y;
- if(flag_y==0)
- month+=1;
- }
- else month+=1;
- flag2=get_moon_day(month_p,table_addr);
- if(flag2==0)temp1=0x1d;
- else temp1=0x1e;
- }
- day=temp4+1;
- }
- else
- { //公歷日在春節(jié)前使用下面代碼進(jìn)行運(yùn)算
- temp3-=temp4;
- if (year==0x0)
- {
- year=0x63;c=1;
- }
- else year-=1;
- table_addr-=0x3;
- month=0xc;
- temp2=year_code[table_addr]&0xf0;
- temp2=_cror_(temp2,4);
- if (temp2==0)
- month_p=0xc;
- else
- month_p=0xd; //
- /*month_p為月份指向,如果當(dāng)年有閏月,一年有十三個(gè)月,月指向13,無(wú)閏月指向12*/
- flag_y=0;
- flag2=get_moon_day(month_p,table_addr);
- if(flag2==0)temp1=0x1d;
- else temp1=0x1e;
- while(temp3>temp1)
- {
- temp3-=temp1;
- month_p-=1;
- if(flag_y==0)month-=1;
- if(month==temp2)flag_y=~flag_y;
- flag2=get_moon_day(month_p,table_addr);
- if(flag2==0)temp1=0x1d;
- else temp1=0x1e;
- }
- day=temp1-temp3+1;
- }
- c_moon=c; //HEX->BCD ,運(yùn)算結(jié)束后,把數(shù)據(jù)轉(zhuǎn)換為BCD數(shù)據(jù)
- temp1=year/10;
- temp1=_crol_(temp1,4);
- temp2=year%10;
- year_moon=temp1|temp2;
- temp1=month/10;
- temp1=_crol_(temp1,4);
- temp2=month%10;
- month_moon=temp1|temp2;
- temp1=day/10;
- temp1=_crol_(temp1,4);
- temp2=day%10;
- day_moon=temp1|temp2;
- }
- /*函數(shù)功能:輸入BCD陽(yáng)歷數(shù)據(jù),輸出BCD星期數(shù)據(jù)(只允許1901-2099年)
- 調(diào)用函數(shù)示例:Conver_week(c_sun,year_sun,month_sun,day_sun)
- 如:計(jì)算2004年10月16日Conversion(0,0x4,0x10,0x16);
- c_sun,year_sun,month_sun,day_sun均為BCD數(shù)據(jù),c_sun為世紀(jì)標(biāo)志位,c_sun=0為21世
- 紀(jì),c_sun=1為19世紀(jì)
- 調(diào)用函數(shù)后,原有數(shù)據(jù)不變,讀week得出陰歷BCD數(shù)據(jù)
- */
- code uchar table_week[12]={0,3,3,6,1,4,6,2,5,0,3,5}; //月修正數(shù)據(jù)表
- /*
- 算法:日期+年份+所過(guò)閏年數(shù)+月較正數(shù)之和除7 的余數(shù)就是星期但如果是在
- 閏年又不到3 月份上述之和要減一天再除7
- 星期數(shù)為0
- */
- /*void Conver_week(bit c,uchar year,uchar month,uchar day)
- {//c=0 為21世紀(jì),c=1 為19世紀(jì) 輸入輸出數(shù)據(jù)均為BCD數(shù)據(jù)
- uchar temp1,temp2;
- temp1=year/16; //BCD->hex 先把數(shù)據(jù)轉(zhuǎn)換為十六進(jìn)制
- temp2=year%16;
- year=temp1*10+temp2;
- temp1=month/16;
- temp2=month%16;
- month=temp1*10+temp2;
- temp1=day/16;
- temp2=day%16;
- day=temp1*10+temp2;
- if (c==0){year+=0x64;} //如果為21世紀(jì),年份數(shù)加100
- temp1=year/0x4; //所過(guò)閏年數(shù)只算1900年之后的
- temp2=year+temp1;
- temp2=temp2%0x7; //為節(jié)省資源,先進(jìn)行一次取余,避免數(shù)大于0xff,避免使用整型數(shù)據(jù)
- temp2=temp2+day+table_week[month-1];
- if (year%0x4==0&&month<3)temp2-=1;
- week=temp2%0x7;
- }*/
- //test
- uchar c_sun,year_sun,month_sun,day_sun;
- /****************************************************************************************************************************
- 函數(shù)功能: 二十四節(jié)氣數(shù)據(jù)庫(kù)
- 入口參數(shù): unsigned char(yy,mo,dd) 對(duì)應(yīng) 年月日
- 出口參數(shù): unsigned char(0-24) 1-24對(duì)應(yīng)二十四節(jié)氣
- 作者 : TOTOP
- 二十四節(jié)氣數(shù)據(jù)庫(kù)(1901--2050)
- 數(shù)據(jù)格式說(shuō)明:
- 如1901年的節(jié)氣為
- 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月
- [ 6,21][ 4,19][ 6,21][ 5,21][ 6,22][ 6,22][ 8,23][ 8,24][ 8,24][ 8,24][ 8,23][ 8,22]
- [ 9, 6][11, 4][ 9, 6][10, 6][ 9, 7][ 9, 7][ 7, 8][ 7, 9][ 7, 9][ 7, 9][ 7, 8][ 7,15]
- 上面第一行數(shù)據(jù)為每月節(jié)氣對(duì)應(yīng)公歷日期,15減去每月第一個(gè)節(jié)氣,每月第二個(gè)節(jié)氣減去15得第二
- 行,這樣每月兩個(gè)節(jié)氣對(duì)應(yīng)數(shù)據(jù)都小于16,每月用一個(gè)字節(jié)存放,高位存放第一個(gè)節(jié)氣數(shù)據(jù),低位存
- 放第二個(gè)節(jié)氣的數(shù)據(jù),可得下表
- ****************************************************************************************************************************/
- uchar code jieqi_code[]=
- {
- 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2000
- 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2001
- 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //2002
- 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //2003
- 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2004
- 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2005
- 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2006
- 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //2007
- 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //2008
- 0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2009
- 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2010
- 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87, //2011
- 0x96,0xB4,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //2012
- 0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87, //2013
- 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2014
- 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //2015
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //2016
- 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87, //2017
- 0xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2018
- 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87, //2019
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x86, //2020
- 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2021
- 0xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87, //2022
- 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87, //2023
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //2024
- 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2025
- 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2026
- 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //2027
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //2028
- 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2029
- 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2030
- 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //2031
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //2032
- 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x86, //2033
- 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x78,0x88,0x78,0x87,0x87, //2034
- 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2035
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //2036
- 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2037
- 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2038
- 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2039
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //2040
- 0xA5,0xC3,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //2041
- 0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2042
- 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2043
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x88,0x87,0x96, //2044
- 0xA5,0xC3,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //2045
- 0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87, //2046
- 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2047
- 0x95,0xB4,0xA5,0xB4,0xA5,0xA5,0x97,0x87,0x87,0x88,0x86,0x96, //2048
- 0xA4,0xC3,0xA5,0xA5,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x86, //2049
- 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x78,0x78,0x87,0x87, //2050
- };
- uchar jieqi (uchar y2,m2,d2)
- {
- uchar temp,d,y,y1,m;
- uint addr;
- d=d2/16*10+d2%16;
- m=m2/16*10+m2%16;
- y1=y2/16*10+y2%16+2000;
- y=y1-2000;
- addr=y*12+m-1;
- if(d<15)
- {
- temp=15-d;
- if((jieqi_code[addr]>>4)==temp) return (m*2-1);
- else return (0);
- }
- if(d==15) return (0);
- if(d>15)
- {
- temp=d-15;
- if((jieqi_code[addr]&0x0f)==temp) return (m*2);
- else return (0);
- }
- }
- /******************************************************************************/
- //公歷節(jié)日數(shù)據(jù)庫(kù)表
- /******************************************************************************/
- void days () //公歷節(jié)日數(shù)據(jù)庫(kù)
- {
- uchar j;
- j=jieqi(yy,mo,dd);
- if(t/2%2==0)//設(shè)置變化的時(shí)間,默認(rèn)是2秒
- { //以下自己添加生日、節(jié)日信息
- if ( month_moon== 0x06 && day_moon== 0x02 ){dispString(3, 0, 1, "后天是奇奇的生日");}
- else if ( month_moon== 0x06 && day_moon== 0x03 ){dispString(3, 0, 1, "明天是奇奇的生日");}
- else if ( month_moon== 0x06 && day_moon== 0x04 ){dispString(3, 0, 1, "今天是奇奇的生日");}
- else if ( month_moon== 0x10 && day_moon== 0x07 ){dispString(3, 0, 1, "后天是老婆的生日");}
- else if ( month_moon== 0x10 && day_moon== 0x08 ){dispString(3, 0, 1, "明天是老婆的生日");}
- else if ( month_moon== 0x10 && day_moon== 0x09 ){dispString(3, 0, 1, "今天是老婆的生日");}
- else if ( month_moon== 0x08 && day_moon== 0x01 ){dispString(3, 0, 1, "后天是我的生日! ");}
- else if ( month_moon== 0x08 && day_moon== 0x02 ){dispString(3, 0, 1, "明天是我的生日! ");}
- else if ( month_moon== 0x08 && day_moon== 0x03 ){dispString(3, 0, 1, "今天是我的生日! ");}
- else if ( month_moon== 0x03 && day_moon== 0x23 ){dispString(3, 0, 1, "后天是爸爸的生日");}
- else if ( month_moon== 0x03 && day_moon== 0x24 ){dispString(3, 0, 1, "明天是爸爸的生日");}
- else if ( month_moon== 0x03 && day_moon== 0x25 ){dispString(3, 0, 1, "今天是爸爸的生日");}
- else if ( month_moon== 0x01 && day_moon== 0x30 ){dispString(3, 0, 1, "后天是媽媽的生日");}
- else if ( month_moon== 0x02 && day_moon== 0x01 ){dispString(3, 0, 1, "明天是媽媽的生日");}
- else if ( month_moon== 0x02 && day_moon== 0x02 ){dispString(3, 0, 1, "今天是媽媽的生日");}
- //農(nóng)歷節(jié)日
- else if ( month_moon== 0x12 && day_moon== 0x29 ){dispString(3, 0, 1, " 明天大年 ");}
- else if ( month_moon== 0x12 && day_moon== 0x30 ){dispString(3, 0, 1, " 大年三十 ");}
- else if ( month_moon== 0x05 && day_moon== 0x05 ){dispString(3, 0, 1, " 今天是端午節(jié) ");}
- else if ( month_moon== 0x08 && day_moon== 0x15 ){dispString(3, 0, 1, " 今天是中秋節(jié) ");}
- else if ( month_moon== 0x01 && day_moon== 0x15 ){dispString(3, 0, 1, " 今天是元宵節(jié) ");}
- else if ( month_moon== 0x02 && day_moon== 0x02 ){dispString(3, 0, 1, " 今天是龍?zhí)ь^ ");}
- else if ( month_moon== 0x07 && day_moon== 0x07 ){dispString(3, 0, 1, " 今天是七夕! ");}
- else if ( month_moon== 0x07 && day_moon== 0x15 ){dispString(3, 0, 1, " 今天是鬼節(jié)! ");}
- else if ( month_moon== 0x09 && day_moon== 0x09 ){dispString(3, 0, 1, " 今天是重陽(yáng)節(jié) ");}
- else if ( month_moon== 0x12 && day_moon== 0x08 ){dispString(3, 0, 1, " 今天是臘八節(jié) ");}
- //國(guó)立節(jié)日
- else if ( mo == 0x01 && dd == 0x01 ){dispString(3, 0, 1, " 元旦快樂(lè)! ");}//1月
- else if ( mo == 0x01 && dd == 0x28 ){dispString(3, 0, 1, "今天是世界麻風(fēng)日");}
-
- else if ( mo == 0x02 && dd == 0x02 ){dispString(3, 0, 1, "今天是世界濕地日");}//2月
- else if ( mo == 0x02 && dd == 0x13 ){dispString(3, 0, 1, " 明天情人節(jié)了 ");}
- else if ( mo == 0x02 && dd == 0x14 ){dispString(3, 0, 1, " 今天是情人節(jié) ");}
-
- else if ( mo == 0x03 && dd == 0x01 ){dispString(3, 0, 1, "今天是國(guó)際海豹日");}//3月
- else if ( mo == 0x03 && dd == 0x03 ){dispString(3, 0, 1, "今天是全國(guó)愛(ài)耳日");}
- else if ( mo == 0x03 && dd == 0x08 ){dispString(3, 0, 1, "今天是3.8 婦女節(jié)");}
- else if ( mo == 0x03 && dd == 0x12 ){dispString(3, 0, 1, " 今天是植樹(shù)節(jié) ");}
- else if ( mo == 0x03 && dd == 0x14 ){dispString(3, 0, 1, "今天是國(guó)際警察日");}
- else if ( mo == 0x03 && dd == 0x15 ){dispString(3, 0, 1, "今天消費(fèi)者權(quán)益日");}
- else if ( mo == 0x03 && dd == 0x17 ){dispString(3, 0, 1, "今天是國(guó)際航海日");}
- else if ( mo == 0x03 && dd == 0x21 ){dispString(3, 0, 1, "今天是世界森林日");}
- else if ( mo == 0x03 && dd == 0x22 ){dispString(3, 0, 1, "今天是世界水日!");}
- else if ( mo == 0x03 && dd == 0x23 ){dispString(3, 0, 1, "今天是世界氣象日");}
- else if ( mo == 0x03 && dd == 0x24 ){dispString(3, 0, 1, "世界防治結(jié)核病日");}
-
- else if ( mo == 0x04 && dd == 0x01 ){dispString(3, 0, 1, "愚人節(jié),小心上當(dāng)");}//4
- else if ( mo == 0x04 && dd == 0x07 ){dispString(3, 0, 1, "今天是世界衛(wèi)生日");}
- else if ( mo == 0x04 && dd == 0x08 ){dispString(3, 0, 1, " 今天復(fù)活節(jié)! ");}
- else if ( mo == 0x04 && dd == 0x13 ){dispString(3, 0, 1, " 黑色星期五! ");}
-
- else if ( mo == 0x05 && dd == 0x01 ){dispString(3, 0, 1, " 今天是勞動(dòng)節(jié) ");}//5
- else if ( mo == 0x05 && dd == 0x04 ){dispString(3, 0, 1, "今天是五四青年節(jié)");}
- else if ( mo == 0x05 && dd == 0x08 ){dispString(3, 0, 1, "今天世界紅十字日");}
- else if ( mo == 0x05 && dd == 0x12 ){dispString(3, 0, 1, "今天是國(guó)際護(hù)士節(jié)");}
- else if ( mo == 0x05 && dd == 0x05 ){dispString(3, 0, 1, "近日注意母親節(jié)! ");}
- else if ( mo == 0x05 && dd == 0x15 ){dispString(3, 0, 1, "今天是國(guó)際家庭日");}
- else if ( mo == 0x05 && dd == 0x31 ){dispString(3, 0, 1, "今天是世界無(wú)煙日");}
-
- else if ( mo == 0x06 && dd == 0x01 ){dispString(3, 0, 1, "今天是國(guó)際兒童節(jié)");}//6
- else if ( mo == 0x06 && dd == 0x05 ){dispString(3, 0, 1, "今天是世界環(huán)境日");}
- else if ( mo == 0x06 && dd == 0x26 ){dispString(3, 0, 1, "今天是國(guó)際禁毒日");}
- else if ( mo == 0x06 && dd == 0x06 ){dispString(3, 0, 1, "今天是全國(guó)愛(ài)眼日");}
- else if ( mo == 0x06 && dd == 0x13 ){dispString(3, 0, 1, "近日注意父親節(jié)! ");}
- else if ( mo == 0x06 && dd == 0x15 ){dispString(3, 0, 1, "近日注意父親節(jié)! ");}
-
- else if ( mo == 0x07 && dd == 0x01 ){dispString(3, 0, 1, "香港回歸記念日! ");}//7
- else if ( mo == 0x07 && dd == 0x07 ){dispString(3, 0, 1, "抗日戰(zhàn)爭(zhēng)記念日! ");}
- else if ( mo == 0x07 && dd == 0x11 ){dispString(3, 0, 1, "今天是世界人口日");}
- else if ( mo == 0x08 && dd == 0x01 ){dispString(3, 0, 1, "今天是八一建軍節(jié)");}//8
- else if ( mo == 0x08 && dd == 0x08 ){dispString(3, 0, 1, "今天是中國(guó)男子節(jié)");}
- else if ( mo == 0x08 && dd == 0x15 ){dispString(3, 0, 1, "抗戰(zhàn)勝利記念日!");}
- else if ( mo == 0x09 && dd == 0x10 ){dispString(3, 0, 1, " 今天是教師節(jié) ");}//9
- else if ( mo == 0x09 && dd == 0x18 ){dispString(3, 0, 1, "九·一八事變記念");}
- else if ( mo == 0x09 && dd == 0x20 ){dispString(3, 0, 1, "今天是國(guó)際愛(ài)牙日");}
- else if ( mo == 0x09 && dd == 0x27 ){dispString(3, 0, 1, "今天是世界旅游日");}
- else if ( mo == 0x10 && dd == 0x01 ){dispString(3, 0, 1, " 今天是國(guó)慶節(jié) ");}//10
- else if ( mo == 0x10 && dd == 0x04 ){dispString(3, 0, 1, "今天是世界動(dòng)物日");}
- else if ( mo == 0x10 && dd == 0x24 ){dispString(3, 0, 1, "今天是聯(lián)合國(guó)日! ");}
- else if ( mo == 0x10 && dd == 0x12 ){dispString(3, 0, 1, "明天國(guó)際教師節(jié)! ");}
- else if ( mo == 0x10 && dd == 0x13 ){dispString(3, 0, 1, "今天是國(guó)際教師節(jié)");}
- else if ( mo == 0x11 && dd == 0x10 ){dispString(3, 0, 1, "今天是世界青年節(jié)");}//11
- else if ( mo == 0x11 && dd == 0x17 ){dispString(3, 0, 1, "今天是世界學(xué)生節(jié)");}
- else if ( mo == 0x12 && dd == 0x01 ){dispString(3, 0, 1, "今天世界艾滋病日");}//12
- else if ( mo == 0x12 && dd == 0x23 ){dispString(3, 0, 1, " 明晚平安夜! ");}
- else if ( mo == 0x12 && dd == 0x24 ){dispString(3, 0, 1, " 今晚平安夜! ");}
- else if ( mo == 0x12 && dd == 0x25 ){dispString(3, 0, 1, " 圣誕快樂(lè) ");}
- else if ( mo == 0x12 && dd == 0x31 ){dispString(3, 0, 1, " 明日元旦 ");}
- }
- else{
- //二十四節(jié)氣
- if (j==1){dispString(3, 0, 1, " 今天小寒 ");}
- else if (j==2){dispString(3, 0, 1, " 今天大寒 ");}
- else if (j==3){dispString(3, 0, 1, " 今天立春 ");}
- else if (j==4){dispString(3, 0, 1, " 今天雨水 ");}
- else if (j==5){dispString(3, 0, 1, " 今天驚蟄 ");}
- else if (j==6){dispString(3, 0, 1, " 今天春分 ");}
- else if (j==7){dispString(3, 0, 1, " 今天清明 ");}
- else if (j==8){dispString(3, 0, 1, " 今天谷雨 ");}
- else if (j==9){dispString(3, 0, 1, " 今天立夏 ");}
- else if (j==10){dispString(3, 0, 1, " 今天小滿(mǎn) ");}
- else if (j==11){dispString(3, 0, 1, " 今天芒種 ");}
- else if (j==12){dispString(3, 0, 1, " 今天夏至 ");}
- else if (j==13){dispString(3, 0, 1, " 今天小暑 ");}
- else if (j==14){dispString(3, 0, 1, " 今天大暑 ");}
- else if (j==15){dispString(3, 0, 1, " 今天立秋 ");}
- else if (j==16){dispString(3, 0, 1, " 今天處暑 ");}
- else if (j==17){dispString(3, 0, 1, " 今天白露 ");}
- else if (j==18){dispString(3, 0, 1, " 今天秋分 ");}
- else if (j==19){dispString(3, 0, 1, " 今天寒露 ");}
- else if (j==20){dispString(3, 0, 1, " 今天霜降 ");}
- else if (j==21){dispString(3, 0, 1, " 今天立冬 ");}
- else if (j==22){dispString(3, 0, 1, " 今天小雪 ");}
- else if (j==23){dispString(3, 0, 1, " 今天大雪 ");}
- else if (j==24){dispString(3, 0, 1, " 今天冬至 ");}
- //非節(jié)日時(shí)顯示時(shí)晨信息
- else { if ( hh >= 0x04 && hh < 0x06 ){dispString(3, 0, 1, " 凌晨 點(diǎn) 分 ");
- lcdWriteCommand(0x9b);
- if(hh1/10 != 0){lcdWriteData((hh1/10)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(hh1%10+0x30);
- lcdWriteCommand(0x9d); //":"
- if(mm/16 != 0){lcdWriteData((mm/16)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(mm%16+0x30); }
- if ( hh >= 0x06 && hh < 0x08 ){dispString(3, 0, 1, " 早晨 點(diǎn) 分 ");
- lcdWriteCommand(0x9b);
- if(hh1/10 != 0){lcdWriteData((hh1/10)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(hh1%10+0x30);
- lcdWriteCommand(0x9d); //":"
- if(mm/16 != 0){lcdWriteData((mm/16)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(mm%16+0x30); }
- if ( hh >= 0x08 && hh < 0x12 ){dispString(3, 0, 1, " 上午 點(diǎn) 分 ");
- lcdWriteCommand(0x9b);
- if(hh1/10 != 0){lcdWriteData((hh1/10)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(hh1%10+0x30);
- lcdWriteCommand(0x9d); //":"
- if(mm/16 != 0){lcdWriteData((mm/16)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(mm%16+0x30); }
- if ( hh == 0x12) {dispString(3, 0, 1, " 中午 點(diǎn) 分 ");
- lcdWriteCommand(0x9b);
- if(hh1/10 != 0){lcdWriteData((hh1/10)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(hh1%10+0x30);
- lcdWriteCommand(0x9d); //":"
- if(mm/16 != 0){lcdWriteData((mm/16)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(mm%16+0x30); }
- if ( hh >= 0x13 && hh < 0x18 ){dispString(3, 0, 1, " 下午 點(diǎn) 分 ");
- lcdWriteCommand(0x9b);
- if(hh1/10 != 0){lcdWriteData((hh1/10)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(hh1%10+0x30);
- lcdWriteCommand(0x9d); //":"
- if(mm/16 != 0){lcdWriteData((mm/16)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(mm%16+0x30); }
- if ( hh >= 0x18 && hh < 0x22 ){dispString(3, 0, 1, " 晚上 點(diǎn) 分 ");
- lcdWriteCommand(0x9b);
- if(hh1/10 != 0){lcdWriteData((hh1/10)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(hh1%10+0x30);
- lcdWriteCommand(0x9d); //":"
- if(mm/16 != 0){lcdWriteData((mm/16)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(mm%16+0x30); }
- if ( hh >= 0x22 && hh <= 0x23 ){dispString(3, 0, 1, " 夜里 點(diǎn) 分 ");
- lcdWriteCommand(0x9b);
- if(hh1/10 != 0){lcdWriteData((hh1/10)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(hh1%10+0x30);
- lcdWriteCommand(0x9d); //":"
- if(mm/16 != 0){lcdWriteData((mm/16)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(mm%16+0x30); }
- if ( hh >= 0x00 && hh < 0x04 ){dispString(3, 0, 1, " 深夜 點(diǎn) 分 ");
- lcdWriteCommand(0x9b);
- if(hh1/10 != 0){lcdWriteData((hh1/10)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(hh1%10+0x30);
- lcdWriteCommand(0x9d); //":"
- if(mm/16 != 0){lcdWriteData((mm/16)+0x30);} //十位消隱
- else{lcdWriteData(0x20);}//同上
- lcdWriteData(mm%16+0x30); }
- }
- }
- }
- /******************************ds1820程序***************************************/
- void delay_18B20(unsigned int i)//延時(shí)1微秒
- {
- while(i--);
- }
- void ds1820rst()//ds1820復(fù)位*
- { unsigned char x=0;
- DQ = 1; //DQ復(fù)位
- delay_18B20(4); //延時(shí)
- DQ = 0; //DQ拉低
- delay_18B20(100); //精確延時(shí)大于480us
- DQ = 1; //拉高
- delay_18B20(40);
- }
- unsigned char ds1820rd()//讀數(shù)據(jù)
- { unsigned char i=0;
- unsigned char dat = 0;
- for (i=8;i>0;i--)
- { DQ = 0; //給脈沖信號(hào)
- dat>>=1;
- DQ = 1; //給脈沖信號(hào)
- if(DQ)
- dat|=0x80;
- delay_18B20(10);
- }
- return(dat);
- }
- void ds1820wr(uchar wdata)//寫(xiě)數(shù)據(jù)
- {unsigned char i=0;
- for (i=8; i>0; i--)
- { DQ = 0;
- DQ = wdata&0x01;
- delay_18B20(10);
- DQ = 1;
- wdata>>=1;
- }
- }
- read_temp()//讀取溫度值并轉(zhuǎn)換
- {uchar a,b;
- ds1820rst();
- ds1820wr(0xcc);//跳過(guò)讀序列號(hào)
- ds1820wr(0x44);//啟動(dòng)溫度轉(zhuǎn)換
- ds1820rst();
- ds1820wr(0xcc);//跳過(guò)讀序列號(hào)
- ds1820wr(0xbe);//讀取溫度
- a=ds1820rd();
- b=ds1820rd();
- tvalue=b;
- tvalue<<=8;
- tvalue=tvalue|a;
- if(tvalue<0x0fff)
- tflag=0;
- else
- {tvalue=~tvalue+1;
- tflag=1;
- }
- tvalue=tvalue*(0.625);//溫度值擴(kuò)大10倍,精確到1位小數(shù)
- return(tvalue);
- }
- /*****************************************************************************/
- //聲明(當(dāng)各函數(shù)的排列適當(dāng)時(shí)可不用聲明)
- void lcm_w_ss(void);void lcm_w_mm(void);
- void lcm_w_hh(void);void lcm_w_dd(void);
- void lcm_w_mo(void);void lcm_w_yy(void);
- void lcm_w_xq(void);
- unsigned char clock_in(void);
- void clock_out(unsigned char dd);
- void Init_1302(void);
- unsigned char read_clock(unsigned char ord);
- void read_clockS(void);
- void Set_time(unsigned char sel);
- void write_clock(unsigned char ord, unsigned char dd);
- void updata (void);
- void lcmnongli();
- void lcmjieqi();
- void lcmshengxiao();
- /*****************************************************************************/
- //農(nóng)歷顯示
- /******************************************************************************/
- void lcmnongli()
- {
- uchar yue,ri;
- year_sun=yy;
- month_sun=mo;
- day_sun=dd;
- Conversion(c_sun,year_sun,month_sun,day_sun);
- yue=(month_moon/16)*10+month_moon%16;
- year1=yue;
- ri=(day_moon/16)*10+day_moon%16; //顯示農(nóng)歷月
- if(yue==1){dispString(1, 0, 1, "正"); }
- if(yue==2){dispString(1, 0, 1, "二"); }
- if(yue==3){dispString(1, 0, 1, "三"); }
- if(yue==4){dispString(1, 0, 1, "四"); }
- if(yue==5){dispString(1, 0, 1, "五"); }
- if(yue==6){dispString(1, 0, 1, "六"); }
- if(yue==7){dispString(1, 0, 1, "七"); }
- if(yue==8){dispString(1, 0, 1, "八"); }
- if(yue==9){dispString(1, 0, 1, "九"); }
- if(yue==10){dispString(1, 0, 1, "十"); }
- if(yue==11){dispString(1, 0, 1, "冬"); }
- if(yue==12){dispString(1, 0, 1, "臘"); }
- dispString(1, 1, 1, "月");
- if(ri<=10)
- {
- if(ri==1){ dispString(1, 2, 1, "初一"); }
- if(ri==2){ dispString(1, 2, 1, "初二"); }
- if(ri==3){ dispString(1, 2, 1, "初三"); }
- if(ri==4){ dispString(1, 2, 1, "初四");}
- if(ri==5){ dispString(1, 2, 1, "初五"); }
- if(ri==6){ dispString(1, 2, 1, "初六"); }
- if(ri==7){ dispString(1, 2, 1, "初七"); }
- if(ri==8){ dispString(1, 2, 1, "初八"); }
- if(ri==9){ dispString(1, 2, 1, "初九"); }
- if(ri==10){ dispString(1, 2, 1, "初十"); }
- }
- else
- {
- if(ri==11){ dispString(1, 2, 1, "十一");}
- if(ri==12){ dispString(1, 2, 1, "十二");}
- if(ri==13){ dispString(1, 2, 1, "十三"); }
- if(ri==14){ dispString(1, 2, 1, "十四"); }
- if(ri==15){ dispString(1, 2, 1, "十五"); }
- if(ri==16){ dispString(1, 2, 1, "十六"); }
- if(ri==17){ dispString(1, 2, 1, "十七"); }
- if(ri==18){ dispString(1, 2, 1, "十八"); }
- if(ri==19){ dispString(1, 2, 1, "十九"); }
- if(ri==20){ dispString(1, 2, 1, "二十");}
- if(ri==21){ dispString(1, 2, 1, "廿一"); }
- if(ri==22){ dispString(1, 2, 1, "廿二");}
- if(ri==23){ dispString(1, 2, 1, "廿三"); }
- if(ri==24){ dispString(1, 2, 1, "廿四"); }
- if(ri==25){ dispString(1, 2, 1, "廿五"); }
- if(ri==26){ dispString(1, 2, 1, "廿六");}
- if(ri==27){ dispString(1, 2, 1, "廿七"); }
- if(ri==28){ dispString(1, 2, 1, "廿八"); }
- if(ri==29){ dispString(1, 2, 1, "廿九");}
- if(ri==30){ dispString(1, 2, 1, "三十"); }
- }
- }
- /******************************************************************************/
- //十二生肖顯示
- /******************************************************************************/
- void lcmshengxiao()
- {
- uint y3;
- y3=(yy/16*10+yy%16+2000-1900)%12;
- if(year<6 & year1>6) y3--;
- switch(y3)
- {
- case 0: dispString(0, 6, 1, "子鼠");
- break;
- case 1: dispString(0, 6, 1, "丑牛");
- break;
- case 2: dispString(0, 6, 1, "寅虎");
- break;
- case 3: dispString(0, 6, 1, "卯兔");
- break;
- case 4: dispString(0, 6, 1, "辰龍");
- break;
- case 5: dispString(0, 6, 1, "巳蛇");
- break;
- case 6: dispString(0, 6, 1, "午馬");
- break;
- case 7: dispString(0, 6, 1, "未羊");
- break;
- case 8: dispString(0, 6, 1, "申猴");
- break;
- case 9: dispString(0, 6, 1, "酉雞");
- break;
- case 10: dispString(0, 6, 1, "戌狗");
- break;
- case 11: dispString(0, 6, 1, "亥豬");
- break;
- }
- }
- /*****************************************************************************/
- //調(diào)時(shí)用加1程序
- void Set_time(unsigned char sel)//根據(jù)選擇調(diào)整的相應(yīng)項(xiàng)目加1并寫(xiě)入DS1302
- {
- signed char address,item;
- signed char max,mini;
- dispString(3, 2, 1, "設(shè)置");
- if(sel==6) {dispString(3, 4, 1, "秒鐘");address=0x80; max=59;mini=0;} //秒7
- if(sel==5) {dispString(3, 4, 1, "分鐘");address=0x82; max=59;mini=0;} //分鐘6
- if(sel==4) {dispString(3, 4, 1, "小時(shí)");address=0x84; max=23;mini=0;} //小時(shí)5
- if(sel==3) {dispString(3, 4, 1, "星期");address=0x8a; max=7;mini=1;} //星期4
- if(sel==2) {dispString(3, 4, 1, "日期");address=0x86; max=31;mini=1;} //日3
- if(sel==1) {dispString(3, 4, 1, "月份");address=0x88; max=12;mini=1;} //月2
- if(sel==0) {dispString(3, 4, 1, "年份");address=0x8c; max=99; mini=0;} //年1
- switch(sel)
- {
- case 0: convertChar(0, 1, 2);
- break;
- case 1: convertChar(0, 2, 3);
- break;
- case 2: convertChar(0, 4, 2);
- break;
- case 3: convertChar(1, 7, 2);
- break;
- case 4: convertChar(2, 0, 2);
- break;
- case 5: convertChar(2, 1, 3);
- break;
- case 6: convertChar(2, 3, 2);
- break;
- }
- //讀取1302某地址上的數(shù)值轉(zhuǎn)換成10進(jìn)制賦給item
- item=((read_clock(address+1))/16)*10 + (read_clock(address+1))%16;
- if(KEY_2 == 0)
- {
- item++;//數(shù)加 1
- }
- if(KEY_4 == 0)
- {
- item--;//數(shù)減 1
- }
- if(item>max) item=mini;//查看數(shù)值有效范圍
- if(item<mini) item=max;
- write_clock(0x8e,0x00);//允許寫(xiě)操作
- write_clock(address,(item/10)*16+item%10);//轉(zhuǎn)換成16進(jìn)制寫(xiě)入1302
- write_clock(0x8e,0x80);//寫(xiě)保護(hù),禁止寫(xiě)操作
-
- }
- /*****************************************************************************/
- //設(shè)置1302的初始時(shí)間(自動(dòng)初始化)
- void Init_1302(void){//-設(shè)置1302的初始時(shí)間(2007年1月1日00時(shí)00分00秒星期一)
- unsigned char f;
- if(read_clock(0xc1) != 0xaa){
- write_clock(0x8e,0x00);//允許寫(xiě)操作
- write_clock(0x8c,0x07);//年
- write_clock(0x8a,0x01);//星期
- write_clock(0x88,0x01);//月
- write_clock(0x86,0x01);//日
- write_clock(0x84,0x00);//小時(shí)
- write_clock(0x82,0x00);//分鐘
- write_clock(0x80,0x00);//秒
- write_clock(0x90,0xa5);//充電
- write_clock(0xc0,0xaa);//寫(xiě)入初始化標(biāo)志RAM(第00個(gè)RAM位置)
- for(f=0;f<60;f=f+2){//清除鬧鐘RAM位為0
- write_clock(0xc2+f,0x00);
- }
- write_clock(0x8e,0x80);//禁止寫(xiě)操作
- }
- }
- /*****************************************************************************/
- //DS1302寫(xiě)數(shù)據(jù)(底層協(xié)議)
- void write_clock(unsigned char ord, unsigned char dd){
- clock_clk=0;
- clock_Rst=0;
- clock_Rst=1;
- clock_out(ord);
- clock_out(dd);
- clock_Rst=0;
- clock_clk=1;
- }
- /*****************************************************************************/
- //1302驅(qū)動(dòng)程序(底層協(xié)議)
- void clock_out(unsigned char dd){
- ACC=dd;
- clock_dat=a0; clock_clk=1; clock_clk=0;
- clock_dat=a1; clock_clk=1; clock_clk=0;
- clock_dat=a2; clock_clk=1; clock_clk=0;
- clock_dat=a3; clock_clk=1; clock_clk=0;
- clock_dat=a4; clock_clk=1; clock_clk=0;
- clock_dat=a5; clock_clk=1; clock_clk=0;
- clock_dat=a6; clock_clk=1; clock_clk=0;
- clock_dat=a7; clock_clk=1; clock_clk=0;
- }
- /*****************************************************************************/
- //DS1302寫(xiě)入字節(jié)(底層協(xié)議)
- unsigned char clock_in(void){
- clock_dat=1;
- a0=clock_dat;
- clock_clk=1; clock_clk=0; a1=clock_dat;
- clock_clk=1; clock_clk=0; a2=clock_dat;
- clock_clk=1; clock_clk=0; a3=clock_dat;
- clock_clk=1; clock_clk=0; a4=clock_dat;
- clock_clk=1; clock_clk=0; a5=clock_dat;
- clock_clk=1; clock_clk=0; a6=clock_dat;
- clock_clk=1; clock_clk=0; a7=clock_dat;
- return(ACC);
- }
- /*****************************************************************************/
- //DS1302讀數(shù)據(jù)(底層協(xié)議)
- unsigned char read_clock(unsigned char ord){
- unsigned char dd=0;
- clock_clk=0;
- clock_Rst=0;
- clock_Rst=1;
- clock_out(ord);
- dd=clock_in();
- clock_Rst=0;
- clock_clk=1;
- return(dd);
- }
- /*****************************************************************************/
- /*****************************************************************************/
- //揚(yáng)聲器驅(qū)動(dòng)程序(鬧鐘音樂(lè))
- /*****************************************************************************/
- void Beep(void)
- {//BELL-揚(yáng)聲器--整點(diǎn)報(bào)時(shí)
- unsigned char a;//定義變量用于發(fā)聲的長(zhǎng)度設(shè)置
- for(a=60;a>0;a--){//第一個(gè)聲音的長(zhǎng)度
- beep = ~beep;//取反揚(yáng)聲器驅(qū)動(dòng)口,以產(chǎn)生音頻
- Delay(100);//音調(diào)設(shè)置延時(shí)
- }
- for(a=100;a>0;a--){//同上
- beep = ~beep;
- Delay(80);//
- }
- for(a=100;a>0;a--){//同上
- beep = ~beep;
- Delay(30);//
- }
- beep = 1;//音樂(lè)結(jié)束后揚(yáng)聲器拉高關(guān)閉
- }
- /*****************************************************************************/
- void Beep_set(void){//BELL -揚(yáng)聲器--確定設(shè)置
- unsigned char a;//定義變量用于發(fā)聲的長(zhǎng)度設(shè)置
- for(a=50;a>0;a--){//第一個(gè)聲音的長(zhǎng)度
- beep = ~beep;//取反揚(yáng)聲器驅(qū)動(dòng)口,以產(chǎn)生音頻
- Delay(100);//音調(diào)設(shè)置延時(shí)
- }
- for(a=100;a>0;a--){//同上
- beep = ~beep;
- Delay(50);//
- }
- for(a=50;a>0;a--){//同上
- beep = ~beep;
- Delay(100);//
- }
- beep = 1;//音樂(lè)結(jié)束后揚(yáng)聲器拉高關(guān)閉
- }
- /*****************************************************************************/
- void Beep_key(void){//-揚(yáng)聲器--按鍵音
- unsigned char a;//定義變量用于發(fā)聲的長(zhǎng)度設(shè)置
- for(a=100;a>0;a--){//聲音的長(zhǎng)度
- beep = ~beep;
- Delay(50);//音調(diào)設(shè)置延時(shí)
- }
- beep = 1;//音樂(lè)結(jié)束后揚(yáng)聲器拉高關(guān)閉
- }
- /*****************************************************************************/
- /*****************************************************************************/
- //電子鐘應(yīng)用層程序設(shè)計(jì)
- /*****************************************************************************/
- //向LCM中填寫(xiě) 年 數(shù)據(jù)
- void lcm_w_yy(void){
- //if(read_clock(0x8d) != yy){
- yy = read_clock(0x8d);
- dispString(0, 0, 1, "20");
- lcdWriteCommand(0x81);
- lcdWriteData((yy/16)+0x30);
- lcdWriteData(yy%16+0x30);
- } //}
- /*****************************************************************************/
- //向LCM中填寫(xiě) 月 數(shù)據(jù)
- void lcm_w_mo(void){
- //if(read_clock(0x89) != mo){
- mo = read_clock(0x89);
- lcdWriteCommand(0x82);
- lcdWriteData(0x2d);
- lcdWriteData((mo/16)+0x30); //十位消隱
- lcdWriteData(mo%16+0x30);
- lcdWriteData(0x2d);
- year=(mo/16*10)+mo%16;
- } //}
- /*****************************************************************************/
- //星期處理并送入LCM的指定區(qū)域
- void lcm_w_xq(void){
- //if(read_clock(0x8b) != xq){
- xq = read_clock(0x8b);
- selx = (read_clock(0x8b))%16; //字節(jié)低4位的BCD碼放入selx
- if(selx==7) {dispString(1, 7, 1, "日");} //
- if(selx==6) {dispString(1, 7, 1, "六");} //
- if(selx==5) {dispString(1, 7, 1, "五");} //
- if(selx==4) {dispString(1, 7, 1, "四");} //
- if(selx==3) {dispString(1, 7, 1, "三");} //
- if(selx==2) {dispString(1, 7, 1, "二");} //
- if(selx==1) {dispString(1, 7, 1, "一");} //星期一
- dispString(1, 5, 1, "星期");
- } //}
- /*****************************************************************************/
- //向LCM中填寫(xiě) 日 數(shù)據(jù)
- void lcm_w_dd(void){
- // if(read_clock(0x87) != dd){
- dd = read_clock(0x87);
- lcdWriteCommand(0x84);
- lcdWriteData((dd/16)+0x30); //十位消隱
- lcdWriteData(dd%16+0x30);
- } //}
- /*****************************************************************************/
- //向LCM中填寫(xiě) 小時(shí) 數(shù)據(jù)
- void lcm_w_hh(void){
- if(read_clock(0x85) != hh){
- hh = read_clock(0x85);
- if (hh > 0x07 && hh < 0x22 && w == 0){
- Beep();//整點(diǎn)報(bào)時(shí)音
- }
- }
- lcdWriteCommand(0x88);
- lcdWriteData((hh/16)+0x30);
- lcdWriteData(hh%16+0x30);
- hh1=hh/16*10+hh%16;
- if(hh1>12) hh1=(hh1-12);
-
- }
- /*****************************************************************************/
- //向LCM中填寫(xiě) 分鐘 數(shù)據(jù)
- void lcm_w_mm(void){
- if(read_clock(0x83) != mm)
- {
- mm = read_clock(0x83);
- }
- lcdWriteCommand(0x89);
- if(t/1%2==0)lcdWriteData(0x3a); //":"
- else{lcdWriteData(0x20);}
- lcdWriteData((mm/16)+0x30);
- lcdWriteData(mm%16+0x30);
- if(t/1%2==0) lcdWriteData(0x3a); //":"
- else{lcdWriteData(0x20);}
- }
- void disp_temper()//溫度值顯示
- {
- uint temper;
- uchar temper_ge,temper_shi,temper_bai;
- temper=read_temp();//讀取溫度
- temper_ge=temper%10+0x30;
- temper_shi=temper%100/10+0x30;
- temper_bai=temper/100+0x30;
- if(tflag==1)
- {
- dispString(2, 4, 1, " -");
- }
- else
- {
- dispString(2, 4, 1, " ");
- }
- if(temper_bai==0x30) temper_bai=0x20;
- lcdWriteCommand(0x8d);
- lcdWriteData(temper_bai);
- lcdWriteData(temper_shi);
- lcdWriteData('.');
- lcdWriteData(temper_ge);
- dispString(2, 7, 1, "℃");
- }
- /*********************************************************************************************************
- 處理顯示函數(shù)(被調(diào)用層)
- *********************************************************************************************************/
- void deal(uchar sfm)
- {
- shi=sfm/16;
- ge=sfm%16;
- }
- /********************************************************************************************************
- 12864顯示時(shí)分秒函數(shù)(被調(diào)用層)
- ********************************************************************************************************/
- void display(uchar add,uchar dat)
- {
- uchar i,j=0;
- for(i=16;i<32;i++)
- {
- lcdWriteCommand(0x80+i);
- lcdWriteCommand(0x90+add);
- lcdWriteData(tab[dat][j++]);
- lcdWriteData(tab[dat][j++]);
- }
- for(i=0;i<16;i++)
- {
- lcdWriteCommand(0x80+i);
- lcdWriteCommand(0x88+add);
- lcdWriteData(tab[dat][j++]);
- lcdWriteData(tab[dat][j++]);
- }
- }
- /*********************************************************************************************************
- 初始化函數(shù)(被調(diào)用層)
- *********************************************************************************************************/
- void init_dz()
- {
- lcdWriteCommand(0x30); //選擇8bit數(shù)據(jù)流,基本指令集
- lcdWriteCommand(0x0c); //開(kāi)顯示(無(wú)游標(biāo)、不反白)
- lcdWriteCommand(0x01); //清除顯示,并且設(shè)定地址指針為00H
- dispString(0, 2, 1, "年 月 日");
- dispString(3, 0, 1, "星期");
- lcdWriteCommand(0x81); //處理年,并顯示
- yy = read_clock(0x8d);
- deal(yy);
- lcdWriteData(shi+0x30);
- lcdWriteData(ge+0x30);
- //處理月,并顯示
- lcdWriteCommand(0x83);
- mo = read_clock(0x89);
- deal(mo);
- lcdWriteData(shi+0x30);
- lcdWriteData(ge+0x30);
- lcdWriteCommand(0x85); //處理日,并顯示
- dd = read_clock(0x87);
- deal(dd);
- lcdWriteData(shi+0x30);
- lcdWriteData(ge+0x30);
- //處理星期,并顯示
- xq = read_clock(0x8b);
- switch(xq)
- {
- case 1: dispString(3, 2, 1, "一");break;
- case 2: dispString(3, 2, 1, "二");break;
- case 3: dispString(3, 2, 1, "三");break;
- case 4: dispString(3, 2, 1, "四");break;
- case 5: dispString(3, 2, 1, "五");break;
- case 6: dispString(3, 2, 1, "六");break;
- case 7: dispString(3, 2, 1, "日");break;
- default:break;
- }
- dispString(3, 7, 1, "℃");
- lcdWriteCommand(0x36); //啟動(dòng)擴(kuò)充指令集,啟動(dòng)繪圖模式
- clear_img(); //清理圖片緩沖區(qū)
- hh = read_clock(0x85); //處理小時(shí),并顯示
- deal(hh);
- display(0,shi);
- display(1,ge);
- display(2,10);
- mm = read_clock(0x83); //處理分鐘,并顯示
- deal(mm);
- display(3,shi);
- display(4,ge);
- display(5,10);
- ss = read_clock(0x81); //處理秒,并顯示
- deal(ss);
- display(6,shi);
- display(7,ge);
- }
- /********************************************************************************************************
- 在12864上顯示時(shí)間
- ********************************************************************************************************/
- void disp_sfm()
- {
- uint temper;
- uchar temper_ge,temper_shi,temper_bai,day_temp,date_temp,month_temp,year_temp;
- lcdWriteCommand(0x36); //啟動(dòng)擴(kuò)充指令集,啟動(dòng)繪圖模式
- ss = read_clock(0x81); //更新數(shù)據(jù)
- if(sec_temp!=ss)//讀取秒,只要有改變液晶顯示也改變
- {
- sec_temp=ss;
- deal(sec_temp);
- if(secl!=shi)
- {
- secl=shi;
- display(6,secl);
- }
- display(7,ge);
- }
- mm = read_clock(0x83); //讀取分,只要有改變液晶顯示也改變
- if(min_temp!=mm)
- {
- min_temp=mm;
- deal(mm);
- display(3,shi);
- display(4,ge);
- }
- hh = read_clock(0x85); //讀取小時(shí),只要有改變液晶顯示也改變
- if(hour_temp!=hh)
- {
- hour_temp=hh;
- deal(hh);
- display(0,shi);
- display(1,ge);
- }
- if(ge/1%2==0)
- {
- display(2,10);
- display(5,10);
- }
- else
- {
- display(2,11);
- display(5,11);
- }
-
- lcdWriteCommand(0x30);
- dd = read_clock(0x87); //讀取日,只要有改變液晶顯示也改變
- if(date_temp!=dd)
- {
- date_temp=dd;
- deal(dd);
- lcdWriteCommand(0x85);
- lcdWriteData(shi+0x30);
- lcdWriteData(ge+0x30);
- }
- mo = read_clock(0x89); //讀取月,只要有改變液晶顯示也改變
- if(month_temp!=mo)
- {
- month_temp=mo;
- lcdWriteCommand(0x83);
- deal(mo);
- lcdWriteData(shi+0x30);
- lcdWriteData(ge+0x30);
- }
- yy = read_clock(0x8d); //讀取年,只要有改變液晶顯示也改變
- if(year_temp!=yy)
- {
- year_temp=yy;
- lcdWriteCommand(0x81);
- deal(yy);
- lcdWriteData(shi+0x30);
- lcdWriteData(ge+0x30);
- }
- xq = read_clock(0x8b); //讀取星期,只要有改變液晶顯示也改變
- if(day_temp!=xq)
- {
- day_temp=xq;
- switch(xq)
- {
- case 1: dispString(3, 2, 1, "一");break;
- case 2: dispString(3, 2, 1, "二");break;
- case 3: dispString(3, 2, 1, "三");break;
- case 4: dispString(3, 2, 1, "四");break;
- case 5: dispString(3, 2, 1, "五");break;
- case 6: dispString(3, 2, 1, "六");break;
- case 7: dispString(3, 2, 1, "日");break;
- default:break;
- }
- }
- temper=read_temp();//讀取溫度
- temper_ge=temper%10+0x30;
- temper_shi=temper%100/10+0x30;
- temper_bai=temper/100+0x30;
- if(tflag==1)
- {
- dispString(3, 4, 1, " -");
- }
- else
- {
- dispString(3, 4, 1, " ");
- }
- if(temper_bai==0x30) temper_bai=0x20;
- lcdWriteCommand(0x9d);
- lcdWriteData(temper_bai);
- lcdWriteData(temper_shi);
- lcdWriteData('.');
- lcdWriteData(temper_ge);
- lcdWriteCommand(0x36);
-
- }
- /*****************************************************************************/
- //刷新數(shù)據(jù)
- void updata (void){
- lcm_w_ss();//刷新 秒
- lcm_w_mm();//刷新 分
- lcm_w_hh();//刷新 小時(shí)
- lcm_w_dd();//刷新 日
- lcm_w_xq();//更新星期值
- lcm_w_mo();//刷新 月
- lcm_w_yy();//刷新 年
- ss = read_clock(0x81); //更新數(shù)據(jù)
- t=ss/16*10+ss%16;
- lcmnongli();
- lcmshengxiao();
- disp_temper();
- if(w == 0)
- {
- days ();//節(jié)日顯示
- }
- if (n==1||n==2||n==3)
- {
- lcdWriteCommand(0x85); //秒值在LCM上的寫(xiě)入位置
- lcdWriteData(0x20);
- lcdWriteData(0x0e);
- }
- else{
- lcdWriteCommand(0x85); //秒值在LCM上的寫(xiě)入位置
- lcdWriteData(0x20);
- lcdWriteData(0x20);
- }
- }
- /*****************************************************************************/
- //向LCM中填寫(xiě) 秒 數(shù)據(jù)
- void lcm_w_ss(void)
- {
- unsigned int i=0;
- unsigned char a=0,b=0,c=0;
- if(read_clock(0x81) != ss){ //判斷是否需要更新
- ss = read_clock(0x81); //更新數(shù)據(jù)
- if(w==1&&e==6)
- {
- if(t/1%2==0)
- {
- lcdWriteCommand(0x8b); //秒值在LCM上的寫(xiě)入位置
- lcdWriteData((ss/16)+0x30); //寫(xiě)十位
- lcdWriteData(ss%16+0x30); //寫(xiě)個(gè)位
- }
- else
- {
- lcdWriteCommand(0x8b); //秒值在LCM上的寫(xiě)入位置
- lcdWriteData(0x20); //寫(xiě)十位
- lcdWriteData(0x20); //寫(xiě)個(gè)位
- }
- }
- else
- {
- lcdWriteCommand(0x8b); //秒值在LCM上的寫(xiě)入位置
- lcdWriteData((ss/16)+0x30); //寫(xiě)十位
- lcdWriteData(ss%16+0x30); //寫(xiě)個(gè)
- }
- }
- }
- //*****************************Music******************************************************/
- //青春舞曲
- unsigned char code Music_wo[]={ 0x17,0x03, 0x16,0x03, 0x11,0x03, 0x15,0x03, 0x17,0x03,
- 0x16,0x03, 0x15,0x03, 0x11,0x03, 0x10,0x02, 0x10,0x03,
- 0x18,0x03, 0x17,0x01, 0x17,0x03, 0x16,0x03, 0x11,0x03,
- 0x15,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x11,0x03,
- 0x10,0x02, 0x10,0x03, 0x10,0x03, 0x10,0x01, 0x10,0x03,
- 0x10,0x03, 0x16,0x03, 0x18,0x03, 0x17,0x02, 0x1A,0x03,
- 0x18,0x03, 0x17,0x02, 0x17,0x03, 0x16,0x03, 0x17,0x01,
- 0x17,0x03, 0x16,0x03, 0x11,0x03, 0x15,0x03, 0x17,0x03,
- 0x16,0x03, 0x15,0x03, 0x11,0x03, 0x10,0x02, 0x10,0x03,
- 0x18,0x03, 0x17,0x01, 0x17,0x03, 0x16,0x03, 0x11,0x03,
- 0x15,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x11,0x03,
- 0x10,0x02, 0x10,0x03, 0x10,0x03, 0x10,0x01, 0x10,0x67,
- 0x15,0x04, 0x15,0x03, 0x15,0x03, 0x15,0x02, 0x15,0x03,
- 0x11,0x03, 0x10,0x67, 0x15,0x04, 0x11,0x03, 0x10,0x03,
- 0x11,0x01, 0x11,0x03, 0x15,0x03, 0x16,0x03, 0x18,0x03,
- 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x11,0x03, 0x10,0x02,
- 0x10,0x02, 0x10,0x01, 0x00,0x00 };
- /***********************************************************************************/
- /*------------------整屏寫(xiě)入數(shù)據(jù):全亮,或者豎條-----------------------------*/
- void lcdfill(unsigned char disdata)
- { unsigned char x,y;
- for(y=0;y<32;y++)
- for(x=0;x<16;x++)
- { lcdWriteCommand(0x36);
- lcdWriteCommand(y+0x80); //行地址
- lcdWriteCommand(x+0x80); //列地址
- lcdWriteCommand(0x30);
- lcdWriteData(disdata);
- lcdWriteData(disdata);
- DelayM(2);
- }
- lcdWriteCommand(0x34);
- lcdWriteCommand(0x36);
- }
- /*------------------顯示橫-----------------------------*/
- void Disp_H_Line()
- { unsigned char x,y;
- unsigned char k=0x00;
- for(y=0;y<32;y++)
- { k=~k;
- for(x=0;x<16;x++)
- { lcdWriteCommand(0x36);
- lcdWriteCommand(y+0x80); //行地址
- lcdWriteCommand(x+0x80); //列地址
- lcdWriteCommand(0x30);
- lcdWriteData(k);
- lcdWriteData(k);
- DelayM(5);
- };
- }
- lcdWriteCommand(0x34);
- lcdWriteCommand(0x36);
- }
- /*------------------顯示邊框-------------------------------*/
- void Frame()
- {unsigned char x,y;
- lcdfill(0x00);
- for(x=0;x<9;x+=8)
- for(y=0;y<32;y++)
- { lcdWriteCommand(0x36);
- lcdWriteCommand(y+0x80); //行地址
- lcdWriteCommand(x+0x80); //列地址
- lcdWriteCommand(0x30);
- lcdWriteData(0x80);
- lcdWriteData(0x00);
-
- lcdWriteCommand(0x36);
- lcdWriteCommand(y+0x80); //行地址
- lcdWriteCommand(x+0x87); //列地址
- lcdWriteCommand(0x30);
- lcdWriteData(0x00);
- lcdWriteData(0x01);
- DelayM(5);
- }
- for(y=0;y<2;y++)
- for(x=0;x<8;x++)
- {lcdWriteCommand(0x36);
- lcdWriteCommand(y*31+0x80); //行地址
- lcdWriteCommand(x+0x80+8*y); //列地址
- lcdWriteCommand(0x30);
- lcdWriteData(0xff);
- lcdWriteData(0xff);
- DelayM(5);
- }
- lcdWriteCommand(0x34);
- lcdWriteCommand(0x36);
- }
- /*****************************************************************************/
- void zijian(void)
- {
- lcdClear();
- dispString(1, 0, 1, " V5.1版本 ");
- dispString(2, 0, 1, " 自檢程序開(kāi)始! ");
- DelayM(2000);
- lcdClear();
- displayPhoto(powerOnPhoto1, OFF);
- DelayM(2000);
- lcdfill(0xff); //顯示全開(kāi)
- DelayM(2000);
-
- Disp_H_Line(); //顯示橫條
- DelayM(2000);
-
-
- lcdfill(0xaa); //顯示豎條
- DelayM(2000);
-
- Frame(); //顯示邊框
- DelayM(2000);
- clear_img();
- lcdClear();
- lcdWriteCommand(0x30); //選擇8bit數(shù)據(jù)流
- lcdWriteCommand(0x0c); //開(kāi)顯示(無(wú)游標(biāo)、不反白)
- lcdWriteCommand(0x01); //清除顯示,并且設(shè)定地址指針為00H
- Beep_set();//確定按鍵音
- dispString(0, 0, 1, " 自檢完成! ");
- dispString(2, 0, 1, " ==景淞電子== ");
- dispString(3, 0, 1, " QQ:379663387 ");
- DelayM(2000);
- lcdInit ();
- }
- /*****************************************************************************/
- void naozhong()
- {
- lcdClear();
- dispString(0, 2, 1, "鬧鐘設(shè)置");
- dispString(2, 0, 1, "鬧鐘");
- if(n==0) {dispString(2, 7, 1, "關(guān)");} //
- if(n==1) {dispString(2, 7, 1, "開(kāi)");} //
- if(n==2) {dispString(2, 7, 1, "開(kāi)");} //
- if(n==3) {dispString(2, 7, 1, "開(kāi)");} //
- lcdWriteCommand(0x8b);
- lcdWriteData((n1/10)+0x30);
- lcdWriteData(n1%10+0x30);
- dispString(2, 4, 1, "點(diǎn)");
- lcdWriteData((n2/10)+0x30);
- lcdWriteData(n2%10+0x30);
- while(1)
- {
- if (KEY_3 == 0) // 設(shè)置時(shí)間
- {
- DelayM(20); //去抖
- if(KEY_3 == 0 )
- {
- Beep_key();//按鍵音
- n++;
- if (n >= 4 ){n = 0;}
- if(n==0) {dispString(2, 7, 1, "關(guān)");} //
- if(n==1) {dispString(2, 7, 1, "開(kāi)");} //
- if(n==2) {dispString(2, 7, 1, "開(kāi)");} //
- if(n==3) {dispString(2, 7, 1, "開(kāi)");} //
- switch(n)
- {
- case 0: convertChar(1, 0, 0);
- break;
- case 1: convertChar(1, 0, 0);
- break;
- case 2: convertChar(2, 3, 2);
- break;
- case 3: convertChar(2, 5, 2);
- break;
- }
- while(KEY_3 == 0);//等待鍵松開(kāi)
- }
- }
- if(KEY_4 == 0||KEY_2 == 0)
- {
- if (KEY_2 == 0&&n==2) //
- {
- DelayM(20); //去抖
- if(KEY_2 == 0 &&n==2)
- {
- Beep_key();//按鍵音
- n1++;
- if (n1 >= 24 ){n1 = 0;}
- while(KEY_2 == 0);//等待鍵松開(kāi)
- }
- }
- if (KEY_2 == 0&&n==3) //
- {
- DelayM(20); //去抖
- if(KEY_2 == 0&&n==3 )
- {
- Beep_key();//按鍵音
- n2++;
- if (n2>= 60 ){n2 = 0;}
- while(KEY_2 == 0);//等待鍵松開(kāi)
- }
- }
- if (KEY_4 == 0&&n==2) //
- {
- DelayM(20); //去抖
- if(KEY_4 == 0 &&n==2)
- {
- Beep_key();//按鍵音
- n1--;
- if (n1<0 ){n1 = 23;}
- while(KEY_4 == 0);//等待鍵松開(kāi)
- }
- }
- if (KEY_4 == 0&&n==3) //
- {
- DelayM(20); //去抖
- if(KEY_4 == 0&&n==3 )
- {
- Beep_key();//按鍵音
- n2--;
- if (n2<0 ){n2 = 59;}
- while(KEY_4 == 0);//等待鍵松開(kāi)
- }
- }
- lcdWriteCommand(0x8b);
- lcdWriteData((n1/10)+0x30);
- lcdWriteData(n1%10+0x30);
- dispString(2, 4, 1, "點(diǎn)");
- lcdWriteData((n2/10)+0x30);
- lcdWriteData(n2%10+0x30);
- }
- if(KEY_1 == 0 )
- {
- Beep_key();//按鍵音
- k=0;
- while(KEY_1 == 0);//等待鍵松開(kāi)
- lcdInit ();
- break;
- }
- }
- }
- /*****************************************************************************/
- void naozhongdao()
- {
- hh1=hh/16*10+hh%16;
- mm1=mm/16*10+mm%16;
- if(n1==hh1 && n2==mm1 && ss==0)
- {
- lcdWriteCommand(0x30); //選擇8bit數(shù)據(jù)流
- lcdWriteCommand(0x0c); //開(kāi)顯示(無(wú)游標(biāo)、不反白)
- lcdWriteCommand(0x01); //清除顯示,并且設(shè)定地址指針為00H
- dispString(0, 1, 1, "鬧鐘時(shí)間到! ");
- lcdWriteCommand(0x89);
- lcdWriteData((n1/10)+0x30);
- lcdWriteData(n1%10+0x30);
- dispString(2, 2, 1, "點(diǎn)");
- lcdWriteData((n2/10)+0x30);
- lcdWriteData(n2%10+0x30);
- dispString(2, 4, 1, "分");
- lcdWriteData(0x02);
- Play(Music_wo,0,3,360);
- lcdInit ();
- }
- }
- /*****************************************************************************/
- void procKey (void)
- {
- uchar key1Times=1 ;
- lcdClear();
- dispString(0, 0, 1, " 功能菜單 ");
- dispString(1, 0, 1, "1:界面 2:設(shè)置");
- dispString(2, 0, 1, "3:鬧鐘 4:音樂(lè)");
- dispString(3, 0, 1, "5:自檢 6:退出");
- convertChar(1, 0, 6);
- while(KEY_3 == 0);//等待鍵松開(kāi)
- while(1)
- {
- if(KEY_4 == 0||KEY_2 == 0)
- {
- if (KEY_4 == 0) //
- {
- DelayM(20); //去抖
- if(KEY_4 == 0 && w == 0)
- {
- Beep_key();//按鍵音
- while(KEY_4 == 0);//等待鍵松開(kāi)
- key1Times--;
- if (key1Times==0 ){key1Times = 6;}
- }
- }
- if (KEY_2 == 0) //
- {
- DelayM(20); //去抖
- if(KEY_2 == 0 && w == 0)
- {
- Beep_key();//按鍵音
- while(KEY_2 == 0);//等待鍵松開(kāi)
- key1Times++;
- if (key1Times==7 ){key1Times = 1;}
- }
- }
- lcdClear();
- dispString(0, 0, 1, " 功能菜單 ");
- dispString(1, 0, 1, "1:界面 2:設(shè)置");
- dispString(2, 0, 1, "3:鬧鐘 4:音樂(lè)");
- dispString(3, 0, 1, "5:自檢 6:退出");
- if (key1Times == 7)
- {
- key1Times = 1;
- }
- switch(key1Times)
- {
- case 1: convertChar(1, 0, 6);
- break;
- case 2: convertChar(1, 5, 6);
- break;
- case 3: convertChar(2, 0, 6);
- break;
- case 4: convertChar(2, 5, 6);
- break;
- case 5: convertChar(3, 0, 6);
- break;
- case 6: convertChar(3, 5, 6);
- break;
- }
- }
- if (KEY_1== 0) //
- {
- DelayM(20);
- if(KEY_1 == 0 )
- {
- Beep_set();//確定按鍵音
- if (key1Times==1 ){if(k==0)k=1;else if(k==1)k=0;lcdInit ();break;}
- if (key1Times==2 ){clear_img();lcdClear();w=1;Set_time(e); k=1;break;}
- if (key1Times==3 ){lcdClear();clear_img();k=2;break;}
- if (key1Times==4 ){clear_img();lcdClear();displayPhoto(powerOnPhoto, OFF);Play(Music_wo,0,3,360);lcdInit ();break;}
- if (key1Times==5 ){zijian(); break;}
- if (key1Times==6 ){lcdInit (); break;}
-
- }
- }
- }
- }
- /*****************************************************************************/
- //---主程序---//
- /*****************************************************************************/
- main()
- {
- KEY_1 = 1;KEY_2 = 1;KEY_3 = 1;KEY_4 = 1;//初始鍵盤(pán)
- yy=0xff;mo=0xff;dd=0xff;xq=0xff;hh=0xff;mm=0xff;ss=0xff; //各數(shù)據(jù)刷新
- Beep_set();//確定按鍵音
- InitialSound();
- beep=1;
- Init_1302();
- lcdWriteCommand(0x30); //選擇8bit數(shù)據(jù)流
- lcdWriteCommand(0x0c); //開(kāi)顯示(無(wú)游標(biāo)、不反白)
- lcdWriteCommand(0x01); //清除顯示,并且設(shè)定地址指針為00H
- lcdClear();
- dispString(0, 0, 1, "┏━━━━━━┓");
- dispString(1, 0, 1, "┃12864 LCD5.2┃");
- dispString(2, 0, 1, "┃多功能萬(wàn)年歷┃");
- dispString(3, 0, 1, "┗━━━━━━┛");
- DelayM(1500); //顯示等留1秒
- lcdInit ();
- c_sun=0;
- /*****************************************************************************/
- while(1)
- {//主循環(huán)
- if(k==1){updata ();}
- if(k==0){disp_sfm();}
- if(k==2){naozhong();}
- if(n==1||n==2||n==3){naozhongdao();}
- //------------------------------------------------------------------
- if (KEY_3 == 0) // 設(shè)置時(shí)間
- {
- DelayM(10); //去抖
- if(KEY_3 == 0 && w == 1) //當(dāng)是調(diào)時(shí)狀態(tài) 本鍵用于調(diào)整下一項(xiàng)
- {
- Beep_key();//按鍵音
- e++;
- if (e >= 7 ){e = 0;}
- Set_time(e);//調(diào)整
- }
- if(KEY_3 == 0 && w == 0) //當(dāng)是調(diào)時(shí)狀態(tài) 本鍵用于調(diào)整下一項(xiàng)
- {
- lcdClear();
- lcdWriteCommand(0x30); //選擇8bit數(shù)據(jù)流
- lcdWriteCommand(0x0c); //開(kāi)顯示(無(wú)游標(biāo)、不反白)
- lcdWriteCommand(0x01); //清除顯示,并且設(shè)定地址指針為00H
- Beep_key();//按鍵音
- procKey ();
- }
- while(KEY_3 == 0);//等待鍵松開(kāi)
- }
- //------------------------------------------------------------------
- if (KEY_1 == 0&& w == 1) // 當(dāng)在調(diào)時(shí)狀態(tài)時(shí)就退出調(diào)時(shí)
- {
- DelayM(20);
- if(KEY_1 == 0 && w == 1)
- {
- Beep_set();//確定按鍵音
- w = 0; //退出調(diào)時(shí)
- e = 0; //“下一項(xiàng)”計(jì)數(shù)器清0
- convertChar(0, 0, 0);
- }
- while(KEY_1 == 0);//等待鍵松開(kāi)
- }
- //------------------------------------------------------------------
- if (KEY_2 == 0 && w == 1) // 加減調(diào)整
- {
- DelayM(5);
- if(KEY_2 == 0 && w == 1)
- {
- Set_time(e);//調(diào)整
- Beep_key();//按鍵音
- }
- while(KEY_2 == 0);//等待鍵松開(kāi)
- }
- //------------------------------------------------------------------
- if (KEY_4 == 0 && w == 1)// 加減調(diào)整
- {
- DelayM(5);
- if(KEY_4 == 0 && w == 1)
- {
- Set_time(e);//調(diào)整
- Beep_key();//按鍵音
- }
- while(KEY_4 == 0);//等待鍵松開(kāi)
- }
- }
- }
復(fù)制代碼
|