lcd.lst

来自「c8051f020模块.rar」· LST 代码 · 共 565 行 · 第 1/2 页

LST
565
字号
 267   1      }
 268          
 269          
 270          void lcd_zifu(uint8 x0,uint8 page,uint8 width)  //单个字符显示
 271          {
 272   1        uint8 x,i=0;
 273   1        
 274   1      for (x=x0+1;x<x0+width+1;x++)    //起始列地址x0,页地址page,数据宽度width
 275   1       {
 276   2              
 277   2          // 一次显示两页
 278   2          
 279   2          lcd_MC(0xB0|page);             //设置页地址    
 280   2          lcd_MC(((x>>4)&0x0f)|0x10);    // 设置列地址高位
 281   2          lcd_MC(x&0x0F);                // 设置列地址低位
 282   2          lcd_MD(num[j][i]);             // 画上层 
 283   2            
 284   2          lcd_MC(0xB0|(page-1));         //设置页地址
 285   2          lcd_MC(((x>>4)&0x0f)|0x10);    // 设置列地址高位
 286   2          lcd_MC(x&0x0F);               //设置列地址低位   
 287   2          lcd_MD(num[j][i+width]);              // 画下层 
 288   2          i++;
 289   2        }
 290   1      }
 291          
 292          
 293          void lcd_hanzichuan(uint8 s,uint8 y,uint8 k)   //一页汉字显示
 294          {
 295   1        uint8 i=0;
 296   1        for(i=0;i<1;i++)
 297   1          {  lcd_hanzi((s+i*k),y,k); j++;   }
 298   1      }
 299          
 300          
 301          void lcd_zifuchuan(uint8 s,uint8 y,uint8 k)   //一页字符显示
 302          {
 303   1        uint8 i=0;
C51 COMPILER V8.02   LCD                                                                   09/01/2009 17:41:50 PAGE 6   

 304   1        for(i=0;i<1;i++)
 305   1          {  lcd_zifu((s+i*k),y,k); j++;   }
 306   1      }
 307          
 308          
 309          
 310          
 311          
 312          
 313          /*******************************************************
 314          //  划竖直线
 315          //  dat1:起点    dat2:终点  画图是从dat2向dat1
 316          //  VOL:列地址
 317          ***********************************************************/
 318          void DrawLine(unsigned int dat1,unsigned int dat2,unsigned int VOL)      //VOL从1~128,画竖线时dat1和dat2从1~6
             -4,画横线时dat1和dat2从0~63
 319          {
 320   1        unsigned int DM,numb,m,FP,PP; 
 321   1        uint8 LCD_VL,LCD_VH;
 322   1        uint8 LCD_D;
 323   1        uint8 LCD_L;
 324   1      
 325   1        LCD_VH=VOL/16;
 326   1        LCD_VL=VOL%16; 
 327   1        numb=0;   
 328   1        
 329   1        DM=dat2-dat1;   
 330   1        PP=dat2/8;   
 331   1        LCD_L=dat2%8;
 332   1        FP=dat2/8; 
 333   1        
 334   1        LCD_D=0x00;
 335   1      if(DM>0)
 336   1      {  
 337   2        for(numb=0;numb<DM;)
 338   2        {    
 339   3          
 340   3          if(PP==FP)
 341   3          {      
 342   4            LCD_D=0x00;
 343   4            for(m=(8-LCD_L);m<8;m++)
 344   4            {
 345   5              if(numb<DM+1)
 346   5              {
 347   6                LCD_D|=0x01<<m;          
 348   6                numb++;                    
 349   6              }        
 350   5            }
 351   4           //LcdNumbers(2,LCD_D,3,0);
 352   4            lcd_MC(0x40|0);    //start line
 353   4            lcd_MC(0xB0|YE[PP]);
 354   4            lcd_MC(0x10|LCD_VH);  //高lie
 355   4            lcd_MC(LCD_VL);   //dilie      
 356   4            lcd_MD(LCD_D);
 357   4            if(PP>0){ PP--;}          
 358   4          }     
 359   3          else
 360   3          {      
 361   4            LCD_D=0x00;
 362   4            for(m=0;m<8;m++)
 363   4            {
 364   5              if(numb<DM+1)
C51 COMPILER V8.02   LCD                                                                   09/01/2009 17:41:50 PAGE 7   

 365   5              {
 366   6                LCD_D|=0x01<<m;          
 367   6                numb++;         
 368   6              }      
 369   5            }      
 370   4            lcd_MC(0x40|0);    //start line
 371   4            lcd_MC(0xB0|YE[PP]);
 372   4            lcd_MC(0x10|LCD_VH);  //高lie
 373   4            lcd_MC(LCD_VL);   //dilie 
 374   4            lcd_MD(LCD_D);
 375   4           // LcdNumbers(2,LCD_D,3,0);     
 376   4            if(PP>0) {PP--;}
 377   4          }   
 378   3        }
 379   2      }
 380   1      if(DM==0)
 381   1      {
 382   2        LCD_D=0x00;
 383   2        lcd_MC(0x40|0);    //start line
 384   2        lcd_MC(0xB0|YE[PP]);
 385   2        lcd_MC(0x10|LCD_VH);  //高lie
 386   2        lcd_MC(LCD_VL);   //dilie 
 387   2        LCD_D|=0x01<<(7-LCD_L);
 388   2        lcd_MD(LCD_D);
 389   2        
 390   2      }
 391   1      } 
 392          
 393          void Lcd_DrawCur(void){
 394   1      int num,k,z;
 395   1      uint8 dat1,dat2;
 396   1      unsigned int temp,temp1,temp2;//,dat1,dat2;      //temp1:向前比较;temp2:向后比较;dat1:为该列的起始行;dat
             -2:为该列的终止行
 397   1       
 398   1      
 399   1      //for(k=0;k<6;k++)
 400   1      for(k=0;k<8;k++)
 401   1      {
 402   2        for(num=0;num<16;num++)
 403   2        {
 404   3          
 405   3          z=num+16*k;
 406   3          
 407   3          if(z==0)                 //只要画与后面的比较;取两点的中点作为连线的标准
 408   3          {
 409   4            temp=DrawCur[z];
 410   4            temp2=DrawCur[z+1];
 411   4            if(temp>=temp2)
 412   4            { 
 413   5              dat1=temp-(temp-temp2)/2;
 414   5              dat2=temp; 
 415   5            }
 416   4            if(temp<temp2)
 417   4            {
 418   5              dat1=temp;
 419   5              dat2=temp+(temp2-temp)-(temp2-temp)/2;
 420   5            }
 421   4          }
 422   3          //if(z==95)
 423   3              if(z==127)
 424   3          {
 425   4            temp=DrawCur[z];
C51 COMPILER V8.02   LCD                                                                   09/01/2009 17:41:50 PAGE 8   

 426   4            temp1=DrawCur[z-1];
 427   4            if(temp>=temp1)
 428   4            {
 429   5              dat1=temp-(temp-temp1)/2;
 430   5              dat2=temp;
 431   5            }
 432   4            if(temp<temp1)
 433   4            {
 434   5              dat1=temp;
 435   5              dat2=temp+(temp1-temp)-(temp1-temp)/2;
 436   5            }
 437   4          }
 438   3         // if((z>0)&&(z<95))
 439   3              if((z>0)&&(z<127))
 440   3          {
 441   4            temp1=DrawCur[z-1];
 442   4            temp=DrawCur[z];
 443   4            temp2=DrawCur[z+1];
 444   4            if((temp>=temp1)&&(temp>=temp2))
 445   4            {
 446   5              dat2=temp;
 447   5              if(temp1>=temp2)
 448   5              {
 449   6                dat1=temp-(temp-temp2)/2;          
 450   6              }
 451   5              else
 452   5              {
 453   6                
 454   6                dat1=temp-(temp-temp1)/2;
 455   6              }
 456   5            }
 457   4            if((temp<temp1)&&(temp<temp2))
 458   4            {
 459   5              dat1=temp;
 460   5              if(temp1>=temp2)
 461   5              {
 462   6                dat2=temp+(temp1-temp)-(temp1-temp)/2;
 463   6              }
 464   5              else
 465   5              {
 466   6                dat2=temp+(temp2-temp)-(temp2-temp)/2;
 467   6              }
 468   5            }
 469   4            if((temp>=temp1)&&(temp<temp2))
 470   4            {
 471   5             dat1=temp-(temp-temp1)/2;
 472   5             dat2=temp+(temp2-temp)-(temp2-temp)/2;
 473   5            }
 474   4            if((temp<temp1)&&(temp>=temp2))
 475   4            {
 476   5              dat1=temp-(temp-temp2)/2;
 477   5              dat2=temp+(temp1-temp)-(temp1-temp)/2;
 478   5            }
 479   4          }    
 480   3      
 481   3           DrawLine(dat1,dat2,z);
 482   3         // LcdNumbers(2,num,3,0);
 483   3          
 484   3          
 485   3        }    
 486   2        }
 487   1         
C51 COMPILER V8.02   LCD                                                                   09/01/2009 17:41:50 PAGE 9   

 488   1      } 
 489             
 490          
 491          
 492          
 493          void main(void)
 494          {
 495   1        uint8 i,j=43;
 496   1      
 497   1        WDTCN = 0xde;
 498   1        WDTCN = 0xad;//关闭看门狗
 499   1        Init_SYSCLK();
 500   1        Init_PORT();
 501   1        LcdIni();
 502   1      
 503   1        for(i=0;i<128;i++)
 504   1        {
 505   2          DrawCur[i]=j;
 506   2          j++;
 507   2              if(j==46)
 508   2              j=40;
 509   2        }
 510   1      
 511   1        while(1)
 512   1        {
 513   2               Lcd_DrawCur();
 514   2      
 515   2      
 516   2      
 517   2      
 518   2      
 519   2        
 520   2        }
 521   1      
 522   1      
 523   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1681    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   2176    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      9      41
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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