完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
原版的哦,采用经典的1302程序,让大家理解起来不费力,只是引入了农历换算程序,还有就是用的Nokia 5110显示的,有18b20程序哦,带温度提醒功能,要是用12864显示,只需改变显示部分的程序即可,移植性还是挺强的哦,希望大家参考参考。有什么不足的请多多包涵
下面是主程序: //电子与信息工程学院创新实验室唐老鸭 //原创----川流不息 #include "rset_time.h" #include "ds18b02.h" uint temperature=0; //温度值 void tempremind() { temperature=readtemperature();//读温度 if(temperature<500){LCD_write_hanzi(10,0,temp,0);LCD_write_hanzi(12,0,temp,1);} else if((temperature>=500)&&(temperature<1000)){LCD_write_hanzi(10,0,temp,2);LCD_write_shu(11,0,11);LCD_write_shu(12,0,11);} else if((temperature>=1000)&&(temperature<1200)){LCD_write_hanzi(10,0,temp,3);LCD_write_hanzi(12,0,temp,2);} else if((temperature>=1200)&&(temperature<1400)){LCD_write_hanzi(8,0,temp,0);LCD_write_hanzi(10,0,temp,3);LCD_write_hanzi(12,0,temp,2);} else if((temperature>=1400)&&(temperature<1600)){LCD_write_hanzi(10,0,temp,3);LCD_write_hanzi(12,0,temp,4);} else if((temperature>=1600)&&(temperature<1800)){LCD_write_hanzi(8,0,temp,0);LCD_write_hanzi(10,0,temp,3);LCD_write_hanzi(12,0,temp,4);} else if((temperature>=1800)&&(temperature<2000)){LCD_write_hanzi(10,0,temp,3);LCD_write_hanzi(12,0,temp,5);} else if((temperature>=2000)&&(temperature<2200)){LCD_write_hanzi(10,0,temp,5);LCD_write_shu(11,0,11);LCD_write_shu(12,0,11);} else if((temperature>=2200)&&(temperature<2500)){LCD_write_shu(11,0,11);LCD_write_shu(12,0,11);LCD_write_hanzi(10,0,temp,6);} else if((temperature>=2500)&&(temperature<2800)){LCD_write_hanzi(10,0,temp,7);LCD_write_hanzi(12,0,temp,6);} else if((temperature>=2800)&&(temperature<3000)){LCD_write_hanzi(10,0,temp,8);LCD_write_hanzi(12,0,temp,6);} else if((temperature>=3000)&&(temperature<3500)){LCD_write_hanzi(10,0,temp,9);LCD_write_hanzi(12,0,temp,6);} else if((temperature>=3500)&&(temperature<3900)){LCD_write_hanzi(10,0,temp,10);LCD_write_hanzi(12,0,temp,6);} else {LCD_write_hanzi(10,0,temp,0);LCD_write_hanzi(10,0,temp,11);LCD_write_hanzi(12,0,temp,6);} } void display() { //第一行显示,调整的时候显示”正在设置:“ if(flag==0) { tempremind(); LCD_write_hanzi(0,0,hanzi,3);//温 LCD_write_hanzi(2,0,hanzi,4); // 度 LCD_write_shu(4,0,temperature/1000); LCD_write_shu(5,0,temperature%1000/100); LCD_write_hanzi(6,0,hanzi,0); //符号℃ } else { LCD_write_hanzi(0,0,hanzi,17); //正 LCD_write_hanzi(2,0,hanzi,18); //在 LCD_write_hanzi(4,0,hanzi,19);//设 LCD_write_hanzi(6,0,hanzi,20);// 置 LCD_write_shu(8,0,10); //冒号: switch(num) { case 1: LCD_write_hanzi(11,0,hanzi,14); break;//设置年 case 2: LCD_write_hanzi(11,0,hanzi,15); break;//设置月 case 3: LCD_write_hanzi(11,0,hanzi,7); break;//设置日 case 4: LCD_write_hanzi(10,0,hanzi,5); LCD_write_hanzi(12,0,hanzi,6); break;//设置星期 case 5: LCD_write_hanzi(11,0,hanzi,21); break;//设置年 case 6: LCD_write_hanzi(11,0,hanzi,22); break;//设置年 default : break; } } //显示第二行 LCD_write_shu(0,2,2);//2 LCD_write_shu(1,2,0);//0 LCD_write_shu(2,2,nian/10); LCD_write_shu(3,2,nian%10); LCD_write_hanzi(4,2,hanzi,14); //年 LCD_write_shu(6,2,yue/10); LCD_write_shu(7,2,yue%10); LCD_write_hanzi(8,2,hanzi,15); //月 LCD_write_shu(10,2,ri/10); LCD_write_shu(11,2,ri%10); LCD_write_hanzi(12,2,hanzi,7);//日 //第三行显示 LCD_write_hanzi(0,4,hanzi,5); //星 LCD_write_hanzi(2,4,hanzi,6); //期 LCD_write_hanzi(4,4,hanzi,xingqi+6); LCD_write_shu(6,4,shi/10); LCD_write_shu(7,4,shi%10); LCD_write_shu(8,4,10); //冒号: LCD_write_shu(9,4,fen/10); LCD_write_shu(10,4,fen%10); LCD_write_shu(11,4,10);//冒号: LCD_write_shu(12,4,miao/10); LCD_write_shu(13,4,miao%10); } void main() { LCD_init(); //初始化LCD模块 LCD_clear(); //清屏幕 //init_time(); flag=0; while(1) { if(flag==0) get_time();//读出时间 rset_time(); display(); } } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
请问一个迭代法图形二值化的程序代码把宽改成240之后整个屏幕不显示是什么原因?
2649 浏览 0 评论
2637 浏览 1 评论
1876 浏览 1 评论
2028 浏览 2 评论
2594 浏览 2 评论
684浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 18:21 , Processed in 0.440578 second(s), Total 45, Slave 37 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号