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

📄 lcd_demo.lst

📁 ARM LPC2142学习板 显示屏范例程序,适何初学者拿来参考与学习
💻 LST
📖 第 1 页 / 共 5 页
字号:
  300          调用方式:void clrscr(void)
  301          函数说明:清屏
  302          --------------------------------------------------------------------------------
  303          -*/
  304          void clrscr(void)
  305          {
  306   1      uchar i;
  307   1      uchar page;
  308   1      for (page=0;page<4;page++)
  309   1      {
  310   2      SetPage(page,page);
  311   2      SetAddress(0,0);
  312   2      for (i=0;i<61;i++){PutCharR(0);PutCharL(0);}
  313   2      }
  314   1      } 
  315          
  316          
  317          //-----------------------------------------------------------
  318          //图片显示
  319          //采用字模2生成或字模3生成的都可以.
  320          //-----------------------------------------------------------
  321          void DrawBmp1(uint x_add, uchar width,unsigned char const *bmp)
  322          {
ARM COMPILER V2.53,  Lcd_Demo                                                              22/05/07  01:37:34  PAGE 6   

  323   1      uchar x,address,i=0;     //address表示显存的物理地址
  324   1      uchar page=0;   //page表示上下两页
  325   1      uchar window=0;  //window表示左右两页
  326   1      //putcharR  //右边
  327   1      //putcharL  //左边
  328   1      for (x=width;x>1;x--)
  329   1      {
  330   2      if (x_add>60) {window=1;address=x_add%61;}
  331   2      else address=x_add; 
  332   2      
  333   2      
  334   2          SetPage(2,2);
  335   2          SetAddress(address,address);
  336   2          if(window==1)PutCharR(bmp[i]);
  337   2          else    PutCharL(bmp[i]);
  338   2          SetPage(3,3);
  339   2          SetAddress(address,address);
  340   2          if(window==1)PutCharR(bmp[i+width]);
  341   2          else    PutCharL(bmp[i+width]);
  342   2          
  343   2          
  344   2          SetPage(0,0);
  345   2          SetAddress(address,address);
  346   2          if(window==1)PutCharR(bmp[i+width+width]);
  347   2          else    PutCharL(bmp[i+width+width]);
  348   2          SetPage(1,1);
  349   2          SetAddress(address,address);
  350   2          if(window==1)PutCharR(bmp[i+width+width+width]);
  351   2          else    PutCharL(bmp[i+width+width+width]); 
  352   2          i++;
  353   2          x_add++;
  354   2         
  355   2      }
  356   1      }
  357          
  358          //---------------------------------------------------------------
  359          //---------------------------------------------------------------
  360          //采用zimo2  显示汉字,以汉字的显示方式
  361          //void Draw_word(uchar d_where,uint x_add,bit layer,uchar width)
  362          //d_where表示在码表中第几个汉字,x_add横坐标位置,layer显示的层, width显示的宽度。
  363          //---------------------------------------------------------------
  364          
  365          
  366          void Draw_word(uchar d_where,uint x_add,uchar layer,uchar width)
  367          {
  368   1      uchar x,i=0,address;     //address表示显存的物理地址
  369   1      uchar page=0;   //page表示上下两页
  370   1      uchar window=0;  //window表示左右两页
  371   1      //putcharR  //右边
  372   1      //putcharL  //左边
  373   1      d_where=d_where*32;
  374   1      
  375   1      for (x=width;x>1;x--)
  376   1      {
  377   2      if (x_add>60) {window=1;address=x_add%61;}
  378   2      else address=x_add; 
  379   2      
  380   2      if(layer==0)    //显示一行八个字
  381   2          {
  382   3          
  383   3          SetPage(0,0);
  384   3          SetAddress(address,address);
  385   3          if(window==1)PutCharR(bmp001[d_where]);//右边
  386   3          else    PutCharL(bmp001[d_where]);//左边
  387   3          SetPage(1,1);
  388   3          SetAddress(address,address);
ARM COMPILER V2.53,  Lcd_Demo                                                              22/05/07  01:37:34  PAGE 7   

  389   3          if(window==1)PutCharR(bmp001[d_where+width]);
  390   3          else    PutCharL(bmp001[d_where+width]);
  391   3      
  392   3          }
  393   2      else
  394   2          {   //显示第二行八个汉字
  395   3          SetPage(2,2);
  396   3          SetAddress(address,address);
  397   3          if(window==1)PutCharR(bmp001[d_where]);//右边
  398   3          else    PutCharL(bmp001[d_where]);//左边
  399   3          SetPage(3,3);
  400   3          SetAddress(address,address);
  401   3          if(window==1)PutCharR(bmp001[d_where+width]);
  402   3          else    PutCharL(bmp001[d_where+width]);
  403   3      
  404   3          }
  405   2          x_add++;
  406   2         d_where++;
  407   2      }
  408   1      }
  409          /*
  410          //------------------------------------------------------------------
  411          //字模2显示一个汉字
  412          //纵向取模,字节倒序
  413          void    disp_one(bit top_low,bit widows,uchar address,uchar width,uchar*bmp)
  414          {   
  415          if(top_low==0)
  416              {
  417              SetPage(0,0);
  418              SetAddress(address,address);
  419              if(window==1)PutCharR(bmp001[next][i]);
  420              else    PutCharL(bmp001[next][i]);
  421              SetPage(1,1);
  422              SetAddress(address,address);
  423              if(window==1)PutCharR(bmp001[next][i+width]);
  424              else    PutCharL(bmp001[next][i+width]);
  425              }
  426          else
  427              {
  428              SetPage(0,0);
  429              SetAddress(address,address);
  430              if(window==1)PutCharR(bmp001[next][i]);
  431              else    PutCharL(bmp001[next][i]);
  432              SetPage(1,1);
  433              SetAddress(address,address);
  434              if(window==1)PutCharR(bmp001[next][i+width]);
  435              else    PutCharL(bmp001[next][i+width]);
  436              }
  437          }
  438          */
  439          
  440          
  441          
  442          
  443          //液晶显示规则
  444          //  M(左)       S(右)
  445          //  page        page
  446          //  0   |   0
  447          //  1   |   1
  448          //  2   |   2
  449          //  3   |   3
  450          
  451          void    delay1s(unsigned char i)
  452          {
  453   1          while(i>1)
  454   1          {
ARM COMPILER V2.53,  Lcd_Demo                                                              22/05/07  01:37:34  PAGE 8   

  455   2              i--;
  456   2              delayms(20);
  457   2          }
  458   1      }
  459          
  460          //显示动态的等待图标
  461          void    wait1(unsigned char i)
  462          {
  463   1          clrscr(); //
  464   1          DrawBmp1(0,60,Bmptc); //
  465   1          for(;i>1;i--)
  466   1          {delay1s(12);
  467   2          DrawBmp1(76,19,Bmpt1); //
  468   2          delay1s(12);
  469   2          DrawBmp1(76,19,Bmpt2); //
  470   2          delay1s(12);
  471   2      
  472   2      //  DrawBmp1(0,60,Bmptc); //
  473   2          DrawBmp1(76,19,Bmpt3); //
  474   2          delay1s(12);
  475   2      
  476   2      //  DrawBmp1(0,60,Bmptc); //
  477   2          DrawBmp1(76,19,Bmpt4); //
  478   2          delay1s(12);
  479   2      
  480   2      //  DrawBmp1(0,60,Bmptc); //
  481   2          DrawBmp1(76,19,Bmpt5); //
  482   2          delay1s(2);
  483   2      
  484   2      //  DrawBmp1(0,60,Bmptc); //
  485   2          DrawBmp1(76,19,Bmpt6); //
  486   2          delay1s(2);
  487   2      
  488   2      //  DrawBmp1(0,60,Bmptc); //
  489   2          DrawBmp1(76,19,Bmpt7); //
  490   2          }
  491   1      
  492   1      }
  493          
  494           void init_port(void)
  495           {
  496   1       //port initialized
  497   1       IODIR1=0x00FF0000;
  498   1       IODIR0=0x40600010;
  499   1       }
  500           
  501           
  502          //演示程序
  503          void main()                                                                                              
             -                            
  504          {                
  505   1      //unsigned int i;
  506   1       init_port();
  507   1       //while(1)
  508   1      // {
  509   1       // for(i=1;i<=128;i<<=1 )
  510   1       // {
  511   1      //  OUT_DATA(i);
  512   1      //  delayms(10);
  513   1      //  }
  514   1        //for (j = 0x010000; j < 0x800000; j <<= 1) { /* Blink LED 0,1,2,3,4,5,6 */
  515   1        //    IOSET1 = j;                               /* Turn on LED */
  516   1        //    delayms (10);                                  /* call wait function */
  517   1        //    IOCLR1 = j;                               /* Turn off LED */
  518   1        //  }
  519   1      // }                                                                                                    
ARM COMPILER V2.53,  Lcd_Demo                                                              22/05/07  01:37:34  PAGE 9   

  520   1       lcdini(); //reset                                                   
  521   1       clrscr(); //clr          
  522   1       
  523   1                                                    
  524   1       Draw_word(0,0,0,16); //
  525   1       Draw_word(1,16,0,16); //
  526   1       Draw_word(2,32,0,16); //
  527   1       Draw_word(3,48,0,16); //
  528   1       Draw_word(0,64,0,16); //
  529   1       Draw_word(1,80,0,16); //
  530   1       Draw_word(2,96,0,16); //
  531   1      
  532   1        clrscr(); //
  533   1       DrawBmp(0,112,ARMKIT_bmp);
  534   1       DrawBmp(1,119,Bmp002); //
  535   1      
  536   1       clrscr(); //
  537   1       delay1s(3);
  538   1       DrawBmp1(0,122,Bmp012); //LOGO
  539   1       while(1)
  540   1          {
  541   2          delay1s(3);
  542   2      
  543   2          clrscr(); //
  544   2          DrawBmp1(10,101,Bmp07); //
  545   2          delay1s(8);
  546   2          clrscr(); //
  547   2          wait1(3);
  548   2          DrawBmp1(0,122,Bmp04); //
  549   2          delay1s(8);
  550   2          clrscr(); //
  551   2          wait1(3);
  552   2          DrawBmp1(0,122,Bmp03); //超前科技
  553   2          delay1s(8);
  554   2          clrscr(); //
  555   2          wait1(3);
  556   2          clrscr(); //
  557   2          DrawBmp1(10,101,Bmp05); //
  558   2          delay1s(8);
  559   2          clrscr(); //
  560   2          wait1(3);
  561   2          clrscr(); //
  562   2          DrawBmp1(10,101,Bmp06); //
  563   2          delay1s(8);
  564   2          clrscr(); //
  565   2          wait1(3);
  566   2          clrscr(); //
  567   2          DrawBmp1(10,101,Bmp08); //
  568   2          delay1s(8);
  569   2          clrscr(); //
  570   2          wait1(3);
  571   2          clrscr(); //
  572   2          DrawBmp1(0,122,Bmp01); //
  573   2          wait1(8);
  574   2          }                                                        
  575   1       }                
  576           
  577                                                   
ARM COMPILER V2.53,  Lcd_Demo                                                              22/05/07  01:37:34  PAGE 10  

ASSEMBLY LISTING OF GENERATED OBJECT CODE



*** EXTERNALS:
 EXTERN DATA (Bmpt1)
 EXTERN DATA (Bmpt2)
 EXTERN DATA (Bmpt3)
 EXTERN DATA (Bmpt4)
 EXTERN DATA (Bmpt5)
 EXTERN DATA (Bmpt6)
 EXTERN DATA (Bmpt7)
 EXTERN DATA (Bmptc)
 EXTERN DATA (bmp001)
 EXTERN DATA (Bmp08)
 EXTERN DATA (Bmp07)
 EXTERN DATA (Bmp06)
 EXTERN DATA (Bmp05)
 EXTERN DATA (Bmp04)
 EXTERN DATA (Bmp03)
 EXTERN DATA (Bmp01)
 EXTERN DATA (Bmp012)
 EXTERN DATA (Bmp002)
 EXTERN DATA (ARMKIT_bmp)
 EXTERN CODE16 (?C?SDIV?T)
 EXTERN CODE16 (?C?UDIV?T)
 EXTERN NUMBER (__startup)

⌨️ 快捷键说明

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