⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer_thermometer_12864.lst

📁 用单片机实现的温度检测 是整个电路的代码调试
💻 LST
📖 第 1 页 / 共 3 页
字号:
 170   1                      Left_Bytes_DaSend( 7, 48, p,8);                 
 171   1              }
 172          
 173          //显示"星期"在第三行
 174          void Display_LCD_5(void)
 175                  {
 176   1                      p=tabc;
 177   1                      p=p+80; Left_Bytes_DaSend( 2, 0, p,16);
 178   1                      p=p+16; Left_Bytes_DaSend( 3, 0, p,16);
 179   1                      p=p+16; Left_Bytes_DaSend( 2, 16, p,16);
C51 COMPILER V7.06   TIMER_THERMOMETER_12864                                               03/22/2007 10:01:19 PAGE 4   

 180   1                      p=p+16; Left_Bytes_DaSend( 3, 16, p,16);
 181   1              }
 182          //显示"温度C"
 183          void    Display_LCD_6(void)
 184                  {
 185   1                      p=tabd;
 186   1                      p=p+112;        Left_Bytes_DaSend( 4, 16, p,16);
 187   1                      p=p+16;         Left_Bytes_DaSend( 5, 16, p,16);
 188   1                      p=p+16;         Left_Bytes_DaSend( 4, 32, p,16);
 189   1                      p=p+16;         Left_Bytes_DaSend( 5, 32, p,16);
 190   1                      p=p+16;         Right_Bytes_DaSend( 4, 48, p,16);
 191   1                      p=p+16;         Right_Bytes_DaSend( 5, 48, p,16);               
 192   1              }
 193          //显示负号
 194          void    Display_LCD_7(void)
 195                  {
 196   1                      p=tabf;         Right_Bytes_DaSend( 4, 0, p,8);
 197   1                      p=p+8;          Right_Bytes_DaSend( 5, 0, p,8);
 198   1                              
 199   1              }
 200          //清除负号
 201          void    Display_LCD_8(void)
 202                  {
 203   1                      p=tabe;         Right_Bytes_DaSend( 4, 0, p,8);
 204   1                      p=p+8;          Right_Bytes_DaSend( 5, 0, p,8);
 205   1                              
 206   1              }
 207          //void DS18B20_Start (void)
 208          //unsigned long DS18B20_Tmp_Read()
 209          //温度转换程序
 210          unsigned char   Tmp_Convert(void)
 211                  {       
 212   1                      unsigned int    TMP_BUF;                //温度缓冲单元
 213   1                      unsigned char   TMP_SIGN;               //温度符号
 214   1                      TMP_BUF=DS18B20_Tmp_Read();
 215   1                      TMP_SIGN=(unsigned char)(TMP_BUF>>12);
 216   1                      if(TMP_SIGN)TMP_BUF=(~TMP_BUF)+1;                       
 217   1                      TMPBUF_MSB=(unsigned char)(TMP_BUF>>4); //取中间八位的值
 218   1                      TMPBUF_LSB=(unsigned char)(TMP_BUF&0x0f);//取低四位的值
 219   1                      TMPBUF_LSB=(TMPBUF_LSB*10)/16;                  //乘10除16相当于乘以0.625
 220   1                      if(TMP_SIGN)return      1;                                      //返回符号标志位
 221   1                              else    return  0;
 222   1              }
 223          //温度显示程序
 224          void    Tmp_Display(void)
 225                  {       unsigned char   tmpf,k,h,l;
 226   1                      tmpf=Tmp_Convert();                     //调用温度转换程序
 227   1                      if(TMPBUF_MSB>125){TMPBUF_MSB=0;Display_LCD_7();}
 228   1                      else    Display_LCD_8();        //负号消隐;
 229   1                      k=TMPBUF_MSB/100;               
 230   1                      h=(TMPBUF_MSB%100)/10;
 231   1                      l=(TMPBUF_MSB%100)%10;                                          
 232   1                      if(tmpf)        {Display_LCD_7();tmpf=0;}
 233   1                              else    Display_LCD_8();                                                        
 234   1                      if(k==0)        p=tabe;
 235   1                              else    p=taba;                         //高位为零则消隐
 236   1                      p=p+(k*16);                     Right_Bytes_DaSend(4, 8, p,8);
 237   1                      p=p+8;                          Right_Bytes_DaSend(5, 8, p,8);                  
 238   1                      if(k==0&&h==0)  p=tabe;
 239   1                              else    p=taba;                 
 240   1                      p=p+(h*16);                     Right_Bytes_DaSend(4, 16, p,8);
 241   1                      p=p+8;                          Right_Bytes_DaSend(5, 16, p,8);
C51 COMPILER V7.06   TIMER_THERMOMETER_12864                                               03/22/2007 10:01:19 PAGE 5   

 242   1                      p=taba;
 243   1                      p=p+(l*16);                     Right_Bytes_DaSend(4, 24, p,8);
 244   1                      p=p+8;                          Right_Bytes_DaSend(5, 24, p,8);
 245   1                      p=taba;
 246   1                      p=p+(TMPBUF_LSB*16);Right_Bytes_DaSend(4, 40, p,8);
 247   1                      p=p+8;                          Right_Bytes_DaSend(5, 40, p,8);         
 248   1                              
 249   1              }
 250          
 251          //LCD初始化程序
 252          void    LCD_Initializate(void)
 253                  {
 254   1                      Display_LCD_1();                        
 255   1                      Display_LCD_2();                                
 256   1                      Display_LCD_3();                                                                
 257   1                      Display_LCD_4();                        
 258   1                      Display_LCD_5();                                
 259   1                      Display_LCD_6();
 260   1                                                      }
 261          //LCD时间信息初始化
 262          void    LCD_DateTime_Initializate(void)
 263                  {       
 264   1                      DateTime_Display(pdt,0,1,0);
 265   1                      DateTime_Display(pdt,1,1,0);
 266   1                      DateTime_Display(pdt,2,1,0);
 267   1                      DateTime_Display(pdt,3,1,0);
 268   1                      DateTime_Display(pdt,4,1,0);
 269   1                      DateTime_Display(pdt,5,1,0);
 270   1                      DateTime_Display(pdt,6,1,0);    //初如化时间信息
 271   1                      Tmp_Display();
 272   1              }
 273          
 274          //读键程序
 275          
 276          unsigned char GetKey(void)
 277           {      unsigned int    i=0;    
 278   1              unsigned char   keybuf=0;
 279   1              if(P1!=0xff)
 280   1                      {
 281   2                                      keybuf=P1;
 282   2                                      if(keybuf!=0xff)
 283   2                                      {
 284   3                                                      while((P1==keybuf)&&(i<0x6000)) i+=1;                   
 285   3                                              if(i>101)             
 286   3                                                      { return keybuf;}  
 287   3                                              else return 0;
 288   3                                              }
 289   2                                      else return     0;                                      
 290   2                      }               
 291   1              else    return 0;                               
 292   1      }
 293          
 294          
 295          /*unsigned char GetKey(void)
 296           {      unsigned char i=0;
 297                  unsigned char keybuf=0;
 298           if(P1!=0x0ff)
 299               {keybuf=P1;
 300               while(P1==keybuf)  ++i;                    
 301               if(i>=20)             
 302                  return keybuf;   
 303                else
C51 COMPILER V7.06   TIMER_THERMOMETER_12864                                               03/22/2007 10:01:19 PAGE 6   

 304                 return 0;
 305                }
 306                  else    return 0;
 307          }*/
 308          
 309          
 310          
 311          //时间设置程序
 312          void    DateTime_SetUp(void)
 313                  {       
 314   1                      unsigned char   i,key,leaptmp,back=0,dtn=0;             //DTTMP number(dtn)为数组元素的序号,
 315   1                      unsigned int    yeartmp;
 316   1                      for(i=0;i<7;i++)
 317   1                      DTTMP[i]=DTBUF[i];      //将DTBUF内的数据调入DTTMP中进行操作
 318   1                      pdt=DTTMP;                      //pointer setup
 319   1                      dp=0xff;                        //关中断中的显示调用,显示的控制权由此函数掌握
 320   1                      MSFLAG=20;
 321   1                      while((back==0)&&(MSFLAG!=0))           
 322   1                              {       
 323   2                                      DateTime_Display(pdt,dtn,secf,0);//void DateTime_Display(unsigned char *arrayp,unsigned char sn,unsign
             -ed char fl,unsigned char k)           
 324   2                                      key=GetKey();
 325   2                      if(key!=0)
 326   2                              {       if(key==LEFT)
 327   3                                              {DateTime_Display(pdt,dtn,1,0);
 328   4                                              if(dtn==0)      dtn=6;
 329   4                                              else dtn=dtn-1;MSFLAG=20;}
 330   3                                      else if(key==RIGHT)
 331   3                                              {DateTime_Display(pdt,dtn,1,0);
 332   4                                                      if(dtn==6)      dtn=0;
 333   4                                              else dtn=dtn+1;MSFLAG=20;}
 334   3                                      else if(key==UP)
 335   3                                              {if(dtn==0)
 336   4                                                      if(DTTMP[dtn]==99)      DTTMP[dtn]=0;
 337   4                                                      else    DTTMP[dtn]+=1;  
 338   4                                              else if(dtn==1)
 339   4                                                      if(DTTMP[dtn]==12)      DTTMP[dtn]=1;
 340   4                                                      else    DTTMP[dtn]+=1;                  
 341   4                                              else if(dtn==2)
 342   4                                                      { yeartmp=DTTMP[dtn-2]+2000;
 343   5                               if((yeartmp%4==0&&yeartmp%100!=0)||(yeartmp%400==0)) leaptmp=1;
 344   5                                                                      else leaptmp=0;                                                 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -