万年历仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include <reg51.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define NoUpLine 1
- #define UpLine 0
- #define NoUnderLine 1
- #define UnderLine 0
- #define FALSE 0
- #define TRUE 1
- /*--------------------------------------------------------------------------
- REG51.H
- Header file for generic 80C51 and 80C31 microcontroller.
- Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
- All rights reserved.
- --------------------------------------------------------------------------*/
- #ifndef __REG51_H__
- #define __REG51_H__
- /* BYTE Register */
- sfr P0 = 0x80;
- sfr P1 = 0x90;
- sfr P2 = 0xA0;
- sfr P3 = 0xB0;
- sfr PSW = 0xD0;
- sfr ACC = 0xE0;
- sfr B = 0xF0;
- sfr SP = 0x81;
- sfr DPL = 0x82;
- sfr DPH = 0x83;
- sfr PCON = 0x87;
- sfr TCON = 0x88;
- sfr TMOD = 0x89;
- sfr TL0 = 0x8A;
- sfr TL1 = 0x8B;
- sfr TH0 = 0x8C;
- sfr TH1 = 0x8D;
- sfr IE = 0xA8;
- sfr IP = 0xB8;
- sfr SCON = 0x98;
- sfr SBUF = 0x99;
- /* BIT Register */
- /* PSW */
- sbit CY = 0xD7;
- sbit AC = 0xD6;
- sbit F0 = 0xD5;
- sbit RS1 = 0xD4;
- sbit RS0 = 0xD3;
- sbit OV = 0xD2;
- sbit P = 0xD0;
- /* TCON */
- sbit TF1 = 0x8F;
- sbit TR1 = 0x8E;
- sbit TF0 = 0x8D;
- sbit TR0 = 0x8C;
- sbit IE1 = 0x8B;
- sbit IT1 = 0x8A;
- sbit IE0 = 0x89;
- sbit IT0 = 0x88;
- /* IE */
- sbit EA = 0xAF;
- sbit ES = 0xAC;
- sbit ET1 = 0xAB;
- sbit EX1 = 0xAA;
- sbit ET0 = 0xA9;
- sbit EX0 = 0xA8;
- /* IP */
- sbit PS = 0xBC;
- sbit PT1 = 0xBB;
- sbit PX1 = 0xBA;
- sbit PT0 = 0xB9;
- sbit PX0 = 0xB8;
- /* P3 */
- sbit RD = 0xB7;
- sbit WR = 0xB6;
- sbit T1 = 0xB5;
- sbit T0 = 0xB4;
- sbit INT1 = 0xB3;
- sbit INT0 = 0xB2;
- sbit TXD = 0xB1;
- sbit RXD = 0xB0;
- /* SCON */
- sbit SM0 = 0x9F;
- sbit SM1 = 0x9E;
- sbit SM2 = 0x9D;
- sbit REN = 0x9C;
- sbit TB8 = 0x9B;
- sbit RB8 = 0x9A;
- sbit TI = 0x99;
- sbit RI = 0x98;
- #endif
- /*-----------------------------------------------------------*/
- #define LCD_OFF 0x3E
- #define LCD_ON 0x3F
- #define Add_X 0xB8 //the start address of the page 0 ;(0~7)
- #define Add_Y 0x40 //the start address of the Y counter ; (0~64)
- #define Add_Z 0xC0 //the start address of the DDRAM ; (0~64)
- #define UPLINE 0x01
- #define UNDERLINE 0x80
- /*-----------------------------------------------------------*/
- #define LCD12864_DATA_PORT P0
- sbit LCD12864_EN =P2^4;
- sbit LCD12864_RW =P2^3; //0:write ; 1:read
- sbit LCD12864_RS =P2^2; //0:the command .1:the data
- sbit LCD12864_CS_L =P2^0; //select the left of the lcd when 1
- sbit LCD12864_CS_R =P2^1;
- sbit LCD12864_RST =P2^5;
- /*------------------------------------------------------------*/
- void delayus(unsigned int us){
- while(us--);
- }
- /*--------------------------select the LCD--------------------*/
- void LCDSel(unsigned char sel){
- switch(sel) {
- case 0: LCD12864_CS_L=0;LCD12864_CS_R=0;break;
- case 1: LCD12864_CS_L=1;LCD12864_CS_R=0;break; //left
- case 2: LCD12864_CS_L=0;LCD12864_CS_R=1;break; //right
- default:;
- };
- }
- /*------------------------------------------------------------*/
- void WaitLCD(){
- unsigned char flag;
- LCD12864_DATA_PORT=0xFF;
- LCD12864_RW=1;
- LCD12864_RS=0;
- LCD12864_EN=1;
- LCD12864_EN=1;
- LCD12864_EN=0;
- LCD12864_DATA_PORT=0xFF; //读有效数据
- LCD12864_RW=1;
- LCD12864_RS=0;
- LCD12864_EN=1;
- do{
- flag=LCD12864_DATA_PORT;
- LCD12864_DATA_PORT=0xFF;
- }while(!((flag&0x80)==0x80));
- LCD12864_EN=0;
- }
- /*-------------------------------------------------------------*/
- void WriteDatToLCD12864(unsigned char dat){
- // WaitLCD();
- LCD12864_RS=1; //the data
- LCD12864_RW=0; //write
- LCD12864_DATA_PORT=dat;
- LCD12864_EN=1;
- LCD12864_EN=0;
- }
- /*-------------------------------------------------------------*/
- void WriteCmdToLCD12864(unsigned char cmd){
- // WaitLCD();
- LCD12864_RS=0; //the command
- LCD12864_RW=0; //write
- LCD12864_DATA_PORT=cmd;
- LCD12864_EN=1;
- LCD12864_EN=0;
- }
- /*-------------------------------------------------------------*/
- unsigned char ReadDatFromLCD12864(void){
- unsigned char dat;
- WaitLCD();
- LCD12864_DATA_PORT=0xFF; //读空操作
- LCD12864_RS=1; //the data
- LCD12864_RW=1; //read
- LCD12864_EN=1;
- LCD12864_EN=1;
- LCD12864_EN=0;
- LCD12864_DATA_PORT=0xFF; //读有效数据
- LCD12864_RS=1;
- LCD12864_RW=1;
- LCD12864_EN=1;
- dat=LCD12864_DATA_PORT;
- LCD12864_EN=0;
- return dat;
- }
- /*--------------------------------------------------------------*/
- //from the chip manual
- void LCD12864_init(void){
- LCD12864_RST=0;
- delayus(50);
- LCD12864_RST=1;
- LCDSel(0); //left and right
- WriteCmdToLCD12864(LCD_OFF);
- WriteCmdToLCD12864(LCD_ON);
- }
- /*------------------------------------------------------------*/
- //x:0~7
- void SetX(unsigned char x){
- WriteCmdToLCD12864(Add_X+x);
- }
- /*------------------------------------------------------------*/
- //y:0~127
- void SetY(unsigned char y){
- WriteCmdToLCD12864(Add_Y+y);
- }
- /*------------------------------------------------------------*/
- //z:0~63
- void SetZ(unsigned char z){
- WriteCmdToLCD12864(Add_Z+z);
- }
- /*------------------------------------------------------------*/
- void ClearLCD(){
- int i,j;
- LCDSel(0);
- for(j=0;j<8;j++) {
- WriteCmdToLCD12864(LCD_ON);
- SetX(j);
- WriteCmdToLCD12864(Add_Y); //diffrent from SetY(0),SetY(64);
- SetZ(0);
- for (i=0;i<64;i++) {
- WriteDatToLCD12864(0x00);
- }
- }
- }
- /*------------------------------------------------------------*/
- //左上角第一个点为原点,向下Y为轴,向右为X轴
- //x:0~63~127 y:0~63
- //flag : 0:擦除某个点
- // 1:显示某个点
- unsigned char code Tab[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
- void Dot(char x,char y,bit flag){
- unsigned char dat;
- if(x<64){
- LCDSel(1);
- SetX(y/8); //set the page address
- SetY(x); //set the Y adress
- dat=ReadDatFromLCD12864();
- if(flag)
- dat=dat|(Tab[y%8]);
- else
- dat=dat&(~(Tab[y%8]));
- SetY(x); //set the Y adress
- WriteDatToLCD12864(dat);
- }
- else if(x<128){
- LCDSel(2);
- SetX(y/8);
- SetY(x-64);
- dat=ReadDatFromLCD12864();
- if(flag)
- dat=dat|(Tab[y%8]);
- else
- dat=dat&(~(Tab[y%8]));
- SetY(x-64);
- WriteDatToLCD12864(dat);
- }
- }
-
- /*------------------------------------------------------------*/
- //draw a line between point(x1,y1) and point(x2,y2)
- //flag 0:erase the line 1:draw a line
- void Line(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,bit flag){
- unsigned char i;
- unsigned char temp;
- float k;
- if(x1==x2){
- if(y1>y2){
- temp=x1;x1=x2;x2=temp;
- temp=y1;y1=y2;y2=temp;
- }
- for(i=y1;i<=y2;i++){
- Dot(x1,i,flag);
- }
- }else{
- if(x1>x2){
- temp=x1;x1=x2;x2=temp;
- temp=y1;y1=y2;y2=temp;
- }
- k=(float)(y2-y1)/(float)(x2-x1);
- for(i=0;i<x2-x1;i++){
- Dot(x1+i,(unsigned char)(y1+k*i),flag);
- }
- }
- }
- /*-------------------------------------------------------------*/
- void Rect(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,bit flag){
- Line(x1,y1,x2,y1,flag);
- Line(x2,y1,x2,y2,flag);
- Line(x2,y2,x1,y2,flag);
- Line(x1,y2,x1,y1,flag);
- }
- /*-------------------------------------------------------------*/
- //16*16
- //x行 0~7 y列 0~127
- //flag 0:汉字反白显示
- //upline: 0表示有上划线
- //underline: 0表示有下划线
- void hz_disp(unsigned char x,unsigned char y,unsigned char n,unsigned char code * hz,bit flag,bit upline,bit underline){
- unsigned char i,j;
- for (j=0;j<n;j++){
- //显示上半个汉字
- for(i=0;i<16;i++){
- //点的位置是在左还是右
- if(y+16*j+i<64){
- LCDSel(1);
- WriteCmdToLCD12864(LCD_ON);
- SetX(x);
- SetZ(0);
- SetY(y+16*j+i);
- if(upline){
- if(flag)
- WriteDatToLCD12864(hz[32*j+i]);
- else
- WriteDatToLCD12864(~hz[32*j+i]);
- }
- else{
- if(flag)
- WriteDatToLCD12864(hz[32*j+i]|UPLINE);
- else
- WriteDatToLCD12864(~hz[32*j+i]|UPLINE);
- }
- }
- else if(y+16*j+i<128){
- LCDSel(2);
- WriteCmdToLCD12864(LCD_ON);
- SetX(x);
- SetZ(0);
- SetY(y+16*j+i-64);
- if(upline){
- if(flag)
- WriteDatToLCD12864(hz[32*j+i]);
- else
- WriteDatToLCD12864(~hz[32*j+i]);
- }
- else{
- if(flag)
- WriteDatToLCD12864(hz[32*j+i]|UPLINE);
- else
- WriteDatToLCD12864(~hz[32*j+i]|UPLINE);
- }
- }
- }
- //显示下半个汉字
- for(i=16;i<32;i++){
- //先判断点是在左还是在右
- if(y+16*j+i-16<64){
- if(x+1<8){ //最后一行显示上半个字
- LCDSel(1);
- WriteCmdToLCD12864(LCD_ON);
- SetX(x+1);
- SetZ(0);
- SetY(y+16*j+i-16);
- if(underline){
- if(flag)
- WriteDatToLCD12864(hz[32*j+i]);
- else
- WriteDatToLCD12864(~hz[32*j+i]);
- }
- else{
- if(flag)
- WriteDatToLCD12864(hz[32*j+i]|UNDERLINE);
- else
- WriteDatToLCD12864(~hz[32*j+i]|UNDERLINE);
- }
- }
- }else if(y+16*j+i-16<127){
- if(x+1<8){ //最后一行
- LCDSel(2);
- WriteCmdToLCD12864(LCD_ON);
- SetX(x+1);
- SetZ(0);
- SetY(y+16*j+i-16-64);
- if(underline){
- if(flag)
- WriteDatToLCD12864(hz[32*j+i]);
- else
- WriteDatToLCD12864(~hz[32*j+i]);
- }
- else{
- if(flag)
- WriteDatToLCD12864(hz[32*j+i]|UNDERLINE);
- else
- WriteDatToLCD12864(~hz[32*j+i]|UNDERLINE);
- }
- }
- }
- }
- }
- }
- /*-------------------------------------------------------------*/
- //x:行0~7
- //y:列0~127
- //asc: 指向标准交换码
- //string: 指向要显示的字符串
- //flag: 0 反白显示
- //online: 0 带上划线
- //underline : 0带下划线
- //n: the number of the string
- void en_disp(unsigned char x,unsigned char y,unsigned char n,unsigned char code *asc,unsigned char *string,bit flag,bit online,bit underline){
- unsigned char i,j,loc;
- for (j=0;j<n;j++){
- loc=string[j]-0x20; //确定要显示的字符在asc表中的位置(乘上16)
- //显示上半个字母
- for(i=0;i<8;i++){
- //点的位置是在左还是右
- if(y+8*j+i<64){
- LCDSel(1);
- WriteCmdToLCD12864(LCD_ON);
- SetX(x);
- SetZ(0);
- SetY(y+8*j+i);
- if(online){
- if(flag)
- WriteDatToLCD12864(asc[16*loc+i]);
- else
- WriteDatToLCD12864(~asc[16*loc+i]);
- }
- else{
- if(flag)
- WriteDatToLCD12864(asc[16*loc+i]|UPLINE);
- else
- WriteDatToLCD12864(~asc[16*loc+i]|UPLINE);
- }
- }
- else if(y+8*j+i<128){
- LCDSel(2);
- WriteCmdToLCD12864(LCD_ON);
- SetX(x);
- SetZ(0);
- SetY(y+8*j+i-64);
- if(online){
- if(flag)
- WriteDatToLCD12864(asc[16*loc+i]);
- else
- WriteDatToLCD12864(~asc[16*loc+i]);
- }
- else {
- if(flag)
- WriteDatToLCD12864(asc[16*loc+i]|UPLINE);
- else
- WriteDatToLCD12864(~asc[16*loc+i]|UPLINE);
- }
- }
- }
- //显示下半个字母
- for(i=8;i<16;i++){
- //先判断点是在左还是在右
- if(y+8*j+i-8<64){
- if(x+1<8){ //最后一行
- LCDSel(1);
- WriteCmdToLCD12864(LCD_ON);
- SetX(x+1);
- SetZ(0);
- SetY(y+8*j+i-8);
- if(underline){
- if(flag)
- WriteDatToLCD12864(asc[16*loc+i]);
- else
- WriteDatToLCD12864(~asc[16*loc+i]);
- }
- else{
- if(flag)
- WriteDatToLCD12864(asc[16*loc+i]|UNDERLINE);
- else
- WriteDatToLCD12864(~asc[16*loc+i]|UNDERLINE);
- }
- }
- }
- else if(y+8*j+i-8<128){
- if(x+1<8){ //最后一行
- LCDSel(2);
- WriteCmdToLCD12864(LCD_ON);
- SetX(x+1);
- SetZ(0);
- SetY(y+8*j+i-8-64);
- if(underline){
- if(flag)
- WriteDatToLCD12864(asc[16*loc+i]);
- else
- WriteDatToLCD12864(~asc[16*loc+i]);
- }
- else{
- if(flag)
- WriteDatToLCD12864(asc[16*loc+i]|UNDERLINE);
- else
- WriteDatToLCD12864(~asc[16*loc+i]|UNDERLINE);
- }
- }
- }
- }
- }
- }
- //亦木明 2008.2.23
- //显示一个16X32的字符
- void Show16X32(unsigned char line,unsigned char column, unsigned char code *pt,bit flag){
- unsigned char i,column_temp1,column_temp2,column_temp3;
- column_temp1=column;
- column_temp2=column;
- column_temp3=column;
- LCDSel(1); //选通左屏
- SetY(column); //设置起始列
- SetX(line); //设置行
- for(i=0;i<16;i++){
- if(column>=64){ //如果列>=64,则选通右屏
- LCDSel(2);
- column=column%64; //设置右屏起始列
- SetY(column);
- SetX(line);
- }
- if(flag)
- WriteDatToLCD12864(*pt); //写数据
- else
- WriteDatToLCD12864(~(*pt));
- pt++;
- column++;
- }
- LCDSel(1);
- SetX(line+1);
- column=column_temp1;
- SetY(column);
- for(i=0;i<16;i++){
- if(column>=64){
- LCDSel(2);
- column=column%64;
- SetY(column);
- SetX(line+1);
- }
- if(flag)
- WriteDatToLCD12864(*pt); //写数据
- else
- WriteDatToLCD12864(~(*pt));
- pt++;
- column++;
- }
- LCDSel(1);
- SetX(line+2);
- column=column_temp2;
- SetY(column);
- for(i=0;i<16;i++){
- if(column>=64){
- LCDSel(2);
- column=column%64;
- SetY(column);
- SetX(line+2);
- }
- if(flag)
- WriteDatToLCD12864(*pt); //写数据
- else
- WriteDatToLCD12864(~(*pt));
- pt++;
- column++;
- }
- LCDSel(1);
- SetX(line+3);
- column=column_temp3;
- SetY(column);
- for(i=0;i<16;i++){
- if(column>=64){
- LCDSel(2);
- column=column%64;
- SetY(column);
- SetX(line+3);
- }
- if(flag)
- WriteDatToLCD12864(*pt); //写数据
- else
- WriteDatToLCD12864(~(*pt));
- pt++;
- column++;
- }
- }
- /*-------------------------------------------------------*/
- /*从第一列开始向下取8个点作为一个字节,然后从第二列开始向下取8个点作为第二个
- 字节...依此类推。如果最后不足8个点就补满8位.取模顺序是从低到高,即第一个点作为最
- 低位。如*-------取为00000001 */
- unsigned char code uMod[][32]=
- {
- 0x40,0x20,0x10,0x0C,0xE3,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0x02,0x00,0x00,
- 0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//年
- /*-- 文字: 月 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x00,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,0x00,0x00,
- 0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x01,0x01,0x21,0x41,0x3F,0x00,0x00,0x00,0x00,
- /*-- 文字: 日 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x3F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x00,
- /*-- 文字: 时 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0xFC,0x44,0x44,0xFC,0x20,0x24,0x24,0x24,0x3F,0x24,0xE4,0x24,0x24,0x20,0x00,
- 0x00,0x1F,0x08,0x08,0x1F,0x01,0x01,0x05,0x19,0x41,0x81,0x7F,0x01,0x01,0x01,0x00,
- /*-- 文字: 分 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x80,0x40,0x20,0x98,0x87,0x82,0x80,0x80,0x83,0x84,0x98,0x30,0x60,0xC0,0x40,0x00,
- 0x00,0x80,0x40,0x20,0x10,0x0F,0x00,0x00,0x20,0x40,0x3F,0x00,0x00,0x00,0x00,0x00,
- /*-- 文字: 秒 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x12,0x12,0xD2,0xFE,0x91,0x11,0xC0,0x38,0x10,0x00,0xFF,0x00,0x08,0x10,0x60,0x00,
- 0x04,0x03,0x00,0xFF,0x00,0x83,0x80,0x40,0x40,0x20,0x23,0x10,0x08,0x04,0x03,0x00,
- };
- unsigned char code ucLunar[][32]=
- {
- //"初"
- 0x10,0x10,0x91,0xD6,0x30,0x98,0x00,0x08, 0x08,0xF8,0x08,0x08,0x08,0xFC,0x08,0x00,
- 0x02,0x01,0x00,0xFF,0x01,0x82,0x40,0x20,0x18,0x07,0x40,0x80,0x40,0x3F,0x00,0x00,
- /*-- 文字: 一 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- /*-- 文字: 二 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,0x00,
- 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x10,0x00,
- /*-- 文字: 三 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04,0x00,0x00,
- 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
- /*-- 文字: 四 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0xFE,0x02,0x02,0x02,0xFE,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0xFE,0x00,0x00,
- 0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x22,0x7F,0x00,0x00,
- /*-- 文字: 五 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x02,0x82,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0xC2,0x82,0x02,0x00,0x00,0x00,
- 0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x30,0x20,0x00,
- /*-- 文字: 六 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x10,0x10,0x10,0x10,0x10,0x91,0x12,0x1E,0x94,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
- 0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x00,0x00,0x01,0x02,0x0C,0x78,0x30,0x00,0x00,
- /*-- 文字: 七 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0xFE,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x38,0x00,0x00,
- /*-- 文字: 八 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x00,0x00,0x80,0x7C,0x08,0x00,0x00,0x7E,0x84,0x00,0x00,0x00,0x00,0x00,
- 0x20,0x10,0x08,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x18,0x30,0x10,0x00,
- /*-- 文字: 九 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x10,0x10,0x10,0x10,0x90,0x7F,0x10,0x10,0x10,0xF8,0x10,0x00,0x00,0x00,0x00,
- 0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x78,0x20,0x00,
- /*-- 文字: 十 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- /*-- 文字: 农 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x20,0x18,0x08,0x88,0xE8,0x1F,0x6A,0x88,0x08,0x88,0xC8,0xA8,0x1C,0x08,0x00,
- 0x08,0x04,0x02,0x41,0xFF,0x40,0x20,0x10,0x01,0x02,0x0D,0x18,0x70,0x20,0x20,0x00,
- /*-- 文字: 历 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0xFE,0x02,0x22,0x22,0x22,0x22,0xFA,0x22,0x22,0x22,0xE2,0x02,0x02,0x00,
- 0x40,0x30,0x0F,0x00,0x40,0x20,0x18,0x06,0x01,0x00,0x20,0x60,0x3F,0x00,0x00,0x00,
- /*-- 文字: 星 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,
- 0x00,0x48,0x46,0x41,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x49,0x41,0x40,0x00,
- /*-- 文字: 期 --*/
- /*-- Times New Roman12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x00,0x04,0xFF,0x54,0x54,0x54,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00,
- 0x42,0x22,0x1B,0x02,0x02,0x0A,0x33,0x62,0x18,0x07,0x02,0x22,0x42,0x3F,0x00,0x00,
- //"正" 15
- 0x00,0x02,0x02,0xC2,0x02,0x02,0x02,0xFE,0x82,0x82,0x82,0xC2,0x83,0x02,0x00,0x00,
- 0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x40,0x60,0x40,0x00,
- //"冬", 16
- 0x00,0x00,0x20,0x10,0x08,0x17,0xA4,0x44,0xA4,0x94,0x0C,0x04,0x00,0x00,0x00,0x00,
- 0x04,0x04,0x02,0x02,0x01,0x25,0x24,0x48,0x48,0x80,0x01,0x01,0x02,0x06,0x02,0x00,
- //"腊", 17
- 0x00,0xFE,0x22,0x22,0xFF,0x42,0x48,0x48,0x7F,0x48,0x48,0x7F,0xC8,0x68,0x40,0x00,
- 0x40,0x3F,0x02,0x82,0xFF,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0xFF,0x01,0x00,0x00,
- //"℃", 18
- 0x00,0x06,0x09,0x09,0xE6,0xF0,0x18,0x08,0x08,0x08,0x18,0x30,0x78,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x07,0x0F,0x18,0x30,0x20,0x20,0x20,0x10,0x08,0x00,0x00,0x00,
- //"廿", 19
- 0x20,0x20,0x20,0x20,0xFE,0x20,0x20,0x20,0x20,0x20,0xFE,0x20,0x20,0x30,0x20,0x00,
- 0x00,0x00,0x00,0x00,0xFF,0x40,0x40,0x40,0x40,0x40,0xFF,0x00,0x00,0x00,0x00,0x00
- };
- unsigned char code SX[][32] = // 数据表
- {
- //"猴",
- 0x22,0x14,0x08,0xF4,0x42,0x21,0xF8,0x17,
- 0xD2,0x92,0x92,0x92,0xDF,0x92,0x10,0x00,
- 0x04,0x42,0x81,0x7F,0x00,0x00,0xFF,0x85,
- 0x44,0x24,0x1F,0x24,0x44,0xC6,0x44,0x00,
- //"鸡",
- 0x08,0x28,0x48,0x88,0x68,0x18,0x00,0xFC,
- 0x06,0x15,0x44,0x84,0x7E,0x04,0x00,0x00,
- 0x10,0x08,0x06,0x01,0x02,0x14,0x10,0x13,
- 0x12,0x12,0x1A,0x52,0x82,0x7F,0x02,0x00,
- //"狗",
- 0x00,0x22,0x14,0x08,0xF4,0x03,0x20,0x98,
- 0x8F,0x88,0xC8,0x88,0x08,0xFC,0x08,0x00,
- 0x08,0x44,0x82,0x41,0x3F,0x00,0x00,0x1F,
- 0x08,0x08,0x4F,0x80,0x40,0x3F,0x00,0x00,
- //"猪",
- 0x40,0x22,0x14,0x08,0xF4,0x02,0x25,0xA4,
- 0x64,0x3F,0x34,0x2C,0xA4,0x32,0x20,0x00,
- 0x08,0x04,0x42,0x81,0x7F,0x02,0x01,0xFF,
- 0x49,0x49,0x49,0x49,0xFF,0x01,0x00,0x00,
- //"鼠",
- 0x00,0xBE,0x2A,0xAA,0x29,0x29,0xE0,0x22,
- 0xAA,0x2A,0x2A,0xAA,0x3F,0x02,0x00,0x00,
- 0x40,0x7F,0x20,0x24,0x09,0x40,0x7F,0x20,
- 0x24,0x09,0x00,0x1F,0x60,0x80,0xE0,0x00,
- //"牛",
- 0x00,0x40,0x30,0x0E,0x08,0x08,0x08,0xFF,
- 0x08,0x08,0x08,0x0C,0x08,0x80,0x00,0x00,
- 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,
- 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
- //"虎",
- 0x00,0x00,0xF8,0x48,0x48,0x48,0xF8,0x4F,
- 0x4A,0x2A,0x2B,0x0A,0xA8,0x18,0x00,0x00,
- 0x80,0x40,0x3F,0x80,0x40,0x3C,0x04,0x05,
- 0x05,0x7F,0x85,0x81,0x81,0xE0,0x00,0x00,
- //"兔",
- 0x20,0x10,0xF8,0x14,0x13,0x12,0x12,0xF2,
- 0x1A,0x16,0x12,0x10,0xF8,0x10,0x00,0x00,
- 0x00,0x80,0x83,0x41,0x21,0x19,0x07,0x01,
- 0x3F,0x41,0x45,0x59,0x43,0x40,0x70,0x00,
- //"龙",
- 0x10,0x10,0x10,0x10,0x10,0x90,0x7F,0x10,
- 0xF0,0x12,0x14,0x10,0xD0,0x18,0x10,0x00,
- 0x00,0x80,0x40,0x30,0x0C,0x23,0x20,0x10,
- 0x3F,0x44,0x42,0x41,0x40,0x40,0x78,0x00,
- //"蛇",
- 0x00,0xF0,0x10,0xFF,0x10,0xF0,0x20,0x18,
- 0xC8,0x09,0x0E,0x08,0x88,0x28,0x18,0x00,
- 0x20,0x67,0x22,0x1F,0x12,0x3B,0x00,0x00,
- 0x3F,0x44,0x42,0x41,0x41,0x40,0x70,0x00,
- //"马",
- 0x00,0x00,0x02,0x02,0xFA,0x02,0x02,0x02,
- 0x02,0x02,0xFF,0x02,0x00,0x80,0x00,0x00,
- 0x08,0x08,0x08,0x08,0x09,0x09,0x09,0x09,
- 0x09,0x09,0x4D,0x89,0x41,0x3F,0x01,0x00,
- //"羊",
- 0x00,0x08,0x88,0x88,0x89,0x8A,0x8C,0xF8,
- 0x8C,0x8A,0x89,0xC8,0x8C,0x08,0x00,0x00,
- 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0xFF,
- 0x08,0x08,0x08,0x08,0x08,0x0C,0x08,0x00
- };
- unsigned char code TianGan[][32] = // 数据表
- {
- //"庚",
- 0x00,0x00,0xFC,0x84,0xA4,0xA4,0xA4,0xA5,
- 0xFE,0xA4,0xA4,0xA4,0xF4,0xA6,0x84,0x00,
- 0x40,0x30,0x0F,0x80,0x82,0x42,0x22,0x1A,
- 0x07,0x1A,0x22,0x22,0x47,0xC0,0x40,0x00,
- //"辛",
- 0x40,0x40,0x44,0x44,0x4C,0x74,0x45,0xC6,
- 0x44,0x64,0x5C,0x46,0x44,0x60,0x40,0x00,
- 0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFF,
- 0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,
- //"壬",
- 0x00,0x00,0x04,0x04,0x04,0x04,0x04,0xFC,
- 0x04,0x02,0x02,0x03,0x02,0x80,0x00,0x00,
- 0x01,0x01,0x41,0x41,0x41,0x41,0x41,0x7F,
- 0x41,0x41,0x41,0x61,0x41,0x01,0x01,0x00,
- //"癸",
- 0x00,0x80,0x4A,0x32,0x92,0x8A,0x86,0x80,
- 0x87,0x98,0xA4,0x52,0x88,0x80,0x80,0x00,
- 0x01,0x80,0x84,0x44,0x44,0x24,0x14,0x0F,
- 0x14,0x14,0x24,0x66,0xC4,0x01,0x00,0x00,
- //"甲",
- 0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE,
- 0x22,0x22,0x22,0x22,0xFF,0x02,0x00,0x00,
- 0x00,0x00,0x07,0x02,0x02,0x02,0x02,0xFF,
- 0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x00,
- //"乙",
- 0x00,0x04,0x04,0x04,0x04,0x84,0x44,0x24,
- 0x14,0x0C,0x04,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x38,0x46,0x41,0x40,0x40,0x40,
- 0x40,0x40,0x40,0x40,0x40,0x78,0x00,0x00,
- //"丙",
- 0x04,0x04,0xC4,0x44,0x44,0x44,0x44,0xFC,
- 0x44,0x44,0x44,0x44,0xE4,0x46,0x04,0x00,
- 0x00,0x00,0xFF,0x00,0x10,0x08,0x04,0x03,
- 0x02,0x04,0x58,0x80,0x7F,0x00,0x00,0x00,
- //"丁",
- 0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,
- 0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- //"戊",
- 0x00,0x00,0xF8,0x08,0x08,0x08,0x08,0x08,
- 0x7F,0x88,0x0A,0x0C,0x08,0xC8,0x00,0x00,
- 0x40,0x30,0x0F,0x00,0x00,0x00,0x40,0x40,
- 0x20,0x13,0x1C,0x24,0x43,0x80,0xE0,0x00,
- //"已",
- 0x00,0x02,0xF2,0x42,0x42,0x42,0x42,0x42,
- 0x42,0x42,0x42,0xFF,0x02,0x00,0x00,0x00,
- 0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,
- 0x40,0x40,0x40,0x40,0x40,0x78,0x00,0x00
- };
- unsigned char code DiZhi[][32] = // 数据表
- {
- //"申",
- 0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0xFF,
- 0x88,0x88,0x88,0x88,0xFC,0x08,0x00,0x00,
- 0x00,0x00,0x1F,0x08,0x08,0x08,0x08,0xFF,
- 0x08,0x08,0x08,0x08,0x1F,0x00,0x00,0x00,
- //"酉",
- 0x02,0x02,0xF2,0x12,0x12,0xFE,0x12,0x12,
- 0x12,0xFE,0x12,0x12,0xFA,0x13,0x02,0x00,
- 0x00,0x00,0xFF,0x44,0x4A,0x49,0x48,0x48,
- 0x48,0x4D,0x49,0x41,0xFF,0x00,0x00,0x00,
- //"戌",
- 0x00,0x00,0xF8,0x08,0x08,0x88,0x08,0x08,
- 0x7F,0x88,0x0A,0x0C,0x08,0xC8,0x00,0x00,
- 0x40,0x30,0x0F,0x01,0x01,0x01,0x41,0x40,
- 0x20,0x13,0x1C,0x24,0x43,0x80,0xE0,0x00,
- //"亥",
- 0x08,0x08,0x08,0x08,0x88,0x48,0x29,0x1E,
- 0x88,0x48,0x68,0x08,0x08,0x0C,0x08,0x00,
- 0x00,0x80,0x90,0x51,0x49,0x25,0x23,0x11,
- 0x08,0x0C,0x12,0x23,0x40,0xC0,0x00,0x00,
- //"子",
- 0x80,0x80,0x82,0x82,0x82,0x82,0x82,0xE2,
- 0xA2,0x92,0x8A,0x86,0x80,0xC0,0x80,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- //"丑",
- 0x00,0x00,0x02,0x82,0x82,0x82,0xFE,0x82,
- 0x82,0x82,0x82,0xFF,0x02,0x00,0x00,0x00,
- 0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,
- 0x40,0x40,0x40,0x7F,0x40,0x60,0x40,0x00,
- //"寅",
- 0x10,0x0C,0xA4,0xA4,0xA4,0xA4,0xA5,0xE6,
- 0xA4,0xA4,0xA4,0xB4,0xA4,0x14,0x0C,0x00,
- 0x00,0x80,0x4F,0x4A,0x2A,0x2A,0x0A,0x0F,
- 0x0A,0x2A,0x2A,0x4A,0x4F,0x80,0x00,0x00,
- //"卯",
- 0x00,0x00,0xFC,0x04,0x02,0x03,0xFA,0x00,
- 0x00,0xFC,0x04,0x04,0x04,0xFE,0x04,0x00,
- 0x00,0x40,0x47,0x24,0x22,0x12,0x0F,0x00,
- 0x00,0xFF,0x02,0x04,0x08,0x07,0x00,0x00,
- //"辰",
- 0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,
- 0x92,0x92,0x9A,0x93,0xC2,0x80,0x00,0x00,
- 0x40,0x30,0x0F,0x00,0x00,0xFF,0x40,0x23,
- 0x04,0x08,0x14,0x12,0x20,0x60,0x20,0x00,
- //"巳",
- 0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,
- 0x42,0x42,0x42,0x42,0xFF,0x02,0x00,0x00,
- 0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,
- 0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00,
- //"午",
- 0x00,0x40,0x20,0x18,0x07,0x04,0x04,0xFC,
- 0x04,0x04,0x04,0x06,0x04,0x80,0x00,0x00,
- 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,
- 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
- //"未",
- 0x80,0x88,0x88,0x88,0x88,0x88,0x88,0xFF,
- 0x88,0x88,0x88,0x88,0x8C,0xC8,0x80,0x00,
- 0x00,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,
- 0x01,0x02,0x04,0x08,0x10,0x30,0x10,0x00
- };
- unsigned char code Asc[] = // ASCII
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // - -
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x38,0xFC,0xFC,0x38,0x00,0x00, // -!-
- 0x00,0x00,0x00,0x0D,0x0D,0x00,0x00,0x00,
- 0x00,0x0E,0x1E,0x00,0x00,0x1E,0x0E,0x00, // -"-
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x20,0xF8,0xF8,0x20,0xF8,0xF8,0x20,0x00, // -#-
- 0x02,0x0F,0x0F,0x02,0x0F,0x0F,0x02,0x00,
- 0x38,0x7C,0x44,0x47,0x47,0xCC,0x98,0x00, // -$-
- 0x03,0x06,0x04,0x1C,0x1C,0x07,0x03,0x00,
- 0x30,0x30,0x00,0x80,0xC0,0x60,0x30,0x00, // -%-
- 0x0C,0x06,0x03,0x01,0x00,0x0C,0x0C,0x00,
- 0x80,0xD8,0x7C,0xE4,0xBC,0xD8,0x40,0x00, // -&-
- 0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,
- 0x00,0x10,0x1E,0x0E,0x00,0x00,0x00,0x00, // -'-
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xF0,0xF8,0x0C,0x04,0x00,0x00, // -(-
- 0x00,0x00,0x03,0x07,0x0C,0x08,0x00,0x00,
- 0x00,0x00,0x04,0x0C,0xF8,0xF0,0x00,0x00, // -)-
- 0x00,0x00,0x08,0x0C,0x07,0x03,0x00,0x00,
- 0x80,0xA0,0xE0,0xC0,0xC0,0xE0,0xA0,0x80, // -*-
- 0x00,0x02,0x03,0x01,0x01,0x03,0x02,0x00,
- 0x00,0x80,0x80,0xE0,0xE0,0x80,0x80,0x00, // -+-
- 0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -,-
- 0x00,0x00,0x10,0x1E,0x0E,0x00,0x00,0x00,
- 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00, // ---
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -.-
- 0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x80,0xC0,0x60,0x30,0x00, // -/-
- 0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,
- 0xF8,0xFC,0x04,0xC4,0x24,0xFC,0xF8,0x00, // -0-
- 0x07,0x0F,0x09,0x08,0x08,0x0F,0x07,0x00,
- 0x00,0x10,0x18,0xFC,0xFC,0x00,0x00,0x00, // -1-
- 0x00,0x08,0x08,0x0F,0x0F,0x08,0x08,0x00,
- 0x08,0x0C,0x84,0xC4,0x64,0x3C,0x18,0x00, // -2-
- 0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0C,0x00,
- 0x08,0x0C,0x44,0x44,0x44,0xFC,0xB8,0x00, // -3-
- 0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,
- 0xC0,0xE0,0xB0,0x98,0xFC,0xFC,0x80,0x00, // -4-
- 0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,
- 0x7C,0x7C,0x44,0x44,0xC4,0xC4,0x84,0x00, // -5-
- 0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,
- 0xF0,0xF8,0x4C,0x44,0x44,0xC0,0x80,0x00, // -6-
- 0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,
- 0x0C,0x0C,0x04,0x84,0xC4,0x7C,0x3C,0x00, // -7-
- 0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00,
- 0xB8,0xFC,0x44,0x44,0x44,0xFC,0xB8,0x00, // -8-
- 0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,
- 0x38,0x7C,0x44,0x44,0x44,0xFC,0xF8,0x00, // -9-
- 0x00,0x08,0x08,0x08,0x0C,0x07,0x03,0x00,
- 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, // -:-
- 0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, // -;-
- 0x00,0x00,0x08,0x0E,0x06,0x00,0x00,0x00,
- 0x00,0x80,0xC0,0x60,0x30,0x18,0x08,0x00, // -<-
- 0x00,0x00,0x01,0x03,0x06,0x0C,0x08,0x00,
- 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, // -=-
- 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,
- 0x00,0x08,0x18,0x30,0x60,0xC0,0x80,0x00, // ->-
- 0x00,0x08,0x0C,0x06,0x03,0x01,0x00,0x00,
- 0x18,0x1C,0x04,0xC4,0xE4,0x3C,0x18,0x00, // -?-
- 0x00,0x00,0x00,0x0D,0x0D,0x00,0x00,0x00,
- 0xF0,0xF8,0x08,0xC8,0xC8,0xF8,0xF0,0x00, // -@-
- 0x07,0x0F,0x08,0x0B,0x0B,0x0B,0x01,0x00,
- 0xE0,0xF0,0x98,0x8C,0x98,0xF0,0xE0,0x00, // -A-
- 0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,
- 0x04,0xFC,0xFC,0x44,0x44,0xFC,0xB8,0x00, // -B-
- 0x08,0x0F,0x0F,0x08,0x08,0x0F,0x07,0x00,
- 0xF0,0xF8,0x0C,0x04,0x04,0x0C,0x18,0x00, // -C-
- 0x03,0x07,0x0C,0x08,0x08,0x0C,0x06,0x00,
- 0x04,0xFC,0xFC,0x04,0x0C,0xF8,0xF0,0x00, // -D-
- 0x08,0x0F,0x0F,0x08,0x0C,0x07,0x03,0x00,
- 0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00, // -E-
- 0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00,
- 0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00, // -F-
- 0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,
- 0xF0,0xF8,0x0C,0x84,0x84,0x8C,0x98,0x00, // -G-
- 0x03,0x07,0x0C,0x08,0x08,0x07,0x0F,0x00,
- 0xFC,0xFC,0x40,0x40,0x40,0xFC,0xFC,0x00, // -H-
- 0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,
- 0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,0x00, // -I-
- 0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,
- 0x00,0x00,0x00,0x04,0xFC,0xFC,0x04,0x00, // -J-
- 0x07,0x0F,0x08,0x08,0x0F,0x07,0x00,0x00,
- 0x04,0xFC,0xFC,0xC0,0xF0,0x3C,0x0C,0x00, // -K-
- 0x08,0x0F,0x0F,0x00,0x01,0x0F,0x0E,0x00,
- 0x04,0xFC,0xFC,0x04,0x00,0x00,0x00,0x00, // -L-
- 0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00,
- 0xFC,0xFC,0x38,0x70,0x38,0xFC,0xFC,0x00, // -M-
- 0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,
- 0xFC,0xFC,0x38,0x70,0xE0,0xFC,0xFC,0x00, // -N-
- 0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,
- 0xF0,0xF8,0x0C,0x04,0x0C,0xF8,0xF0,0x00, // -O-
- 0x03,0x07,0x0C,0x08,0x0C,0x07,0x03,0x00,
- 0x04,0xFC,0xFC,0x44,0x44,0x7C,0x38,0x00, // -P-
- 0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,
- 0xF8,0xFC,0x04,0x04,0x04,0xFC,0xF8,0x00, // -Q-
- 0x07,0x0F,0x08,0x0E,0x3C,0x3F,0x27,0x00,
- 0x04,0xFC,0xFC,0x44,0xC4,0xFC,0x38,0x00, // -R-
- 0x08,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,
- 0x18,0x3C,0x64,0x44,0xC4,0x9C,0x18,0x00, // -S-
- 0x06,0x0E,0x08,0x08,0x08,0x0F,0x07,0x00,
- 0x00,0x1C,0x0C,0xFC,0xFC,0x0C,0x1C,0x00, // -T-
- 0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,
- 0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00, // -U-
- 0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,
- 0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00, // -V-
- 0x01,0x03,0x06,0x0C,0x06,0x03,0x01,0x00,
- 0xFC,0xFC,0x00,0x80,0x00,0xFC,0xFC,0x00, // -W-
- 0x03,0x0F,0x0E,0x03,0x0E,0x0F,0x03,0x00,
- 0x0C,0x3C,0xF0,0xC0,0xF0,0x3C,0x0C,0x00, // -X-
- 0x0C,0x0F,0x03,0x00,0x03,0x0F,0x0C,0x00,
- 0x00,0x3C,0x7C,0xC0,0xC0,0x7C,0x3C,0x00, // -Y-
- 0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,
- 0x1C,0x0C,0x84,0xC4,0x64,0x3C,0x1C,0x00, // -Z-
- 0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0E,0x00,
- 0x00,0x00,0xFC,0xFC,0x04,0x04,0x00,0x00, // -[-
- 0x00,0x00,0x0F,0x0F,0x08,0x08,0x00,0x00,
- 0x38,0x70,0xE0,0xC0,0x80,0x00,0x00,0x00, // -\-
- 0x00,0x00,0x00,0x01,0x03,0x07,0x0E,0x00,
- 0x00,0x00,0x04,0x04,0xFC,0xFC,0x00,0x00, // -]-
- 0x00,0x00,0x08,0x08,0x0F,0x0F,0x00,0x00,
- 0x08,0x0C,0x06,0x03,0x06,0x0C,0x08,0x00, // -^-
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -_-
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x00,0x00,0x03,0x07,0x04,0x00,0x00,0x00, // -`-
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xA0,0xA0,0xA0,0xE0,0xC0,0x00,0x00, // -a-
- 0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,
- 0x04,0xFC,0xFC,0x20,0x60,0xC0,0x80,0x00, // -b-
- 0x08,0x0F,0x07,0x08,0x08,0x0F,0x07,0x00,
- 0xC0,0xE0,0x20,0x20,0x20,0x60,0x40,0x00, // -c-
- 0x07,0x0F,0x08,0x08,0x08,0x0C,0x04,0x00,
- 0x80,0xC0,0x60,0x24,0xFC,0xFC,0x00,0x00, // -d-
- 0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,
- 0xC0,0xE0,0xA0,0xA0,0xA0,0xE0,0xC0,0x00, // -e-
- 0x07,0x0F,0x08,0x08,0x08,0x0C,0x04,0x00,
- 0x40,0xF8,0xFC,0x44,0x0C,0x18,0x00,0x00, // -f-
- 0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,
- 0xC0,0xE0,0x20,0x20,0xC0,0xE0,0x20,0x00, // -g-
- 0x27,0x6F,0x48,0x48,0x7F,0x3F,0x00,0x00,
- 0x04,0xFC,0xFC,0x40,0x20,0xE0,0xC0,0x00, // -h-
- 0x08,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,
- 0x00,0x00,0x20,0xEC,0xEC,0x00,0x00,0x00, // -i-
- 0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x20,0xEC,0xEC,0x00, // -j-
- 0x00,0x30,0x70,0x40,0x40,0x7F,0x3F,0x00,
- 0x04,0xFC,0xFC,0x80,0xC0,0x60,0x20,0x00, // -k-
- 0x08,0x0F,0x0F,0x01,0x03,0x0E,0x0C,0x00,
- 0x00,0x00,0x04,0xFC,0xFC,0x00,0x00,0x00, // -l-
- 0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,
- 0xE0,0xE0,0x60,0xC0,0x60,0xE0,0xC0,0x00, // -m-
- 0x0F,0x0F,0x00,0x0F,0x00,0x0F,0x0F,0x00,
- 0x20,0xE0,0xC0,0x20,0x20,0xE0,0xC0,0x00, // -n-
- 0x00,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,
- 0xC0,0xE0,0x20,0x20,0x20,0xE0,0xC0,0x00, // -o-
- 0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,
- 0x20,0xE0,0xC0,0x20,0x20,0xE0,0xC0,0x00, // -p-
- 0x40,0x7F,0x7F,0x48,0x08,0x0F,0x07,0x00,
- 0xC0,0xE0,0x20,0x20,0xC0,0xE0,0x20,0x00, // -q-
- 0x07,0x0F,0x08,0x48,0x7F,0x7F,0x40,0x00,
- 0x20,0xE0,0xC0,0x60,0x20,0x60,0xC0,0x00, // -r-
- 0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,
- 0x40,0xE0,0xA0,0x20,0x20,0x60,0x40,0x00, // -s-
- 0x04,0x0C,0x09,0x09,0x0B,0x0E,0x04,0x00,
- 0x20,0x20,0xF8,0xFC,0x20,0x20,0x00,0x00, // -t-
- 0x00,0x00,0x07,0x0F,0x08,0x0C,0x04,0x00,
- 0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00,0x00, // -u-
- 0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,
- 0x00,0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00, // -v-
- 0x00,0x03,0x07,0x0C,0x0C,0x07,0x03,0x00,
- 0xE0,0xE0,0x00,0x00,0x00,0xE0,0xE0,0x00, // -w-
- 0x07,0x0F,0x0C,0x07,0x0C,0x0F,0x07,0x00,
- 0x20,0x60,0xC0,0x80,0xC0,0x60,0x20,0x00, // -x-
- 0x08,0x0C,0x07,0x03,0x07,0x0C,0x08,0x00,
- 0xE0,0xE0,0x00,0x00,0x00,0xE0,0xE0,0x00, // -y-
- 0x47,0x4F,0x48,0x48,0x68,0x3F,0x1F,0x00,
- 0x60,0x60,0x20,0xA0,0xE0,0x60,0x20,0x00, // -z-
- 0x0C,0x0E,0x0B,0x09,0x08,0x0C,0x0C,0x00,
- 0x00,0x40,0x40,0xF8,0xBC,0x04,0x04,0x00, // -{-
- 0x00,0x00,0x00,0x07,0x0F,0x08,0x08,0x00,
- 0x00,0x00,0x00,0xBC,0xBC,0x00,0x00,0x00, // -|-
- 0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,
- 0x00,0x04,0x04,0xBC,0xF8,0x40,0x40,0x00, // -}-
- 0x00,0x08,0x08,0x0F,0x07,0x00,0x00,0x00,
- 0x08,0x0C,0x04,0x0C,0x08,0x0C,0x04,0x00, // -~-
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x80,0xC0,0x60,0x30,0x60,0xC0,0x80,0x00, // --
- 0x07,0x07,0x04,0x04,0x04,0x07,0x07,0x00,
- };
- /*--------------------------------32X16-----------------------------------------*/
- unsigned char code ucNum3216[][64]=
- {0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0xFE,0xFF,0x0F,0x01,0x00,0x00,0x00,0x00,0x01,0x0F,0xFF,0xFE,0xF0,0x00,
- 0x00,0x1F,0x7F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0xFF,0x1F,0x00,
- 0x00,0x00,0x00,0x01,0x03,0x07,0x06,0x06,0x06,0x06,0x07,0x03,0x01,0x00,0x00,0x00,/*"0",0*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x0C,0x0C,0x0C,0x0E,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",1*/
- 0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x3C,0x3F,0x3F,0x03,0x00,0x00,0x00,0xC1,0xFF,0xFF,0x7E,0x00,0x00,
- 0x00,0x00,0x00,0xC0,0xE0,0xF0,0x78,0x1C,0x0E,0x07,0x03,0x01,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x07,0x07,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,/*"2",2*/
- 0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x0C,0x0F,0x0F,0x03,0x00,0x80,0x80,0xC1,0xFF,0x7F,0x3E,0x00,0x00,0x00,
- 0x00,0x70,0xF0,0xF0,0x80,0x00,0x00,0x01,0x01,0x03,0x87,0xFF,0xFE,0xFC,0x00,0x00,
- 0x00,0x00,0x01,0x03,0x03,0x07,0x06,0x06,0x06,0x06,0x03,0x03,0x01,0x00,0x00,0x00,/*"3",3*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x80,0xE0,0xF0,0x3C,0x0E,0x07,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
- 0x00,0x1C,0x1E,0x1F,0x19,0x18,0x18,0x18,0x18,0xFF,0xFF,0xFF,0x18,0x18,0x18,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x00,0x00,0x00,/*"4",4*/
- 0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,
- 0x00,0x00,0xF8,0xFF,0xCF,0xC0,0x60,0x60,0x60,0xE0,0xE0,0xC0,0x80,0x00,0x00,0x00,
- 0x00,0xE0,0xE1,0xE1,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0x7E,0x00,0x00,
- 0x00,0x00,0x03,0x07,0x07,0x0E,0x0C,0x0C,0x0C,0x0E,0x07,0x07,0x01,0x00,0x00,0x00,/*"5",5*/
- 0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x00,0x00,0x00,
- 0x00,0x00,0xF0,0xFC,0xFF,0x8F,0xC1,0x60,0x60,0x60,0xE0,0xE1,0xC7,0x87,0x06,0x00,
- 0x00,0x00,0x3F,0xFF,0xFF,0x81,0x00,0x00,0x00,0x00,0x00,0x81,0xFF,0xFF,0x7E,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x06,0x06,0x06,0x07,0x07,0x03,0x01,0x00,0x00,/*"6",6*/
- 0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFE,0xFF,0x1F,0x03,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xFF,0x3F,0x07,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"7",7*/
- 0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x3E,0x7F,0xFF,0xC1,0x80,0x80,0x80,0xC1,0xFF,0x7F,0x3E,0x00,0x00,0x00,
- 0x00,0xF8,0xFE,0xFE,0x87,0x03,0x01,0x01,0x01,0x03,0x87,0xFE,0xFE,0xF8,0x00,0x00,
- 0x00,0x00,0x01,0x03,0x03,0x07,0x06,0x06,0x06,0x07,0x03,0x03,0x01,0x00,0x00,0x00,/*"8",8*/
- 0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xFC,0xFF,0xFF,0x83,0x01,0x00,0x00,0x00,0x01,0x83,0xFF,0xFE,0xF8,0x00,
- 0x00,0x00,0xC0,0xC1,0xC3,0x07,0x06,0x06,0x06,0x06,0x83,0xE1,0xFF,0x7F,0x1F,0x00,
- 0x00,0x00,0x00,0x01,0x03,0x07,0x06,0x06,0x06,0x07,0x03,0x03,0x01,0x00,0x00,0x00,/*"9",9*/
- 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};
- #ifndef _COLINLUAN_DS1302_H_
- #define _COLINLUAN_DS1302_H_
- #define uchar unsigned char
- typedef struct systime
- {
- uchar cYear;
- uchar cMon;
- uchar cDay;
- uchar cHour;
- uchar cMin;
- uchar cSec;
- uchar cWeek;
- }SYSTIME;
- extern void DS1302_Write(uchar ucData);
- extern uchar DS1302_Read();
- extern void DS1302_Init();
- extern uchar WDS1302(uchar ucAddr,uchar ucDar);
- extern uchar RDS1302(uchar ucAddr);
- extern void SetTime(SYSTIME sys);
- extern void GetTime(SYSTIME *sys);
- #endif
- #ifndef _COLINLUAN_LUNAR_H_
- #define _COLINLUAN_LUNAR_H_
- #define uchar unsigned char
- #define uint unsigned int
-
- typedef struct spdate
- {
- char cYear;
- char cMon;
- char cDay;
- }SPDATE;
- extern SPDATE GetSpringDay(uchar GreYear,uchar GreMon,uchar GreDay); //获得农历日期
- extern bit YearFlag(uchar cYear); //判断平年,闰年
- extern uchar GetWeekDay(uchar cYear,uchar cMon,uchar cDay); //判断当前天是星期几
- #endif
- #define int8 unsigned char
- #define KEY1 0
- #define KEY2 1
- #define KEY3 2
- #define KEY4 3
- //键值定义
- #define KEY_NONE 0x00
- #define KEY_ONOFF 0x10
- #define KEY_ACCU 0x20
- #define KEY_BUZZER 0x40
- #define KEY_BACKLED 0x80
- #define KEYCOUNT_DEF 1 //10ms*1=10ms 去抖时间
- int8 keyvalue=KEY_NONE;
- int8 key1count_dn =0,key1count_up =0; //按键去抖计数器
- int8 key2count_dn =0,key2count_up =0;
- int8 key3count_dn =0,key3count_up =0;
- int8 key4count_dn =0,key4count_up =0;
- void keyinput(void){
- int8 portb_temp;
- portb_temp=P3;
- if(!(portb_temp&0x10)){ //SET键按下处理
- if (key1count_up<KEYCOUNT_DEF) key1count_up= 0; //清弹起计数器,保证弹起的脉宽必须大于2*KEYCOUNT_DEF
- key1count_dn++;
- if (key1count_dn==KEYCOUNT_DEF) { keyvalue|=0x10;key1count_up= 0; }
- if (key1count_dn> KEYCOUNT_DEF) key1count_dn = KEYCOUNT_DEF; //保持按下计数器
- }
- else{ //SET键弹起处理
- if (key1count_dn<KEYCOUNT_DEF) key1count_dn=0; //清按下计数器,保证按下的脉宽必须大于2*KEYCOUNT_DEF
- key1count_up++;
- if (key1count_up==KEYCOUNT_DEF) { keyvalue&=0xef;key1count_dn=0;}
- if (key1count_up>KEYCOUNT_DEF) key1count_up = KEYCOUNT_DEF;
- }
- if(!(portb_temp&0x20)){ //INC键按下处理
- if (key2count_up<KEYCOUNT_DEF) key2count_up= 0; //清弹起计数器,保证弹起的脉宽必须大于2*KEYCOUNT_DEF
- key2count_dn++;
- if (key2count_dn==KEYCOUNT_DEF) { keyvalue|=0x20;key2count_up= 0; }
- if (key2count_dn> KEYCOUNT_DEF) key2count_dn = KEYCOUNT_DEF; //保持按下计数器
- }
- else{ //INC键弹起处理
- if (key2count_dn<KEYCOUNT_DEF) key2count_dn=0; //清按下计数器,保证按下的脉宽必须大于2*KEYCOUNT_DEF
- key2count_up++;
- if (key2count_up==KEYCOUNT_DEF) { keyvalue&=0xdf;key2count_dn=0;}
- if (key2count_up>KEYCOUNT_DEF) key2count_up = KEYCOUNT_DEF;
- }
-
- if(!(portb_temp&0x40)){ //DEC键按下处理
- if (key3count_up<KEYCOUNT_DEF) key3count_up= 0; //清弹起计数器,保证弹起的脉宽必须大于2*KEYCOUNT_DEF
- key3count_dn++;
- if (key3count_dn==KEYCOUNT_DEF) { keyvalue|=0x40; key3count_up= 0;}
- if (key3count_dn> KEYCOUNT_DEF) key3count_dn = KEYCOUNT_DEF; //保持按下计数器
- }
- else{ //DEC键弹起处理
-
- if (key3count_dn<KEYCOUNT_DEF) key3count_dn=0; //清按下计数器,保证按下的脉宽必须大于2*KEYCOUNT_DEF
- key3count_up++;
- if (key3count_up==KEYCOUNT_DEF) { keyvalue&=0xbf;key3count_dn=0;}
- if (key3count_up>KEYCOUNT_DEF) key3count_up = KEYCOUNT_DEF;
- }
- }
- uchar dispBuf[7];
- uchar T0_Count=0,Tmp_Count=0;
- bit T0_Flag,Tmp_Flag,Flash_Flag;
- SYSTIME sys; //系统日期
- SPDATE SpDat; //农历日期
- bit Hour_Flag=TRUE,Min_Flag=TRUE,Sec_Flag=TRUE; //设置时间标志
- bit Year_Flag=TRUE,Mon_Flag=TRUE,Day_Flag=TRUE;
- uchar State_Set=0; //设置时、分、秒、日、月、年等状态
- bit State_Flag=FALSE,Inc_Flag=FALSE,Dec_Flag=FALSE; //三个按键是否按下的标志
- uchar code Mon2[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31,
- 0,31,29,31,30,31,30,31,31,30,31,30,31};
- /*****************************LCD显示函数******************************
- 入口参数:
- cDat: 要显示的数
- X: 行数 0~7
- Y: 列数 0~127
- show_flag: 是否反白显示,0反白,1不反白
- upline: 上划线, 0表示带上划线
- underline: 下划线, 0表示带下划线
- ***********************************************************************/
- void LCD_ShowTime(char cDat,uchar X,uchar Y,bit show_flag,bit up,bit under){
- uchar s[2];
- s[0]=cDat/10+'0';
- s[1]=cDat%10+'0';
- en_disp(X,Y,2,Asc,s,show_flag,up,under);
- }
-
- void Show_YMD(){ //年、月、日、星期、显示函数
- uchar uiTempDat;
- uiTempDat=RDS1302(0x88|0x01);
- sys.cMon=((uiTempDat&0x1f)>>4)*10+(uiTempDat&0x0f);
- LCD_ShowTime(sys.cMon,2,5,Mon_Flag,NoUpLine,NoUnderLine);
- hz_disp(4,5,1,uMod[1],1,NoUpLine,NoUnderLine); //月
- Show16X32(2,27,ucNum3216[sys.cDay/10],Day_Flag); //日
- Show16X32(2,43,ucNum3216[sys.cDay%10],Day_Flag);
- hz_disp(6,8,2,ucLunar[13],1,UpLine,UnderLine);
- if(sys.cWeek==7)
- hz_disp(6,40,1,uMod[2],1,UpLine,UnderLine); //星期
- else
- hz_disp(6,40,1,ucLunar[sys.cWeek],1,UpLine,UnderLine); //星期
- LCD_ShowTime(20,0,9,1,UpLine,UnderLine);
- LCD_ShowTime(sys.cYear,0,25,Year_Flag,UpLine,UnderLine);
- hz_disp(0,41,1,uMod[0],1,UpLine,UnderLine); //年
- SpDat=GetSpringDay(sys.cYear,sys.cMon,sys.cDay); //获得农历
- if(SpDat.cMon==1) //显示农历月
- hz_disp(4,64,1,ucLunar[15],1,UpLine,NoUnderLine); //"正"
- else if(SpDat.cMon==11)
- hz_disp(4,64,1,ucLunar[16],1,UpLine,NoUnderLine); //"冬"
- else if(SpDat.cMon==12)
- hz_disp(4,64,1,ucLunar[17],1,UpLine,NoUnderLine); //"腊"
- else
- hz_disp(4,63,1,ucLunar[SpDat.cMon],1,UpLine,NoUnderLine); //"二"~"十"
- if(SpDat.cDay/10==1 && SpDat.cDay%10>0) //显示"十" 例如"十四"而不是"一四"
- hz_disp(4,95,1,ucLunar[10],1,UpLine,NoUnderLine);
- else if(SpDat.cDay/10==2 && SpDat.cDay%10>0) //显示"廿" 例如"廿三"而不是"二四"
- hz_disp(4,95,1,ucLunar[19],1,UpLine,NoUnderLine);
- else
- hz_disp(4,95,1,ucLunar[SpDat.cDay/10],1,UpLine,NoUnderLine); //正常数字
- if(!(SpDat.cDay%10)) //"十"
- hz_disp(4,111,1,ucLunar[10],1,UpLine,NoUnderLine);
- else //正常数字
- hz_disp(4,111,1,ucLunar[SpDat.cDay%10],1,UpLine,NoUnderLine);
- hz_disp(0,104,1,SX[(uint)(2000+SpDat.cYear)%12],1,UpLine,UnderLine); //生肖
-
- hz_disp(2,95,1,TianGan[(uint)(2000+SpDat.cYear)%10],1,NoUpLine,NoUnderLine); //天干
- hz_disp(2,111,1,DiZhi[(uint)(2000+SpDat.cYear)%12],1,NoUpLine,NoUnderLine); //地支
-
- }
- void LCD_ShowWNL(){ //万年历显示函数
- LCD_ShowTime(sys.cSec,6,111,Sec_Flag,UpLine,UnderLine); //秒,每秒钟刷新
- if(!sys.cSec || State_Set) //分,普通模式每分钟刷新
- LCD_ShowTime(sys.cMin,6,87,Min_Flag,UpLine,UnderLine); // 设置模式每次刷新
-
- if(!sys.cSec && !sys.cMin || State_Set) //时,普通模式每小时刷新
- LCD_ShowTime(sys.cHour,6,63,Hour_Flag,UpLine,UnderLine); // 设置模式每次刷新
-
- if(!sys.cSec && !sys.cMin && !sys.cHour || State_Set ){ //公历农历的年、月、日、星期
- Show_YMD(); //普通模式每天刷新
- if(State_Set==7) State_Set=0; //设置模式每次刷新
- }
- }
- void CAL_Init(){ //日期初始化函数
- sys.cYear=0x13; //BCD码表示的日历时间值
- sys.cMon=0x06;
- sys.cDay=0x030;
- sys.cHour=0x23;
- sys.cMin=0x59;
- sys.cSec=0x55;
- sys.cWeek=GetWeekDay(sys.cYear,sys.cMon,sys.cDay);
- }
- void SFR_Init(){ //定时器1初始化函数
- Flash_Flag=FALSE;
- TMOD=0x11;
- ET1=1;
- TH1= (-10000)/256;
- TL1= (-10000)%256;
- EA=1;
- }
- void GUI_Init(){ //LCD图形初始化函数
- LCD12864_init();
- ClearLCD();
- Rect(0,0,127,63,1); //描绘框架
- Line(62,0,62,62,1);
- Line(0,48,127,48,1);
- Line(0,15,127,15,1);
- Line(24,15,24,48,1);
- Line(63,32,128,32,1);
- SetTime(sys); //设置时间
- GetTime(&sys); //获得时间
-
- Show_YMD();
- LCD_ShowTime(sys.cSec,6,111,Sec_Flag,UpLine,UnderLine);
- en_disp(6,103,1,Asc,":",1,UpLine,UnderLine);
- LCD_ShowTime(sys.cMin,6,87,Min_Flag,UpLine,UnderLine);
- en_disp(6,79,1,Asc,":",1,UpLine,UnderLine);
- LCD_ShowTime(sys.cHour,6,63,Hour_Flag,UpLine,UnderLine);
- hz_disp(2,64,1,ucLunar[11],1,NoUpLine,NoUnderLine); //"农"
- hz_disp(2,80,1,ucLunar[12],1,NoUpLine,NoUnderLine); //"历"
- hz_disp(4,79,1,uMod[1],1,UpLine,NoUnderLine); //"月"
- }
- void DecToBCD(){ //二-十进制转换函数
- sys.cHour=(((sys.cHour)/10)<<4)+((sys.cHour)%10);
- sys.cMin=(((sys.cMin)/10)<<4)+((sys.cMin)%10);
- sys.cSec=((sys.cSec/10)<<4)+((sys.cSec)%10);
- sys.cYear=((sys.cYear/10)<<4)+((sys.cYear)%10);
- sys.cMon=((sys.cMon/10)<<4)+((sys.cMon)%10);
- sys.cDay=((sys.cDay/10)<<4)+((sys.cDay)%10);
- }
- void Time_Set(){ //时间设置函数
- if(State_Flag){ //设置键按下
- State_Flag=FALSE;
- State_Set++;
- if(State_Set==8) State_Set=0;
- }
- Hour_Flag=TRUE;Min_Flag=TRUE;Sec_Flag=TRUE;
- Year_Flag=TRUE;Mon_Flag=TRUE;Day_Flag=TRUE;
- switch(State_Set){ //设置类型
- case 0: //无设置
- break;
- case 1: //设置时
- Hour_Flag=FALSE;
- break;
- case 2: //设置分
- Min_Flag=FALSE;
- break;
- case 3: //设置秒
- Sec_Flag=FALSE;
- break;
- case 4: //设置天
- Day_Flag=FALSE;
- break;
- case 5:
- Mon_Flag=FALSE; //设置月
- break;
- case 6:
- Year_Flag=FALSE; //设置年
- break;
- case 7: //无动作,设置此值为让"年"的反白消失。
- break;
- }
-
- if(Inc_Flag){ //加键被按下
- Inc_Flag=FALSE;
- switch(State_Set) {
- case 0:
- break;
- case 1: //小时加
- sys.cHour++;
- (sys.cHour)%=24;
- break;
- case 2: //分加1
- sys.cMin++;
- sys.cMin%=60;
- break;
- case 3: //秒加1
- sys.cSec++;
- sys.cSec%=60;
- break;
- case 4: //天加1
- (sys.cDay)=(sys.cDay%Mon2[YearFlag(sys.cYear)][sys.cMon])+1;
- break;
- case 5: //月加1
- sys.cMon=(sys.cMon%12)+1;
- break;
- case 6:
- sys.cYear++; //年加1
- sys.cYear=sys.cYear%100;
- break;
- }
- DecToBCD(); //转为BCD数
- sys.cWeek=GetWeekDay(sys.cYear,sys.cMon,sys.cDay); //算出星期
- SetTime(sys); //存入DS1302
- }
- if(Dec_Flag){ //减键按下
- Dec_Flag=FALSE;
- switch(State_Set){
- case 0:
- break;
- case 1:
- sys.cHour=(sys.cHour+23)%24; //时减1
- break;
- case 2: //分减1
- sys.cMin=(sys.cMin+59)%60;
- break;
- case 3: //秒减1
- sys.cSec=(sys.cSec+59)%60;
- break;
- case 4: //天减1
- sys.cDay=((sys.cDay+Mon2[YearFlag(sys.cYear)][sys.cMon]-1)%Mon2[YearFlag(sys.cYear)][sys.cMon]);
- if(sys.cDay==0) sys.cDay=Mon2[YearFlag(sys.cYear)][sys.cMon];
- break;
- case 5: //月减1
- sys.cMon=(sys.cMon+11)%12;
- if(sys.cMon==0) sys.cMon=12;
- break;
- case 6: //年减1
- sys.cYear=(sys.cYear+99)%100;
- break;
- }
- DecToBCD();
- sys.cWeek=GetWeekDay(sys.cYear,sys.cMon,sys.cDay);
- SetTime(sys);
- }
- }
- void main(){ //主函数
- SFR_Init();
- CAL_Init();
- GUI_Init();
- TR1=1;
- while(1){
- GetTime(&sys); //获得时间
- LCD_ShowWNL(); //显示万年历
- Time_Set(); //时间设置
- }
- }
- void timer1() interrupt 3 { //定时器1中断服务函数
- TH1= (-10000)/256;
- TL1= (-10000)%256;
- keyinput(); //读取按键
- if (keyvalue&0x10){
- State_Flag=TRUE;
- keyvalue &= 0xef; //清键值,保证一直按下只执行一次按键动作。
- }
- if (keyvalue&0x20 ){ //加
- Inc_Flag=TRUE;
- keyvalue &= 0xdf; //清键值,保证一直按下只执行一次按键动作。
- }
- if (keyvalue&0x40){ //减
- Dec_Flag=TRUE;
- keyvalue &= 0xbf; //清键值,保证一直按下只执行一次按键动作。
- }
-
- }
复制代码
所有资料51hei提供下载:
带农历的万年历.rar
(39.21 KB, 下载次数: 66)
|