#include
typedefunsigned int uint;
typedef unsigned charuchar;
本文引用地址:http://m.butianyuan.cn/article/201611/322561.htmsbit LCD_RS=P2^0;
sbit LCD_RW=P2^1;
sbit LCD_EN=P2^2;
sbit DQ=P3^4;
uchar Temp_Value[]={0x00,0x00};
uchar Temp=0;
uchar Display_Digit[]={0,0,0,0};
bit DS18B20_IS_OK=1;
uchar code df_tab[]={0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,9};//decimal fraction
uchar code Display_LINE0[]={" Current Temp:"};
uchar Display_LINE1[]={" Temp:"};
void _delay_ms(unsigned int x)
{
unsigned char i;
while(x--)
{
for(i=0;i<125;i++);
}
}
void _delay_us(uint x)
{
while(--x);
}
bit LCD_Busy(void)//測(cè)忙
{
bit LCD_Status;//返回值變量
LCD_RS=0;//讀取狀態(tài)
LCD_RW=1;
LCD_EN=1;
_nop_();_nop_();_nop_();_nop_();
LCD_Status=(bit)(P0&0x80);
LCD_EN=0;
return LCD_Status;
}
void LCD_Write_Command(uchar cmd)//寫指令
{
while(LCD_Busy());
LCD_RS=0;//
LCD_RW=0;
LCD_EN=0;
_nop_();_nop_();
P0=cmd;
_nop_();_nop_();_nop_();_nop_();
LCD_EN=1;
_nop_();_nop_();_nop_();_nop_();
LCD_EN=0;
}
void LCD_Write_Data(uchar dat)//寫數(shù)據(jù)
{
while(LCD_Busy());//每次寫數(shù)據(jù)操作之前均需要檢測(cè)忙信號(hào)
LCD_RS=1;
LCD_RW=0;
LCD_EN=0;
P0=dat;
_nop_();_nop_();_nop_();_nop_();
LCD_EN=1;
_nop_();_nop_();_nop_();_nop_();
LCD_EN=0;
}
void Init_LCD(void)//液晶初始化
{
_delay_ms(15);//延時(shí)15MS
LCD_Write_Command(0x38);
_delay_ms(5);
LCD_Write_Command(0x38);
_delay_ms(5);
LCD_Write_Command(0x38);//以后每次寫指令操作之前均需要檢測(cè)忙信號(hào)
while(LCD_Busy());
_delay_ms(5);
LCD_Write_Command(0x01);//清屏
while(LCD_Busy());
_delay_ms(5);
LCD_Write_Command(0x38);//設(shè)置16*2顯示,5*7點(diǎn)陣,8位數(shù)據(jù)接口
_delay_ms(5);
while(LCD_Busy());
LCD_Write_Command(0x0c);//開顯示,不顯示光標(biāo)
_delay_ms(5);
while(LCD_Busy());
LCD_Write_Command(0x06);//當(dāng)讀或?qū)懸粋€(gè)字符后地址指針加一,且光標(biāo)加一
}
void LCD_POS(uchar pos)//字符顯示位置
{
LCD_Write_Command(0x80|pos);
}
void Show_String(uchar *str)//顯示字符串
{
while(*str!=