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

📄 ocm4x8c.lst

📁 Keil c工程
💻 LST
📖 第 1 页 / 共 2 页
字号:
 342   1              {
 343   2              case 1:line_real=0;break;
 344   2              case 2:line_real=0x10;break;
 345   2              case 3:line_real=8;break;
 346   2              case 4:line_real=0x18;break;
 347   2              }
 348   1      SetDDRAM(line_real+x-1);
 349   1      
 350   1      CheckOdd=0;                             //add on 2004/06/29
 351   1      }
 352          void NextLine(void)
 353          {
 354   1              while(CheckBusy());
 355   1              switch(ReadAC())
 356   1              {
 357   2              case 0x08:SetDDRAM(0x10);break;
 358   2              case 0x18:SetDDRAM(0x08);break;
 359   2              case 0x10:SetDDRAM(0x18);break;
 360   2              case 0x20:Delay100uS(5000);WaitMode();
 361   2                                      break;
 362   2          }
 363   1      
 364   1      }
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 7   

 365          /*************** upper functions ********************************/
 366          void DisplayChar(byte Char)
 367          {
 368   1              OCM4X8C_WriteData(Char);
 369   1              CheckOdd^=1;
 370   1      
 371   1              if(!CheckOdd) NextLine();
 372   1      
 373   1      }
 374          void DisplayEChar(byte EChar)
 375          {
 376   1      //8*16 dot matrix
 377   1      //EChar should be valued in 01h to 7fh
 378   1      if((EChar>0)&&(EChar<0x80))
 379   1              {
 380   2      
 381   2              OCM4X8C_WriteData(EChar);
 382   2              CheckOdd^=1;
 383   2      
 384   2              if(!CheckOdd) NextLine();
 385   2      
 386   2              }
 387   1      }
 388          
 389          void DisplayCChar(word CChar)
 390          {
 391   1      //16*16 dot matrix
 392   1      //CChar should be valued in 0xa1a1 to 0xf7fe,
 393   1      //in which ,0xa1a0 to 0xa9ff is special characters,
 394   1      //0xb0a1 to 0xd7fe is the class 1 chinese characters,
 395   1      //0xd8a1 to 0xf7fe is the class 2 chinese characters.
 396   1      byte high,low;
 397   1      high=CChar>>8;
 398   1      low=CChar;
 399   1      if((high>0xa0)&&(high<0xf8)&&(low>0xa0)&&(low<0xff))
 400   1              {
 401   2      
 402   2              OCM4X8C_WriteData(high);        //higer 8bit,should be bigger than or equal to 0xa0
 403   2              OCM4X8C_WriteData(low); //lower 8bit,should be bigger than or equal to 0xa0
 404   2      
 405   2              NextLine();
 406   2              }
 407   1      
 408   1      }
 409          
 410          void DisplayString(byte *string)
 411          {
 412   1      byte i=0;
 413   1      while(*(string+i)!=LCD_STRING_END)
 414   1              {
 415   2              DisplayChar(*(string+i));
 416   2              i++;
 417   2              }
 418   1      }
 419          
 420          void DeleteNumber(void)
 421          //删除刚输出的半角字符,2004/06/30
 422          {
 423   1      byte temp;
 424   1      
 425   1      if(!CheckOdd)//delete right half
 426   1              {
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 8   

 427   2               IndexShiftLeft();
 428   2               temp=OCM4X8C_ReadData();
 429   2               temp=OCM4X8C_ReadData();
 430   2               IndexShiftLeft();
 431   2               DisplayEChar(' ');
 432   2               DisplayEChar(' ');
 433   2               IndexShiftLeft();
 434   2               DisplayEChar(temp);
 435   2              }
 436   1      else    //delete left half
 437   1              {
 438   2               DisplayEChar(' ');
 439   2               IndexShiftLeft();
 440   2               DisplayEChar(' ');DisplayEChar(' ');
 441   2               IndexShiftLeft();
 442   2              }
 443   1      }
 444          
 445          void DisplayNumber(word number)
 446          {
 447   1      byte NumDisplay[5];
 448   1      byte i,*string;
 449   1      bit rtn=0;
 450   1      
 451   1              NumDisplay[0]=number/10000;                     //最高位
 452   1              number-=NumDisplay[0]*10000;
 453   1      
 454   1              NumDisplay[1]=number/1000;
 455   1              number-=NumDisplay[1]*1000;
 456   1      
 457   1              NumDisplay[2]=number/100;
 458   1              number-=NumDisplay[2]*100;
 459   1      
 460   1              NumDisplay[3]=number/10;
 461   1              number-=NumDisplay[3]*10;
 462   1      
 463   1              NumDisplay[4]=number;
 464   1      
 465   1              string=NumDisplay;
 466   1              
 467   1      for(i=0;(i<5)&&(rtn==0);i++)                    //寻找第一个不为0的数字位置//保证至少输出一个数字
 468   1              {
 469   2               if(*(string+i)!=0) rtn=1;
 470   2              }
 471   1      //if(i%2!=0)DisplayEChar(0x20);           //保证输出偶数个字符
 472   1      for(i-=1;i<5;i++) DisplayEChar(*(string+i)+0x30);
 473   1      
 474   1      }
 475          
 476          void DisplayDoubleNumber(bit left,bit space,word number)
 477          //left=1,left align
 478          //left=0,right align
 479          //space=1,space;space=0,'0'
 480          {
 481   1      byte NumDisplay[5];
 482   1      byte i,*string;
 483   1      bit rtn=0;
 484   1      
 485   1              NumDisplay[0]=number/10000;                     //最高位
 486   1              number-=NumDisplay[0]*10000;
 487   1      
 488   1              NumDisplay[1]=number/1000;
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 9   

 489   1              number-=NumDisplay[1]*1000;
 490   1      
 491   1              NumDisplay[2]=number/100;
 492   1              number-=NumDisplay[2]*100;
 493   1      
 494   1              NumDisplay[3]=number/10;
 495   1              number-=NumDisplay[3]*10;
 496   1      
 497   1              NumDisplay[4]=number;
 498   1      
 499   1              string=NumDisplay;
 500   1              
 501   1      for(i=0;(i<5)&&(rtn==0);i++)                    //寻找第一个不为0的数字位置//保证至少输出一个数字
 502   1              {
 503   2               if(*(string+i)!=0) rtn=1;
 504   2              }
 505   1      if((i%2!=0)&&(left==0))space?DisplayEChar(0x20):DisplayEChar('0');                //保证输出偶数个字符
 506   1      DisplayNumber(number);
 507   1      if((i%2!=0)&&(left==1))space?DisplayEChar(0x20):DisplayEChar('0');                //保证输出偶数个字符
 508   1      
 509   1      }
 510          
 511          void SlideShow(byte time,byte line,byte *string)        //add on 2004/07/02
 512          //time设定滑动速度,单位为10毫秒。
 513          //line设置字符出现的行数,string为显示的字符,长度限制为小于8个汉字或16个半轿字符。
 514          //字符从右边出现,至左边停止。string必须为偶数字节。
 515          {
 516   1      byte i,j=0;
 517   1      word *p=string;
 518   1      
 519   1      OCM4X8C_WriteInstruction(DISPLAY_STATUS+4);     //whole display on,index off,index position off
 520   1      
 521   1      do
 522   1      {
 523   2              SetStartPoisition(line,8-j);
 524   2              for(i=0;i<=j;i++)       DisplayCChar(*(p+i));
 525   2              Delay100uS(time*100);
 526   2              j++;
 527   2              
 528   2      }
 529   1      while (((*(string+2*j)!=LCD_STRING_END))&&(j<=8));
 530   1      
 531   1      while(j<8)
 532   1      {
 533   2              ClearLine(line);
 534   2              SetStartPoisition(line,8-j);
 535   2              DisplayString(string);
 536   2              Delay100uS(time*100);
 537   2              j++;
 538   2      }
 539   1      
 540   1      }
 541          
 542          void SlideString(byte time,byte line,byte *string)      //add on 2004/07/02
 543          //time设定滑动速度,line设置字符出现的行数,string为显示的字符,长度不限
 544          //字符从右边出现, 一直向左滚动直到字符全部消失。string必须为偶数字节。
 545          {
 546   1      byte i,j=0;
 547   1      byte length=0;  //字符串长度。
 548   1      word *p=string;
 549   1      
 550   1      OCM4X8C_WriteInstruction(DISPLAY_STATUS+4);     //whole display on,index off,index position off
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 10  

 551   1      
 552   1      do{length++;}
 553   1      while(*(string+length)!=LCD_STRING_END);
 554   1      
 555   1      if(length<=16)
 556   1      {
 557   2              for(j=0;j<length/2;j++)
 558   2              {
 559   3              SetStartPoisition(line,8-j);
 560   3              for(i=0;i<=j;i++)       DisplayCChar(*(p+i));
 561   3              Delay100uS(time*100);
 562   3              }
 563   2      
 564   2              for(;j<8;j++)
 565   2              {
 566   3               ClearLine(line);
 567   3               SetStartPoisition(line,8-j);
 568   3               for(i=0;i<length/2;i++) DisplayCChar(*(p+i));
 569   3               Delay100uS(time*100);
 570   3              }
 571   2      
 572   2              for(j=1;j<=length/2;j++)
 573   2              {
 574   3               ClearLine(line);
 575   3               SetStartPoisition(line,1);
 576   3               for(i=j;i<length/2;i++) DisplayCChar(*(p+i));
 577   3               Delay100uS(time*100);
 578   3      
 579   3              } 
 580   2      
 581   2      }
 582   1      else
 583   1      {
 584   2              for(j=0;j<8;j++)
 585   2              {
 586   3              SetStartPoisition(line,8-j);
 587   3              for(i=0;i<=j;i++)       DisplayCChar(*(p+i));
 588   3              Delay100uS(time*100);
 589   3              }
 590   2              for(j=1;j<=length/2-8;j++)
 591   2              {
 592   3               SetStartPoisition(line,1);
 593   3               for(i=j;i<j+8;i++) DisplayCChar(*(p+i));
 594   3               Delay100uS(time*100);
 595   3              }
 596   2              for(;j<=length/2;j++)
 597   2              {
 598   3               ClearLine(line);
 599   3               SetStartPoisition(line,1);
 600   3               for(i=j;i<length/2;i++) DisplayCChar(*(p+i));
 601   3               Delay100uS(time*100);
 602   3              }
 603   2      }
 604   1      
 605   1      }
 606          void DrawPicture(byte *bmpPicture)
 607          //display 128*64 bmp
 608          //横向取模 高位在左
 609          //位图大小128*64 
 610          //点阵由牧马字模输出
 611          {
 612   1      byte X,Y;
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 11  

 613   1      
 614   1      WaitMode();
 615   1      OCM4X8C_WriteInstruction(DISPLAY_STATUS+4);     //whole display on,index off,index position off
 616   1      
 617   1      SetToExtendOperation();
 618   1      DrawOff();
 619   1      
 620   1       for(Y=0;Y<32;Y++)                              
 621   1         {
 622   2              OCM4X8C_WriteInstruction(SET_GDRAM+Y);
 623   2              OCM4X8C_WriteInstruction(SET_GDRAM+0);  //X=0
 624   2      
 625   2                      for(X=0;X<8*2;X++)      //display the upper half
 626   2                   {
 627   3                        OCM4X8C_WriteData(*(bmpPicture+Y*0x10+X));
 628   3               }
 629   2              for(X=0;X<16;X++)       //display the lower half
 630   2                   {
 631   3                        OCM4X8C_WriteData(*(bmpPicture+0x1f0+Y*0x10+X));      
 632   3               }
 633   2        }
 634   1      
 635   1      DrawOn();
 636   1      SetToBasicOperation();
 637   1      }
 638          
 639          /*
 640          void CA12864K_DrawPicture(byte *bmpPicture)
 641          //display 128*64 bmp
 642          //横向取模 高位在左
 643          //位图大小128*64 
 644          //点阵由牧马字模输出
 645          {
 646          byte X,Y;
 647          
 648          WaitMode();
 649          while(CheckBusy());
 650          XBYTE[OCM4X8C_WRITE_INSTRUCTION]=DISPLAY_STATUS+4;      //whole display on,index off,index position off
 651          
 652          SetToExtendOperation();
 653          DrawOff();
 654          
 655          
 656           for(Y=0;Y<64;Y++)                              
 657             {
 658                  while(CheckBusy());
 659                  XBYTE[OCM4X8C_WRITE_INSTRUCTION]=SET_GDRAM+Y;   //Y=0   
 660                  while(CheckBusy());
 661                  XBYTE[OCM4X8C_WRITE_INSTRUCTION]=SET_GDRAM+0;   //X=0
 662          
 663                          for(X=0;X<8*2;X++)      
 664                       {
 665                          while(CheckBusy());
 666                          XBYTE[OCM4X8C_WRITE_DATA]=*(bmpPicture+Y*0x10+X);
 667                   }
 668            }
 669          
 670          DrawOn();
 671          SetToBasicOperation();
 672          }
 673          */
 674          
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 12  

 675          #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2041    ----
   CONSTANT SIZE    =    128    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      1      55
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1       4
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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