#include<reg52.h>
#include<intrins.h>
sbit rs = P2^6;
sbit rw = P2^5;
sbit ep = P2^7;
sbit DQ = P3^7;
sbit HT_motor = P1^0;
sbit LT_motor = P1^1;
sbit H_alarm = P1^2;
sbit normal = P1^3;
sbit L_alarm = P1^4;
sbit key_add1 = P2^0;
sbit key_add10= P2^1;
sbit key_dec1 = P2^2;
sbit key_dec10= P2^3;
float temper;
#define delay1us _nop_();
#define delay5us {_nop_();_nop_();_nop_();_nop_();_nop_();}
#define delay15us {delay5us;delay5us;delay5us;}
#define delay45us {delay15us;delay15us;delay15us;}
#define delay60us {delay15us;delay15us;delay15us;delay15us;}
#define delay480us {delay60us;delay60us;delay60us;delay60us;delay60us;delay60us;delay60us;delay60us;}
unsigned char display1[10]={"0123456789"};
unsigned char display2[2]={'.','-'};
unsigned char display3[20]={"Current_Wendu"};
unsigned char display4[20]={"set_lowerwendu"};
unsigned char display5[20]={"set_upperwendu"};
unsigned int tempreture_nuber,tempreture_dot;
unsigned char th_byte;
unsigned char tl_byte;
unsigned int tempreture_int;
unsigned int upper_temperature=40;
unsigned int lower_temperature=10;
unsigned int set_flag = 0;
void delay(unsigned int ms_count)
{
unsigned int k;
while(ms_count--)
{
for(k=0;k<250;k++)
{
_nop_();_nop_();_nop_();_nop_();
}
}
}
void waibuzhongduan_init()
{
EA = 1;
EX0=1;
IT0=1;
PX0=1;
}
bit lcd1602_busytest()
{
bit result;
rs = 0;
rw = 1;
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
result=(P0&0x80);
ep = 0;
return result;
}
void lcd1602_write_comdand(unsigned char write_data)
{
while(lcd1602_busytest());
rs = 0;
rw = 0;
ep = 0;
_nop_();
_nop_();
P0 = write_data;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 0;
}
void lcd1602_write_address(unsigned char address_data)
{
lcd1602_write_comdand(address_data|0x80);
}
void lcd1602_write_data(unsigned char display_data)
{
while(lcd1602_busytest());
rs = 1;
rw = 0;
ep = 0;
P0 = display_data;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 0;
}
void lcd1602_init()
{
delay(15);
lcd1602_write_comdand(0x38);
delay(5);
lcd1602_write_comdand(0x38);
delay(5);
lcd1602_write_comdand(0x38);
delay(5);
lcd1602_write_comdand(0x0c);
delay(5);
lcd1602_write_comdand(0x06);
delay(5);
lcd1602_write_comdand(0x38);
delay(5);
}
链接:https://pan.baidu.com/s/1-NLch_3mhFdbYPBocw_XOw 提取码:om3g
|