具有大字显示时间的风格 温度实时显示 具有闹钟 星期自动计算 有农历 还有功能待完善。
#include"main.h"#include"LCD12864.h" #include"delay.h" #include"DS1302.h" #include"DS18B20.h" #include"NONGLICONVERSION.H" #include"keyscan.h" #include"bell.h" #include"zk.h" sbit style=P1^4; sbit knz =P2^3; void main() { Init_1302(); init_12864(); displaypicture_12864(0,0,qqt,64,128); delayms(5000); delayms(5000); delayms(5000); displaypicture_12864(0,0,kj,64,128); delayms(5000); delayms(5000); delayms(5000); writecom_12864(0x01); displaypicture_12864(0,0,kong,64,128); bell2(); while(1) { uint a,n,s,Year,Month,Day; Year=ReadYear_1302(); Month=ReadMoon_1302(); Day=ReadDay_1302(); a=Conver_week(Year,Month,Day); displayDigital_12864(1,0,20); displayDigital_12864(1,1,Year); writedat_12864('-'); writedat_12864(Month/10+0x30); writedat_12864(Month%10+0x30); writedat_12864('-'); displayDigital_12864(1,4,Day); if(a==0){display_12864(1,6,"周日");} //0=星期日 if(a==1){display_12864(1,6,"周一");} if(a==2){display_12864(1,6,"周二");} if(a==3){display_12864(1,6,"周三");} if(a==4){display_12864(1,6,"周四");} if(a==5){display_12864(1,6,"周五");} if(a==6){display_12864(1,6,"周六");} if(style==0) delayms(20); if(style==0) { bell1(); while(style==0); s++; } if(s%4==1) { displaypicture_12864(16,0,num16321[ReadHour_1302()/10],32,16); displaypicture_12864(16,1,num16321[ReadHour_1302()%10],32,16); if((ReadSecond_1302())%2==1) {displaypicture_12864(17,2,num16321[10],32,16);} if((ReadSecond_1302())%2==0) {displaypicture_12864(17,2,kong3216,32,16);} displaypicture_12864(16,3,num16321[ReadMinute_1302()/10],32,16); displaypicture_12864(16,4,num16321[ReadMinute_1302()%10],32,16); if((ReadSecond_1302())%2==1){displaypicture_12864(17,5,num16321[10],32,16);} if((ReadSecond_1302())%2==0){displaypicture_12864(17,5,kong3216,32,16);} displaypicture_12864(16,6,num16321[ReadSecond_1302()/10],32,16); displaypicture_12864(16,7,num16321[ReadSecond_1302()%10],32,16); } if(s%4==2) { displaypicture_12864(16,0,num16322[ReadHour_1302()/10],32,16); displaypicture_12864(16,1,num16322[ReadHour_1302()%10],32,16); if((ReadSecond_1302())%2==1){displaypicture_12864(17,2,num16322[10],32,16);} if((ReadSecond_1302())%2==0){displaypicture_12864(17,2,kong3216,32,16);} displaypicture_12864(16,3,num16322[ReadMinute_1302()/10],32,16); displaypicture_12864(16,4,num16322[ReadMinute_1302()%10],32,16); if(ReadSecond_1302()%2==1){displaypicture_12864(17,5,num16322[10],32,16);} if(ReadSecond_1302()%2==0){displaypicture_12864(17,5,kong3216,32,16);} displaypicture_12864(16,6,num16322[ReadSecond_1302()/10],32,16); displaypicture_12864(16,7,num16322[ReadSecond_1302()%10],32,16); } if(s%4==3) { displaypicture_12864(16,0,num16323[ReadHour_1302()/10],32,16); displaypicture_12864(16,1,num16323[ReadHour_1302()%10],32,16); if((ReadSecond_1302())%2==1){displaypicture_12864(17,2,num16323[10],32,16);} if((ReadSecond_1302())%2==0){displaypicture_12864(17,2,kong3216,32,16);} displaypicture_12864(16,3,num16323[ReadMinute_1302()/10],32,16); displaypicture_12864(16,4,num16323[ReadMinute_1302()%10],32,16); if((ReadSecond_1302())%2==1){displaypicture_12864(17,5,num16323[10],32,16);} if((ReadSecond_1302())%2==0){displaypicture_12864(17,5,kong3216,32,16);} displaypicture_12864(16,6,num16323[ReadSecond_1302()/10],32,16); displaypicture_12864(16,7,num16323[ReadSecond_1302()%10],32,16); } if(s%4==0) { displaypicture_12864(16,0,num16324[ReadHour_1302()/10],32,16); displaypicture_12864(16,1,num16324[ReadHour_1302()%10],32,16); if((ReadSecond_1302())%2==1){displaypicture_12864(17,2,num16324[10],32,16);} if((ReadSecond_1302())%2==0){displaypicture_12864(17,2,kong3216,32,16);} displaypicture_12864(16,3,num16324[ReadMinute_1302()/10],32,16); displaypicture_12864(16,4,num16324[ReadMinute_1302()%10],32,16); if((ReadSecond_1302())%2==1){displaypicture_12864(17,5,num16324[10],32,16);} if((ReadSecond_1302())%2==0){displaypicture_12864(17,5,kong3216,32,16);} displaypicture_12864(16,6,num16324[ReadSecond_1302()/10],32,16); displaypicture_12864(16,7,num16324[ReadSecond_1302()%10],32,16); } a=read_temp(); writecom_12864(0x98+5); writedat_12864(a%1000/100+0x30); writedat_12864(a%100/10+0x30 ); writedat_12864('.'); writedat_12864(a%10+0x30); displaypicture_12864(47,7,wd,16,16); displaypicture_12864(48,4,wdj,16,16); Conversion(Year,Month,Day); writecom_12864(0x98); if(month_moon==1) {display_12864(4,0,"正");} if(month_moon==2) {display_12864(4,0,"二");} if(month_moon==3) {display_12864(4,0,"三");} if(month_moon==4) {display_12864(4,0,"四");} if(month_moon==5) {display_12864(4,0,"五");} if(month_moon==6) {display_12864(4,0,"六");} if(month_moon==7) {display_12864(4,0,"七");} if(month_moon==8) {display_12864(4,0,"八");} if(month_moon==9) {display_12864(4,0,"九");} if(month_moon==10) {display_12864(4,0,"十");} if(month_moon==11) {display_12864(4,0,"冬");} if(month_moon==12) {display_12864(4,0,"腊");} display_12864(4,1,"月"); if(day_moon==1){display_12864(4,2,"初一");} if(day_moon==2){display_12864(4,2,"初二");} if(day_moon==3){display_12864(4,2,"初三");} if(day_moon==4){display_12864(4,2,"初四");} if(day_moon==5){display_12864(4,2,"初五");} if(day_moon==6){display_12864(4,2,"初六");} if(day_moon==7){display_12864(4,2,"初七");} if(day_moon==8){display_12864(4,2,"初八");} if(day_moon==9){display_12864(4,2,"初九");} if(day_moon==10){display_12864(4,2,"初十");} if(day_moon==11){display_12864(4,2,"十一");} if(day_moon==12){display_12864(4,2,"十二");} if(day_moon==13){display_12864(4,2,"十三");} if(day_moon==14){display_12864(4,2,"十四");} if(day_moon==15){display_12864(4,2,"十五");} if(day_moon==16){display_12864(4,2,"十六");} if(day_moon==17){display_12864(4,2,"十七");} if(day_moon==18){display_12864(4,2,"十八");} if(day_moon==19){display_12864(4,2,"十九");} if(day_moon==20){display_12864(4,2,"二十");} if(day_moon==21){display_12864(4,2,"廿一");} if(day_moon==22){display_12864(4,2,"廿二");} if(day_moon==23){display_12864(4,2,"廿三");} if(day_moon==24){display_12864(4,2,"廿四");} if(day_moon==25){display_12864(4,2,"廿五");} if(day_moon==26){display_12864(4,2,"廿六");} if(day_moon==27){display_12864(4,2,"廿七");} if(day_moon==28){display_12864(4,2,"廿八");} if(day_moon==29){display_12864(4,2,"廿九");} if(day_moon==30){display_12864(4,2,"三十");} keyscan(); if(knz==0) delayms(20); if(knz==0) { while(knz==0); n++; } if(n%2==1) { displaypicture_12864(0,5,nz,16,16); if(bellscan()==1) bell1(); } if(n%2==0) { displaypicture_12864(0,5,kong,16,16); } } }
复制代码https://mbb.eet-china.com/download/311171.html