12864液晶显示:
新建文件夹.zip
(42.16 KB, 下载次数: 8)
万年历终极版:
- #include<reg52.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar x,y; //清屏时定义的起始地址
- uchar flag1,flag2; //标志位 温湿度传感器时使用
- uchar wei; //位定义
- uchar zijie; // 字节定义
- uchar wdzs,wdxs,sdzs,sdxs,jiaoyan;
- uchar WZ,WX,SZ,SX,JY;
- sbit rs=P0^0; //液晶3个端口的定义
- sbit rw=P0^1;
- sbit e=P0^2;
- sbit SJ=P0^3; //温湿度传感器接口
-
- sbit sck=P0^4; //时钟芯片DS1302
- sbit io=P0^5;
- sbit rst=P0^6;
- sbit key1=P2^2;
- sbit key2=P2^1;
- sbit key3=P2^0;
- uchar time_data[7]={13,1,11,11,00,00,00};//年,周,月,日,时,分,秒
- uchar write_add[7]={0x8c,0x8a,0x88,0x86,0x84,0x82,0x80};
- uchar read_add[7]={0x8d,0x8b,0x89,0x87,0x85,0x83,0x81};
- uchar disp[13]="";
- uchar time_data1[7]=""; //用来存放从1302中读出的时间
- uchar time_data2[7]="";
- uchar table1[]="温度";
- uchar table2[]="湿度";
- uchar table3[4]="";
- uchar table4[4]="";
- uchar table5[]="温湿度万年历"; //可显示任意汉字数字及字符
- uchar code image[]=
- {0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x10,0xE7,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x10,0x42,0x92,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x18,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x28,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x28,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x24,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x3C,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x44,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0xE7,0x3C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,//HAUT
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x01,0x80,0x00,
- 0x00,0x60,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0xE0,0x00,0x01,0x80,0x00,
- 0x00,0x63,0xE0,0x18,0x00,0x0E,0x01,0xB0,0x00,0xC0,0x07,0xE0,0x00,0x03,0x40,0x00,
- 0x00,0x3F,0x80,0x7C,0x01,0xF8,0x00,0xF0,0x00,0xC0,0x00,0xF8,0x00,0x02,0x40,0x00,
- 0x00,0xC7,0x80,0x33,0x80,0x30,0x00,0xF0,0x01,0x98,0x1F,0x98,0x00,0x02,0x40,0x00,
- 0x00,0x3F,0x80,0xFF,0x80,0x30,0x06,0xFC,0x0F,0xF0,0x1F,0xC0,0x00,0x02,0x40,0x00,
- 0x00,0x1F,0x81,0xF9,0x80,0x30,0x03,0xF8,0x01,0x80,0x01,0x80,0x00,0x06,0x20,0x00,
- 0x00,0x6D,0x81,0xF9,0x80,0x30,0x03,0xF0,0x01,0xC0,0x01,0xF8,0x00,0x38,0x1C,0x00,
- 0x00,0xC1,0x81,0xBF,0x80,0x30,0x00,0xF0,0x01,0xE0,0x1F,0x80,0x01,0xE0,0x03,0x80,
- 0x00,0xC1,0x81,0xF9,0x83,0xFF,0x80,0xFF,0x03,0x30,0x01,0x80,0x00,0xC0,0x03,0x00,
- 0x00,0x03,0x81,0xB7,0x80,0x00,0x07,0xE0,0x06,0x38,0x01,0x80,0x00,0x38,0x3E,0x00,
- 0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x0C,0x03,0x80,0x00,0x04,0x20,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,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,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,
- 0x30,0x03,0x08,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x1F,0xEB,0x08,0x10,0x06,0x0E,0x0F,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x04,0x2B,0x3D,0xFF,0x1A,0x11,0x09,0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x35,0xAB,0x09,0x01,0x02,0x01,0x10,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x1D,0xAB,0x08,0xC6,0x02,0x0E,0x10,0x8E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x05,0xAB,0x0D,0x83,0x02,0x01,0x10,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x0D,0xAB,0x18,0xFE,0x02,0x01,0x10,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x19,0x8B,0x28,0x10,0x02,0x11,0x19,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x33,0xC7,0x08,0x10,0x02,0x0E,0x0F,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x26,0x73,0x39,0xFF,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,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,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };//显示一幅图片(可以是任意一张图片)
- void delay_50us(uchar z);
- void delay_50ms(uchar z);
- void delay_1s(uchar z);
- void write_12864com(uchar com);
- void write_12864dat(uchar dat);
- void ini();
- void clear();
- void picture( uchar*p);
- void display1(); //显示汉字
- void display2(); //显示温湿度
- void Delay (uint z) ;
- void delay_1ms(void);
- void Delay_nms(uchar n);
- void delay_10us() ;
- void jieshou (void) ;
- void read (void) ;
- void write_1302_byte(uchar dat);
- void write_1302(uchar add,uchar dat);
- uchar read_1302(uchar add);
- void set_rct();
- void read_rct(void) ;
- void time_pros(void);
- void display3();//显示日期
- void display4();//显示时间
- void tiaoshi();//时间调整
- void main()
- {
- ini(); //液晶初始化
- set_rct(); //对时
- clear(); //清屏
- picture(image); // 显示图片
- delay_1s(10);
- clear(); //清屏
-
- while(1)
- {
- display1();//显示第一行汉字
- display2();//显示温湿度(第二行)
- read(); //读取温湿度
- delay_1s(2);
- tiaoshi ();
- read_rct();//读取时间
- time_pros(); //时间处理函数
- display3(); //用来显示日期 (第三行)
- display4(); //用来显示时间(第四行)
- }
- }
- void delay_50us(uchar z) //延时50微妙
- {
- uint j;
- for(;z>0;z--)
- for (j=19;j>0;j--);
- }
- void delay_50ms(uchar z) //延时50毫秒
- { uint j;
- for(;z>0;z--)
- for (j=6000;j>0;j--);
- }
- void delay_1s(uchar z) //延时1秒
- {
- uint i,j,k;
- for (i=z;i>0;i--)
- for(j=600;j>0;j--)
- for(k=10;k>0;k--);
- }
- void Delay (uint z)
- {
- uchar x,y;
- for(x=z;x>0;x--);
- for(y=110;y>0;y--);
- }
- /****************lcd12864程序****************/
- void write_12864com(uchar com)//写指令
- { rw=0;
- rs=0;
- delay_50us(1);
- P1=com;//数据接口
- e=1;
- delay_50us(10);
- e=0;
- delay_50us(2);
- }
- void write_12864dat(uchar dat)//写数据
- { rw=0;
- rs=1;
- delay_50us(1);
- P1=dat;//数据接口
- e=1;
- delay_50us(10);
- e=0;
- delay_50us(2);
- }
- void ini()//初始化
- { delay_50ms(2);
- write_12864com(0x30);//
- delay_50us(4);
- write_12864com(0x30);
- delay_50us(4);
- write_12864com(0x0c);//显示游标 ,反写 ,光标
- delay_50us(4);
- write_12864com(0x01); //清除显示
- delay_50us(240);
- //write_12864com(0x06); //模式设置
- //delay_50us(10);
- }
- void clear(void)
- { uchar i,j,k;
- x=0x80;
- y=0x80;
- write_12864com(0x34); //打开扩展指令集
- for (i=0;i<2;i++)
- {
- for (j=0;j<32;j++)
- { write_12864com(y+j);
- write_12864com(x);
- for (k=0;k<16;k++)
- {
- write_12864dat(0x00);
- }
- }
- x=0x88;
- }
- write_12864com(0x36);//打开绘图显示
- write_12864com(0x30);
- }
- void picture( uchar*p)
- {
- uchar i,j,k;
- x=0x80;
- y=0x80;
- write_12864com(0x34);
- for (i=0;i<2;i++)
- {
- for (j=0;j<32;j++)
- {
- write_12864com(y+j);
- write_12864com(x);
- for (k=0;k<16;k++)
- {
- write_12864dat(*p++);
- }
- }
- x=0x88;
- }
- write_12864com(0x36);
- write_12864com(0x30);
- }
- void display1() //显示汉字 温湿度万年历
- { uchar i,a;
- a=0;
- write_12864com(0x80);//地址
- write_12864dat(0x20);
- write_12864dat(0x01);
- write_12864dat(0x01);
- write_12864dat(0x20);
- for (i=4;i<16;i++)
- {
- write_12864dat(table5[a]);
- a++;
- delay_50us(1);
- }
- }
- void display2()//显示汉字 用数组 温湿度
- {
- uchar i,a,b,c,d;
- a=0;
- b=0;
- c=0;
- d=0;
- write_12864com(0x90);//地址
- for (i=0;i<4;i++)
- {
- write_12864dat(table1[a]);
- a++;
- delay_50us(1);
- }
- for (i=4;i<8;i++)
- {
- write_12864dat(table3[b]);
- b++;
- delay_50us(1);
- }
- for (i=8;i<12;i++)
- {
- write_12864dat(table2[c]);
- c++;
- delay_50us(1);
- }
- for (i=12;i<16;i++)
- {
- write_12864dat(table4[d]);
- d++;
- delay_50us(1);
- }
- }
- void display3() //显示日期
- {
- uchar a;
- if (disp[10]==0x31) a=0;
- if (disp[10]==0x32) a=1;
- if (disp[10]==0x33) a=2;
- if (disp[10]==0x34) a=3;
- if (disp[10]==0x35) a=4;
- if (disp[10]==0x36) a=5;
- if (disp[10]==0x37) a=6;
- write_12864com(0x88);
- write_12864dat(0x32); //2
- write_12864dat(0x30); //0
- write_12864dat(disp[12]);
- write_12864dat(disp[11]);
- write_12864dat(0xa3);
- write_12864dat(0xad);
- write_12864dat(disp[9]);
- write_12864dat(disp[8]);
- write_12864dat(0xa3);
- write_12864dat(0xad);
- write_12864dat(disp[7]);
- write_12864dat(disp[6]);
- write_12864dat(0x20);
- write_12864dat(0x20);
- write_12864dat(0xa2);
- write_12864dat(0xe5+a);
- }
- void display4() //显示时间
- {
- write_12864com(0x98);
- write_12864dat(0x20);
- write_12864dat(0x20);
- write_12864dat(disp[5]);
- write_12864dat(disp[4]);
- write_12864dat(0xa1);
- write_12864dat(0xc3);
- write_12864dat(disp[3]);
- write_12864dat(disp[2]);
- write_12864dat(0xa1);
- write_12864dat(0xc3);
- write_12864dat(disp[1]);
- write_12864dat(disp[0]);
- write_12864dat(0x20);
- write_12864dat(0x20);
- write_12864dat(0x20);
- write_12864dat(0x20);
- }
- /****************DHT11程序****************/
- void delay_10us(void) //10微秒
- {
- _nop_();
- _nop_();
- _nop_();
- }
- void delay_1ms(void) //1毫秒
- {
- uchar i;
- for(i=0;i<70;i++)
- {
- delay_10us();
- }
- }
- void Delay_nms(uchar n)//n毫秒
- {
- uchar x;
- for(x=n;x>0;x--)
- delay_1ms();
- }
- void jieshou (void) //数据0 1确认
- {
- uchar i;
- uchar flag;
- zijie=0;
- for(i=0;i<8;i++)
- {
- flag=2;
- while((!SJ)&&flag++); //1bit是否结束
- delay_10us();
- delay_10us();
- delay_10us();
- zijie<<=1;
- // delay_10us();
- /* if(SJ)
- {
- wei=1; // 超过28us依然为高电平 表示为1
- flag=2;
- while((SJ)&&flag++);
- }
- else
- wei=0;
- zijie<<=1;
- zijie|=wei;
- } */
- if(SJ)
- {
- wei=1; // 超过28us依然为高电平 表示为1
-
- zijie|=wei;
- }
- flag=2;
- while((SJ)&&flag++);
- }
- // return zijie;
- }
- void read (void)
- {
- uchar flag;
- SJ=0; //数据
- //主机拉低高于18ms
- Delay_nms(10);
- Delay_nms(10);
- Delay_nms(10);
- SJ=1;
- delay_10us();
- delay_10us();
- delay_10us();
- // delay_10us();
- // SJ=1; //主机设为输入 判断从机响应信号
- if(!SJ)
- {
- flag=1;
- while((!SJ)&&flag++);//判断从机是否发出 80us 的低电平响应号是否结束
- flag=1;
- while((SJ)&&flag++); //判断从机是否发出 80us 的高电平 如发据接收状态
- jieshou(); //数据接收状态
- sdzs=zijie; //湿度整数8位
- jieshou();
- sdxs=zijie;//湿度小数8位
- jieshou();
- wdzs=zijie; //温度整数8位
- jieshou();
- wdxs=zijie; //温度小数8位
- jieshou();
- jiaoyan=zijie; //校验位
- //SJ=1;
- //JY=(sdzs+sdxs+wdzs+wdxs);
- //if(JY==jiaoyan) //数据校验 正确执行
- if((sdzs+sdxs+wdzs+wdxs)==jiaoyan)//数据校验 正确执行
- {
- SZ=sdzs;
- SX=sdxs;
- WZ=wdzs;
- WX=wdxs;
- JY=jiaoyan;
- }
- else
- {
- SZ=0;
- SX=0;
- WZ=0;
- WX=0;
- }
- }
- table3[0]=0x3a;
- table3[1]=(char)(0x30+WZ/10);
- table3[2]=(char)(0x30+WZ%10);
- table3[3]=0x63;
- table4[0]=0x3a;
- table4[1]=(char)(0x30+SZ/10);
- table4[2]=(char)(0x30+SZ%10);
- table4[3]=0x25;
- }
- /***************DS1302程序*********************/
- void write_1302_byte(uchar dat) //写字节
- {
- uchar i;
- for (i=0;i<8;i++)
- {
- sck=0;
- io=dat&0x01;
- dat>>=1;
- sck=1;
- }
- }
- void write_1302(uchar add,uchar dat)
- { rst=0;
- _nop_();
- sck=0;
- _nop_();
- rst=1;
- _nop_();
- write_1302_byte(add);
- write_1302_byte(dat);
- rst=0;
- _nop_();
- io=1;
- sck=1;
- }
- uchar read_1302(uchar add)
- { uchar i,value;
- rst=0;
- _nop_();
- sck=0;
- _nop_();
- rst=1;
- _nop_();
- write_1302_byte(add);
- for (i=0;i<8;i++)
- {
- value>>=1;
- sck=0;
- if(io)
- value=value|0x80;
- sck=1;
- }
- rst=0;
- _nop_();
- sck=0;
- _nop_();
- sck=1;
- io=1;
- return value;
- }
- void set_rct(void)//设置时间
- { uchar i;
- for(i=0;i<7;i++) //10进制转换16进制
- {
- time_data1[i]=time_data[i]%10+time_data[i]/10*16;
- }
- write_1302(0x8e,0x00);//去除写保护
- for(i=0;i<7;i++)
- {
- write_1302(write_add[i],time_data1[i]);
- }
- write_1302(0x8e,0x80);//添加写保护
- }
- void read_rct(void) //对时间
- { uchar i;
- for(i=0;i<7;i++)
- {
- time_data2[i]=read_1302(read_add[i]); //此时数组里面是从里面读出来的时间(16进制的)
- }
- }
- void time_pros(void) //处理函数
- {
- disp[0]=(char)(time_data2[6]%16+0x30); //6表示秒
- disp[1]=(char)(time_data2[6]/16+0x30);
- disp[2]=(char)(time_data2[5]%16+0x30); //5表示分
- disp[3]=(char)(time_data2[5]/16+0x30);
- disp[4]=(char)(time_data2[4]%16+0x30); //4表示时
- disp[5]=(char)(time_data2[4]/16+0x30);
- disp[6]=(char)(time_data2[3]%16+0x30); //3表示日
- disp[7]=(char)(time_data2[3]/16+0x30);
- disp[8]=(char)(time_data2[2]%16+0x30); //2表示月
- disp[9]=(char)(time_data2[2]/16+0x30);
- disp[10]=(char)(time_data2[1]%16+0x30); //1表示周
- disp[11]=(char)(time_data2[0]%16+0x30); //0表示年
- disp[12]=(char)(time_data2[0]/16+0x30);
- }
- void tiaoshi () //时间调整
- {
- if (key1==0)
- {
- Delay(10);
- if(key1==0);
- {
- flag1++;
- if (flag1==1|flag1==2|flag1==3|flag1==4|flag1==5|flag1==6)
- {
- write_1302(0x8e,0x00);//允许写
- write_1302(0x80,0x80); //时钟停止
- }
- if(flag1==7)
- {
- flag1=0;
- write_1302(0x80,0x00); //启动时钟
- write_1302(0x8e,0x80);// 进制写(添加写保护)
- }
- }
- while(!key1);
- //Delay(10);
- //while(!key1);
- }
- if (key2==0)
- {
- Delay(10);
- if (key2==0)
- {
- switch(flag1)
- {
- case 1:
- {
- time_data[0]=time_data[0]+1;
- if(time_data[0]==100)
- time_data[0]=0;
- } break;
- case 2:
- {
- time_data[2]=time_data[2]+1;
- if(time_data[2]==13)
- time_data[2]=1;
- } break;
- case 3:
- {
- time_data[3]=time_data[3]+1;
- if(time_data[3]==32)
- time_data[3]=1;
- } break;
- case 4:
- {
- time_data[1]=time_data[1]+1;
- if(time_data[1]==8)
- time_data[1]=1;
- } break;
- case 5:
- {
- time_data[4]=time_data[4]+1;
- if(time_data[4]==24)
- time_data[4]=00;
- } break;
- case 6:
- {
- time_data[5]=time_data[5]+1;
- if(time_data[5]==60)
- time_data[5]=00;
- } break;
- }
- }
- while(!key2);
- set_rct();
- }
- if (key3==0)
- {
- Delay(10);
- if (key3==0)
- {
- switch(flag1)
- {
- case 1:
- {
- time_data[0]=time_data[0]-1;
- if(time_data[0]==-1)
- time_data[0]=99;
- } break;
- case 2:
- {
- time_data[2]=time_data[2]-1;
- if(time_data[2]==0)
- time_data[2]=12;
- } break;
- case 3:
- {
- time_data[3]=time_data[3]-1;
- if(time_data[3]==0)
- time_data[3]=31;
- } break;
- case 4:
- {
- time_data[1]=time_data[1]-1;
- if(time_data[1]==0)
- time_data[1]=7;
- } break;
- case 5:
- {
- time_data[4]=time_data[4]-1;
- if(time_data[4]==-1)
- time_data[4]=23;
- } break;
- case 6:
- {
- time_data[5]=time_data[5]-1;
- if(time_data[5]==-1)
- time_data[5]=59;
- } break;
- }
- while(!key3);
- set_rct();
- }
- }
- }
复制代码
|