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

📄 fm12864.lst

📁 用AT89C51写的程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 235   1              line |= 0xb8; //1011 1xxx
 236   1              SendCommandToLCD(line);
 237   1      }
 238          //设定列地址--Y 0-63
 239          void SetColumn(uchar column)
 240          {
 241   1              column &= 0x3f; // 0=<column<=63
 242   1              column |= 0x40; //01xx xxxx
 243   1              SendCommandToLCD(column);
 244   1      }
 245          //设定显示开始行--XX
 246          void SetStartLine(uchar startline) //0--63
 247          {
 248   1              //startline &= 0x07;
 249   1              startline |= 0xc0; //1100 0000
 250   1              SendCommandToLCD(startline);
 251   1      }
 252          //开关显示
 253          void SetOnOff(uchar onoff)
 254          {
 255   1              onoff|=0x3e; //0011 111x
 256   1              SendCommandToLCD(onoff);
 257   1      }
 258          /*---------------------------------------------------------------------------------------------------*/
 259          //选择屏幕
 260          //screen: 0-全屏,1-左屏,2-右屏
 261          void SelectScreen(uchar screen)
 262          { //北京显示器:负有效 cs1: 0--右; cs2: 0--左
 263   1              switch(screen)
 264   1              { 
 265   2                      case 0: 
 266   2                              cs1=0;//全屏
 267   2                              nop();
 268   2                              cs2=0; 
 269   2                              nop();
 270   2                              break; 
 271   2                      case 1: 
 272   2                              cs1=1;//左屏
 273   2                              nop();
 274   2                              cs2=0;
 275   2                              nop();
 276   2                              break;
 277   2                      case 2: 
 278   2                              cs1=0;//右屏
 279   2                              nop();
 280   2                              cs2=1;
 281   2                              nop();
 282   2                              break;
 283   2                      default:
 284   2                              break;
 285   2              }
 286   1      }
 287          /*---------------------------------------------------------------------------------------------------*/
 288          //清屏
 289          //screen: 0-全屏,1-左屏,2-右
 290          void ClearScreen(uchar screen)
 291          { 
 292   1              uchar i,j;
 293   1              SelectScreen(screen);
 294   1              for(i=0;i<8;i++)
C51 COMPILER V7.05   FM12864                                                               01/01/2003 15:48:46 PAGE 6   

 295   1              { 
 296   2                      SetLine(i);
 297   2                      for(j=0;j<64;j++)
 298   2                      {
 299   3                              WriteByte(0x00);
 300   3                      }
 301   2              }
 302   1      }
 303          /*--------------------------------------------------------------------------------------------------*/
 304          //显示8*8点阵
 305          //lin:行(0-7), column: 列(0-127)
 306          //address : 字模区首地址
 307          void Show8x8(uchar lin,uchar column,uchar *address)
 308          { 
 309   1              uchar i;
 310   1      //      if(column>128) {return;}
 311   1              if(column<64)
 312   1              {
 313   2                      SelectScreen(2); //如果列数<64则从第2屏上开始写
 314   2                      SetLine(lin);
 315   2                      SetColumn(column);
 316   2                      for(i=0;i<8;i++)
 317   2                      {
 318   3                              if(column+i<64)
 319   3                              {
 320   4                                      WriteByte(*(address+i));
 321   4                              }
 322   3                              else
 323   3                              {
 324   4                                      SelectScreen(1);
 325   4                                      SetLine(lin);
 326   4                                      SetColumn(column-64+i);
 327   4                                      WriteByte(*(address+i));
 328   4                              }
 329   3                      }
 330   2              }
 331   1              else 
 332   1              {
 333   2                      SelectScreen(1); //否则从第2屏上开始写
 334   2                      column-=64; //防止越界
 335   2                      SetLine(lin);
 336   2                      SetColumn(column);
 337   2                      for(i=0;i<8;i++)
 338   2                      {
 339   3                              if(column+i<64)
 340   3                              {
 341   4                                      WriteByte(*(address+i));
 342   4                              }
 343   3                              else
 344   3                              {
 345   4                                      SelectScreen(2);
 346   4                                      SetLine(lin);
 347   4                                      SetColumn(column-64+i);
 348   4                                      WriteByte(*(address+i));
 349   4                              }
 350   3                      }
 351   2              }
 352   1      }
 353          
 354          //显示数字8*16
 355          void ShowNumber(uchar lin,uchar column,uchar num)
 356          {
C51 COMPILER V7.05   FM12864                                                               01/01/2003 15:48:46 PAGE 7   

 357   1              uchar *address;
 358   1              address=&Numcode[num][0];
 359   1              Show8x8(lin,column,address);
 360   1              Show8x8(lin+1,column,address+8);
 361   1      }
 362          //显示汉字16*16
 363          void ShowChina(uchar lin,uchar column,uchar num)
 364          {
 365   1              uchar *address;
 366   1      //      if(lin>7 || column>127){return;}        
 367   1              address = &HZcode[num][0];
 368   1              Show8x8(lin,column,address);
 369   1              Show8x8(lin,column+8,address+8);
 370   1              Show8x8(lin+1,column,address+16);
 371   1              Show8x8(lin+1,column+8,address+24);
 372   1      }
 373          
 374          void InitLCD(void) //初始化LCD
 375          { 
 376   1              uchar i=2000; //延时
 377   1              while(i--);
 378   1              SetOnOff(1); //开显示
 379   1              ClearScreen(1);//清屏
 380   1              ClearScreen(2);
 381   1              SetStartLine(0); //开始行:0
 382   1      }
 383          
 384          
 385          //time0初始化
 386          void time0_init(void)
 387          {
 388   1              EA = 1;
 389   1              ET0 = 1;
 390   1              TMOD = 0x01;
 391   1              PT0 = 1;
 392   1              TH0 = 0x3C;
 393   1              TL0 = 0xB0;
 394   1              TR0 = 1;
 395   1      }
 396          
 397          void time0_interrupt(void)interrupt 1
 398          {
 399   1              TH0 = 0x3c;
 400   1              TL0 = 0xb0;
 401   1              time0_count++;
 402   1              if(time0_count==40)
 403   1              {
 404   2                      time0_count=0;
 405   2                      j=j-2;
 406   2                      SetOnOff(1); //开显示
 407   2                      ClearScreen(1);//清屏
 408   2                      ClearScreen(2);
 409   2                      SetStartLine(0); //开始行:0
 410   2                      ShowChina(j,0,0);
 411   2                      ShowChina(j,22,1);
 412   2                      ShowChina(j,44,2);
 413   2                      ShowChina(j,66,3);
 414   2                      ShowChina(j,86,4);
 415   2                      ShowChina(j,108,5);
 416   2                      ShowChina(j+18,26,6);
 417   2                      ShowChina(j+18,46,7);           
 418   2                      ShowChina(j+18,66,8);
C51 COMPILER V7.05   FM12864                                                               01/01/2003 15:48:46 PAGE 8   

 419   2                      ShowChina(j+18,86,9);
 420   2      
 421   2                      ShowChina(j+36,0,10);
 422   2                      ShowChina(j+36,18,11);  
 423   2                      ShowNumber(j+36,36,0);  
 424   2                      ShowNumber(j+36,44,7);
 425   2                      ShowNumber(j+36,50,3);
 426   2                      ShowNumber(j+36,58,1);
 427   2      
 428   2                      ShowNumber(j+36,66,4);
 429   2                      ShowNumber(j+36,74,1);
 430   2                      ShowNumber(j+36,82,9);
 431   2                      ShowNumber(j+36,90,7);
 432   2                      ShowNumber(j+36,98,4);
 433   2                      ShowNumber(j+36,106,8);
 434   2                      ShowNumber(j+36,114,8);
 435   2      //              ShowNumber(j+36,122,8);
 436   2      
 437   2      
 438   2                      ShowNumber(j+54,0,11);
 439   2                      ShowNumber(j+54,8,11);
 440   2                      ShowNumber(j+54,16,11);
 441   2                      ShowNumber(j+54,24,12);
 442   2                      ShowNumber(j+54,32,13);
 443   2                      ShowNumber(j+54,40,14);
 444   2                      ShowNumber(j+54,48,15);
 445   2                      ShowNumber(j+54,56,16);
 446   2                      ShowNumber(j+54,64,17);
 447   2                      ShowNumber(j+54,72,18);
 448   2                      ShowNumber(j+54,80,19);
 449   2                      ShowNumber(j+54,88,12);
 450   2                      ShowNumber(j+54,96,20);
 451   2                      ShowNumber(j+54,104,21);
 452   2                      ShowNumber(j+54,112,22);
 453   2      
 454   2      //              ShowChina(j+72,0,12);
 455   2      //              ShowChina(j+72,20,13);
 456   2      //              ShowChina(j+72,50,14);
 457   2      //              ShowChina(j+72,70,15);
 458   2      //              ShowChina(j+72,90,16);
 459   2              }
 460   1      }
 461          
 462          void main(void)
 463          {
 464   1              InitLCD();
 465   1              time0_init();
 466   1              while(1)
 467   1              {
 468   2                      ;
 469   2              }       
 470   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1021    ----
   CONSTANT SIZE    =   1200    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      2      17
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
C51 COMPILER V7.05   FM12864                                                               01/01/2003 15:48:46 PAGE 9   

END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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