shu[]={0x00,0x00,0x40,0x5F,0x55,0x55,0xF5,0x55,0x55,0x55,0xD5,0x5F,0x40,0x00,0x00,0x00,0x11,0x
11,0x09,0x09,0xFD,0x55,0x57,0x57,0x55,0x55,0x55,0xFD,0x01,0x01,0x01,0x00};//暑
const unsigned char
bao[]={0x40,0x20,0xF8,0x17,0x82,0x80,0xBE,0xA2,0xA2,0xE2,0xA2,0xA2,0xBE,0x80,0x80,0x00,0x00,
0x00,0x7F,0x00,0x20,0x10,0x08,0x06,0x01,0x7F,0x03,0x0C,0x18,0x30,0x10,0x00};//保
const unsigned char
nuan[]={0x00,0xFC,0x44,0x44,0xFC,0x80,0xA6,0xAA,0xE2,0xA6,0xAA,0xA1,0xA9,0xA5,0x80,0x00,0x0
0,0x0F,0x04,0x04,0x4F,0x20,0x58,0x46,0x27,0x2A,0x12,0x1A,0x26,0x62,0x20,0x00};//暖
const unsigned char
nononono[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//
const unsigned char
danwei_c[]={0x00,0x02,0x05,0xE2,0x18,0x04,0x02,0x02,0x02,0x02,0x02,0x02,0x04,0x1E,0x00,0x00,0x
00,0x00,0x00,0x07,0x18,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x18,0x00,0x00};//单位
const unsigned char
maohao[]={0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00};//':'
const unsigned char
dian[]={0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00};//'.'
const unsigned
char dw[]={0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00};//?
W'
const unsigned char
uu[]={0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20};//'u'
const unsigned char
jj[]={0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00};//'j'
const unsigned char
ii[]={0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00};//'i'
const unsigned char
ee[]={0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00};//'e'
const unsigned char
ff[]={0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00};//'f'
const unsigned char
ll[]={0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00};//'l'
const unsigned char
aa[]={0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20};//'a'
const unsigned char
ss[]={0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00};//'s'
const unsigned char
hh[]={0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20};//'h'
const unsigned char
vv[]={0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00};//'v'
const unsigned char
zhenghao1[]={0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00};
//'+'
const unsigned char
fuhao1[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01};//'-'
const unsigned char
xinghao[]={0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00};//\
const unsigned char
s1[]={0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00};//'1'
const unsigned char
s0[]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00};//'0'
const unsigned char
s2[]={0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00};/*\
const unsigned
char s3[]={0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00};/*\
\
const unsigned char
s4[]={0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00};/*\
const unsigned char
s5[]={0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00};/*\
const unsigned char
s6[]={0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00};/*\
const unsigned char
s7[]={0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00};/*\
const unsigned char
s8[]={0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00};/*\
const unsigned
char s9[]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00};/*\
\
const unsigned char
nono[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//空的
const unsigned char
juhao[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00};//'.'
const unsigned char
zhenghao[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x0
0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//'+'
const unsigned char
fuhao[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0
0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//'-'
const unsigned char
ss0[]={0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x40,0x40,0x40,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFE,0x0F,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0xFE,0xF0,0x00,0x00,0x00,0x1F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0x1F,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x0
6,0x04,0x04,0x04,0x06,0x03,0x01,0x00,0x00,0x00};//0
const unsigned char
ss1[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x0
6,0x07,0x07,0x06,0x04,0x04,0x04,0x00,0x00,0x00};//1
const unsigned char
ss2[]={0x00,0x00,0x00,0x00,0x80,0x40,0x40,0x40,0x40,0x40,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1E,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC1,0x7F,0x3E,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x07,0x06,0x06,0x06,0x0
6,0x06,0x06,0x06,0x06,0x06,0x07,0x01,0x00,0x00};//2
const unsigned char
ss3[]={0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x40,0x40,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x80,0x80,0x80,0xC0,0x61,0x3F,0x1E,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0xFE,0x78,0x00,0x00,0x00,0x00,0x01,0x03,0x02,0x04,0x0
4,0x04,0x04,0x04,0x02,0x03,0x01,0x00,0x00,0x00};//3
const unsigned char
ss4[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x30,0x0C,0x02,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x10,0x1C,0x12,0x11,0x10,0x10,0x10,0x10,0xFF,0xFF,0xFF,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0
8,0x08,0x08,0x0F,0x0F,0x0F,0x08,0x08,0x08,0x00};//4
const unsigned char
ss5[]={0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0xF8,0x87,0x40,0x20,0x20,0x20,0x20,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0xE0,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x7E,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x04,
0x04,0x04,0x04,0x04,0x02,0x03,0x01,0x00,0x00,0x00};//5
const unsigned char
ss6[]={0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x40,0x40,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0x0E,0x81,0x80,0x40,0x40,0x40,0x40,0xC0,0x83,0x03,0x00,0x00,0x00,0x00,0x3F,0xFF,0xC3,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x7E,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x
06,0x04,0x04,0x04,0x04,0x02,0x03,0x01,0x00,0x00};//6
const unsigned char
ss7[]={0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x0F,0x03,0x01,0x00,0x00,0x00,0x80,0x60,0x18,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//7
const unsigned char
ss8[]={0x00,0x00,0x00,0x00,0x80,0xC0,0x40,0x40,0x40,0x40,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x3F,0x71,0xE0,0xC0,0x80,0x80,0x80,0x80,0x61,0x3F,0x1E,0x00,0x00,0x00,0xF8,0xFC,0x06,0x03,0x01,0x00,0x01,0x01,0x03,0x07,0x0E,0xFC,0xF8,0x00,0x00,0x00,0x00,0x01,0x03,0x02,0x04,0x
04,0x04,0x04,0x04,0x02,0x03,0x01,0x00,0x00,0x00};//8
const unsigned char
ss9[]={0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x40,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFF,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0xFE,0xF8,0x00,0x00,0x00,0x00,0x81,0x83,
0x06,0x04,0x04,0x04,0x04,0x02,0x83,0xF1,0x7F,0x0F,0x00,0x00,0x00,0x00,0x03,0x03,0x04,0x04,0x0
4,0x04,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00};//9
const unsigned char
nonono[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//9
const unsigned char
danwei_c1[]={0x00,0x00,0x00,0x00,0x00,0xE0,0x10,0x10,0x10,0xF0,0x00,0x00,0x00,0x80,0xc0,0x60,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0xfC,0xff,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x7f,0xf0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x
00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03};//℃
const unsigned char
danwei_c2[]={0x30,0x30,0x10,0x10,0x10,0x20,0x20,0x20,0x40,0x80,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x0
6,0x06,0x02,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00};
/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
////////////////////////基本子函数///////////////////////
//延时
void delay(char x,char y)
{ char z; do{ z=y; do{;}while(--z); }while(--x);
}
//其指令时间为:7+(3*(Y-1)+7)*(X-1)如果再加上函数调用的call 指令、页面设定、传递参数花掉
的7 个指令。
//则是:14+(3*(Y-1)+7)*(X-1)。
//--------------------------------------------------
//系统初始化函数 void init()
{
ADCON1=0X07; //设置A口为普通数字口 TRISA=0X00; //设置A口方向为输出 TRISD=0X00; //设置D口方向为输出
}
//-----------------------------------------------
//复位DS18B20函数(*一定要注意延时,我曾经在这上差点搞晕*)
reset(void)
{
char presence=1; while(presence)
{
DQ_LOW() ; //主机拉至低电平 delay(2,90); //延时>480503us
DQ_HIGH(); //释放总线等电阻拉高总线,并保持15~60us
delay(2,8); //延时>60us
if(DQ==1) presence=1; //没有接收到应答信号,继续复位
else presence=0; //接收到应答信号 delay(2,70); //延时>240us
} }
//-----------------------------------------------
//写18b20写字节函数 void write_byte(uch val)
{ uch i; uch temp; for(i=8;i>0;i--)
{
temp=val&0x01; //最低位移出
DQ_LOW(); NOP(); NOP(); NOP(); NOP();
NOP(); //从高拉至低电平,产生写时间隙 if(temp==1) DQ_HIGH(); //如果写1,拉高电平
delay(2,7); //延时>60us
DQ_HIGH(); NOP(); NOP();
val=val>>1; //右移一位
} }
//------------------------------------------------
//18b20读字节函数 uch read_byte(void)
{