void display_temp(unsigned char add, unsigned short dat)//ÏòLCDD′ζèêy¾Y,2¢Ö¸¶¨ÏÔê¾Î»ÖÃ
{ unsigned char gw,sw,xw,a,sign;
if(dat&0xf800)
{ sign=1;
dat=~dat;
dat+=1;
}
else sign=0;
a=dat&0x0f;
xw=ditab[a];
dat>>=4;
gw=dat%10;//è¡μøöλêy×Ö
sw=(dat/10)%10;//è¡μÃê®Î»êy×Ö
write_1602com(add);
if(sw) write_1602dat(0x30+sw);//10μÃμ½¸Ãêy×ÖμÄLCD1602ÏÔê¾Âë
else write_1602dat(' ');
if(sign)
{ write_1602com(add);
write_1602dat('-');
}
if(sw&&sign)
{ write_1602com(add-1);
write_1602dat('-');
write_1602dat(0x30+sw);
}
write_1602dat(0x30+gw);//μÃμ½¸Ãêy×ÖμÄLCD1602ÏÔê¾Âë
write_1602dat('.'); //
write_1602dat(0x30+xw); //xiaoshuwei
write_1602dat(0xdf);//ÏÔê¾Î¶èμÄD¡Ô2è|·ûoÅ£¬0xdfêÇòo¾§Æá×Ö·û¿aμĸ÷ûoÅμØÖ·Âë
write_1602dat('C'); //ÏÔê¾"C"·ûoÅ£¬0x43êÇòo¾§Æá×Ö·û¿aàï′óD′CμÄμØÖ·Âë
}
以上18b20的代码在LCD1602上显示数值可以供参考, |