- /**********Nokia 5110 LCD 显示程序***************/
- /**********作者:郑文 ***************/
- /**********芯片:AT89S52 **************/
- /*功能:支持中文显示、字符显示、图片显示********/
- #include
- #include
- #include "english_6x8_pixel.h"
- #include "picture84x48.h"
- #include "Nokia_5110.h"
- #include "18b20.h"
- #define uchar unsigned char
- #define uint unsigned int
- uchar tem_h,tem_l,tem_f,tem_f1,tem_f2;
- uint tem; //温度读取后*10后存储空间地址
- float tem_read; //温度读取保存地址空间
- void Delay1ms(unsigned int count);
- void temperature_read_charge(void);
- void nokia_5110_picture();//写一屏图
- /************毫秒延时程序********************/
- void Delay1ms(unsigned int count)
- {
- unsigned int i,j;
- for(i=0;i for(j=0;j<120;j++);
- }
- /********************************************/
- /*void temperature_read_charge(void)
- {
- tem_read=ReadTemperature();
- tem=tem_read*1000; //温度精确到小数点后3位
- tem_h=tem/10000+0x30; //温度高位
- tem_l=( tem-(tem_h-0x30)*10000 )/1000+0x30; //温度低位
- tem_f=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000 )/100+0x30;
- tem_f1=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000-(tem_f-0x30)*100 )/10+0x30;
- tem_f2=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000-(tem_f-0x30)*100-(tem_f1-0x30)*10 )+0x30;
- Delay1ms(100);
- }
- */
- /**********************************************/
- void nokia_5110_picture()//写一屏图
- {
- uchar e;
- uchar t;
- uchar k;
- uint d;
- d=0;
- for(t=0;t<6;t++)
- {
- for(k=0;k<84;k++)
- {
- e=dal[d];
- write_byte(e,1);
- d=d+1;
- }
- }
- }
- /**************************************/
- /*****************主程序********************/
- void main(void)
- {
- unsigned main_i,x,y;
- unsigned xnum ,ynum;
- float T_temp;
- uchar i;
- uchar moni_temp;
- P2=0X00;
- LED_A =1;
- LCD_VDD =1;
- LCD_GND =0;
- LCD_Init(); //初始化液晶
- LCD_Clear();
- /***********指定地址显示汉字(x,y,table)*********************/
- /***********取点(x,y,byte数据)*************/
- /*其中X=[0,83] Y=[0,5] byte 显示是从下到上 */
- nokia_5110_picture();
- LCD_set_XY(42,3);
- LCD_write_char(124);
- LCD_write_char('C');
- /* while(1)
- {
- for(i=0;i<8;i++)
- {
- LCD_set_XY(68,4);
- LCD_write_char(125+i);
- Delay1ms(100);
- }
- for(i=0;i<8;i++)
- {
- LCD_set_XY(68,3);
- LCD_write_char(125+i);
- Delay1ms(100);
- }
- for(i=0;i<8;i++)
- {
- LCD_set_XY(68,2);
- LCD_write_char(125+i);
- Delay1ms(100);
- }
- for(i=0;i<8;i++)
- {
- LCD_set_XY(68,1);
- LCD_write_char(125+i);
- Delay1ms(100);
- }
- for(i=0;i<8;i++)
- {
- LCD_set_XY(68,0);
- LCD_write_char(125+i);
- Delay1ms(100);
- }
- LCD_set_XY(68,0);
- LCD_write_char(125);
- LCD_set_XY(68,1);
- LCD_write_char(125);
- LCD_set_XY(68,2);
- LCD_write_char(125);
- LCD_set_XY(68,3);
- LCD_write_char(125);
- LCD_set_XY(68,4);
- LCD_write_char(125);
- }*/
- while(1)
- {
- /********温度数据的读取和转换*************/
- tem_read=ReadTemperature();
- tem=tem_read*1000; //温度精确到小数点后一位08.1.8
- tem_h=tem/10000+0x30; //温度高位
- tem_l=( tem-(tem_h-0x30)*10000 )/1000+0x30; //温度低位
- tem_f=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000 )/100+0x30;
- tem_f1=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000-(tem_f-0x30)*100 )/10+0x30;
- tem_f2=( tem-(tem_h-0x30)*10000-(tem_l-0x30)*1000-(tem_f-0x30)*100-(tem_f1-0x30)*10 )+0x30;
- //Delay1ms(5);
- LCD_set_XY(12,3);
- LCD_write_char(tem_h);
- // Delay1ms(5);
- LCD_write_char(tem_l);
- // Delay1ms(5);
- LCD_write_char('.');
- // Delay1ms(5);
- LCD_write_char(tem_f);
- // Delay1ms(5);
- LCD_write_char(tem_f1);
- //Delay1ms(5);
- moni_temp=((tem_h-0x30)*10+tem_l-0x30)+1;//加1是修正值
- if(moni_temp>0 && moni_temp<8)
- {
- LCD_set_XY(68,3);
- LCD_write_char(125);
- LCD_set_XY(68,2);
- LCD_write_char(125);
- LCD_set_XY(68,1);
- LCD_write_char(125);
- LCD_set_XY(68,0);
- LCD_write_char(125);
- LCD_set_XY(68,4);
- LCD_write_char(125+moni_temp);
- }
- else if(moni_temp>=8 && moni_temp<16)
- {
- LCD_set_XY(68,2);
- LCD_write_char(125);
- LCD_set_XY(68,1);
- LCD_write_char(125);
- LCD_set_XY(68,0);
- LCD_write_char(125);
- LCD_set_XY(68,4);
- LCD_write_char(132);
- LCD_set_XY(68,3);
- LCD_write_char(125+moni_temp-8);
- }
- else if(moni_temp>=16 && moni_temp<24)
- {
- LCD_set_XY(68,1);
- LCD_write_char(125);
- LCD_set_XY(68,0);
- LCD_write_char(125);
- LCD_set_XY(68,4);
- LCD_write_char(132);
- LCD_set_XY(68,3);
- LCD_write_char(132);
- LCD_set_XY(68,2);
- LCD_write_char(125+moni_temp-16);
- }
- else if(moni_temp>=24 && moni_temp<32)
- {
- LCD_set_XY(68,0);
- LCD_write_char(125);
- LCD_set_XY(68,4);
- LCD_write_char(132);
- LCD_set_XY(68,3);
- LCD_write_char(132);
- LCD_set_XY(68,2);
- LCD_write_char(132);
- LCD_set_XY(68,1);
- LCD_write_char(125+moni_temp-24);
- }
- else if(moni_temp>=32 && moni_temp<40)
- {
- LCD_set_XY(68,4);
- LCD_write_char(132);
- LCD_set_XY(68,3);
- LCD_write_char(132);
- LCD_set_XY(68,2);
- LCD_write_char(132);
- LCD_set_XY(68,1);
- LCD_write_char(132);
- LCD_set_XY(68,0);
- LCD_write_char(125+moni_temp-32);
- }
- else
- {;}
- }
- }
|