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

📄 1335c51.lst

📁 这是一个成熟的用于驱动步进马达的程序,我们用于调试螺钉的.
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V8.15   1335C51                                                               10/29/2008 21:06:48 PAGE 15  

                              WriteData( Cnumber++ );                                 // 写入汉字代码
                              tempPtr++;                                                              // 修正光标地址
                      }
              }
              
              #endif
 868          
 869          /*====================================================
 870          ;  绘点子程序,携入参数attr决定写或擦点
 871           ====================================================*/
 872          void Point(uint Px, uchar Py, uchar attr ) 
 873          {
 874   1      
 875   1              uint tempPtr;
 876   1              uchar tempD,tempP;
 877   1                      
 878   1              tempPtr = (uint)Py * paraP9 + (Px / 8);                 // 计算地址
 879   1              WriteCommand( CsrDirD );                                                // CSRDIR 代码(光标自动下移)
 880   1              WriteCommand( CsrW );                                                   // 设置光标地址
 881   1              WriteData( (uchar)(tempPtr & 0xff) );
 882   1              WriteData( (uchar)(tempPtr /256 +BasePart2) );
 883   1              WriteCommand( mRead );                                                  // 读显示ram指令
 884   1              tempD = ReadDataLcm();                                                  // 读取当前显示数据
 885   1              //tempP = 1<<(uchar)(7-Px & 0x0007);
 886   1          tempP = Px - ((Px / 8) * 8);
 887   1              tempP = (0x80 >> tempP);
 888   1      
 889   1      // 根据预定属性决定写点或擦除
 890   1              if( attr )
 891   1                      {
 892   2                              tempD |= tempP; // 画点
 893   2                      }
 894   1              else 
 895   1                      {
 896   2                              tempD &= ~tempP;                                // 消点
 897   2                      }
 898   1      
 899   1              WriteCommand( CsrW );                                           // 重新设置光标地址
 900   1              WriteData( (uchar)(tempPtr & 0xff) );
 901   1              WriteData( (uchar)(tempPtr /256+BasePart2) );
 902   1              WriteCommand( mWrite );                                         // 代码0x42,数据写入指令
 903   1              WriteData( tempD );                                                     // 写入合成数据
 904   1      
 905   1      }
 906          
 907          /*======================== 清显示 32K RAM区(清屏)子程序 ======================*/
 908          
 909          void LcmClear( void ) 
 910          {
 911   1      
 912   1              uint i1=32768;
 913   1      
 914   1              WriteCommand( CsrDirR );                        // 光标移动方向定义:自动右移
 915   1              WriteCommand( CsrW );                           // 光标Locate,定位
 916   1              WriteData( 0 );                                         // 写入参数CSRL设置参数光标指针低8位
 917   1              WriteData( 0 );                                         // 写入参数CSRH设置参数光标指针高8位
 918   1              WriteCommand( mWrite );                         // 数据写入指令,代码0x42
 919   1              while(i1--)     
 920   1              {
 921   2      
 922   2                      WriteData( 0x0 );       // 写入数据0
 923   2              }
C51 COMPILER V8.15   1335C51                                                               10/29/2008 21:06:48 PAGE 16  

 924   1      }
 925          
 926          #if 0
              /*======================== 清显示 图形 RAM区(清屏)子程序 ======================*/
              void LcmClear_G( void ) 
              {
              
                      uint i1=0x3400;
              
                      WriteCommand( CsrDirR );                        // 光标移动方向定义:自动右移
                      WriteCommand( CsrW );                           // 光标Locate,定位
                      WriteData( 0xff );                                              // 写入参数CSRL设置参数光标指针低8位
                      WriteData( 0x3f );                                              // 写入参数CSRH设置参数光标指针高8位
                      WriteCommand( mWrite );                         // 数据写入指令,代码0x42
                      while(i1--)     
                      {
              
                              WriteData( 0x0 );       // 写入数据0
                      }
              }
              
              
              
              /*============================================================================
               光标位定位,用于在1区图形方式下。
               输入参数约定: x...水平方向字节单位坐标,即可以以半个汉字宽度设定水平坐标。
                                              y...垂直方向以行线定位的坐标,可以定位到点单位。
                                              左上角约定坐标为( 0, 0 )
              
               ============================================================================*/
              void Locatexy(uchar x,uchar y, uchar attribs) 
              {
                      uint temp;
                      temp = (uint)y*paraP9+x;
                      if(attribs)temp += BasePart2*256;       // 如果需要就指向第二区,加上第二区首地址
                      WriteCommand( CsrW );                           // 光标Locate,定位
                      WriteData( (uchar)(temp & 0xff) );      // 写入参数CSRL设置参数光标指针低8位
                      WriteData( (uchar)(temp /256 ) );       // 写入参数CSRH设置参数光标指针高8位
              }
              
              #endif
 965          
 966          
 967          
 968          
 969          
 970          #if 0
              
              /************************************************/
              /*画圆。数学方程(X-Ox)^2+(Y-Oy)^2=Rx^2          */
              /************************************************/
              
              void circle(uint Ox,uchar Oy,uchar Rx,uchar attr)
              {
                      uint xx,rr,xt,yt,rs,col,row;
                      yt=Rx;
                      rr=Rx*Rx+1;                     //补偿 1 修正方形
                      rs=(yt+(yt>>1))>>1;             //(*0.75)分开1/8圆弧来画
                      for (xt=0;xt<=rs;xt++)
                      {
                              xx=xt*xt;
                              while ((yt*yt)>(rr-xx))yt--;
C51 COMPILER V8.15   1335C51                                                               10/29/2008 21:06:48 PAGE 17  

                              col=Ox+xt;              //第一象限
                              row=Oy-yt;
                              Point(col,row,attr);
                              col=Ox-xt;              //第二象限
                              Point(col,row,attr);
                              row=Oy+yt;              //第三象限
                              Point(col,row,attr);
                              col=Ox+xt;              //第四象限
                              Point(col,row,attr);
              
              /***************45度镜象画另一半***************/
              
                              col=Ox+yt;              //第一象限
                              row=Oy-xt;
                              Point(col,row,attr);
                              col=Ox-yt;              //第二象限
                              Point(col,row,attr);
                              row=Oy+xt;              //第三象限
                              Point(col,row,attr);
                              col=Ox+yt;              //第四象限
                              Point(col,row,attr);
                      }
              }
              
              #endif
