Nokia 5110_DS18B20顯示程序
/**********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
}
/********************************************/
/*void temperature_read_charge(void)
{
tem_read=ReadTemperature();
tem=tem_read*1000; //溫度精確到小數(shù)點后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數(shù)據(jù))*************/
/*其中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)
{
/********溫度數(shù)據(jù)的讀取和轉換*************/
tem_read=ReadTemperature();
tem=tem_read*1000; //溫度精確到小數(shù)點后一位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
{;}
}
}
評論