1011          
1012          
1013          //显示BMP图片
1014          void BmpDisp( uint Ox, uchar Oy, uchar width, uchar height, uchar code *pbmp ) 
1015          {
1016   1              uint Optr;
1017   1              uchar tempCount1,tempCount2;
1018   1                      
1019   1              Optr = (uint)Oy * paraP9 + Ox;
1020   1              WriteCommand( CsrDirR );                                                // 自动右移。
1021   1      
1022   1              for (tempCount1=0;tempCount1<height;tempCount1++) 
1023   1              {
1024   2                      WriteCommand( CsrW );                                           // 光标定位指令
1025   2                      WriteData( (uchar)(Optr &0xff) );                       // 设置光标地址CSR
1026   2                      WriteData( Optr /256 +BasePart2 );
1027   2                      WriteCommand( mWrite );                                         // ram写指令
1028   2                      
1029   2      
1030   2              for(tempCount2=0;tempCount2<width/8;tempCount2++) 
1031   2                      {
1032   3                              WriteData(pbmp[tempCount1*(width/8)+tempCount2]);               // 写入数据
1033   3                      }
1034   2                      Optr+=paraP9;
1035   2              }
1036   1      }
1037          
1038          /*==============================================================================
1039          ; 汉字写入子程序(图形方式)。每次调用输出一个汉字
1040          ; 支持图形方式使用,完成汉字点阵码的输出。
1041          ; 携入参数: Ox,Oy....写入显示的左上角坐标,Ox是以字节单位,Oy以行扫描线单位
1042                                  Ptr......汉字码,库内的排列编码,大型程序时请改用unsigned int类型
1043          ; 无返回数据。
1044           ==============================================================================*/
1045          void PutCdotInGraph( uint Ox, uchar Oy, uchar DotWidth, uchar code *Disp) 
1046          {
1047   1              uint Optr;
C51 COMPILER V8.15   1335C51                                                               10/29/2008 21:06:48 PAGE 18  

1048   1              uchar tempCount1,tempCount2,nByte;
1049   1                      
1050   1              Optr = (uint)Oy * paraP9 + Ox;
1051   1              nByte = DotWidth/8;
1052   1              WriteCommand( CsrDirD );                                                // 自动下移
1053   1      
1054   1              for (tempCount1=0;tempCount1<nByte;tempCount1++) 
1055   1              {
1056   2                      WriteCommand( CsrW );                                           // 光标定位指令
1057   2                      WriteData( (uchar)(Optr &0xff) );                       // 设置光标地址CSR
1058   2                      WriteData( Optr /256 +BasePart2 );
1059   2                      WriteCommand( mWrite );                                         // ram写指令
1060   2                      
1061   2                      switch(DotWidth)
1062   2                      {
1063   3      
1064   3                              case 16:        for(tempCount2=0;tempCount2<DotWidth;tempCount2++) 
1065   3                                                      {
1066   4                                                              WriteData( *Disp );             // 写入数据
1067   4                                  Disp++;
1068   4                                                      }
1069   3                                                      break;
1070   3                              case 24:        for(tempCount2=0;tempCount2<DotWidth;tempCount2++) 
1071   3                                                      {
1072   4                                                              WriteData( *Disp );             // 写入数据
1073   4                                                              Disp++;
1074   4             

⌨️ 快捷键说明

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