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

📄 lcdx1.lst

📁 此程序主要测试50HZ~3KHZ音频范围幅频特性测试程序.程序包含主控程序和显示程序.
💻 LST
📖 第 1 页 / 共 4 页
字号:
 590          /*从下到上,从左到右进行刷新*/
 591          
 592          void draw_srec(point p1,point p2,uchar s)
 593          {
 594   1              uchar a,i,j,min,max;
 595   1              if(p1.x>p2.x) {a=p1.x;p1.x=p2.x;p2.x=a;}
 596   1              if(p1.y>p2.y) {a=p1.y;p1.y=p2.y;p2.y=a;}
 597   1              if((p1.x<128)&(p1.y<64))
 598   1              {
 599   2                      if(p2.x>127) p2.x=127;
 600   2                      if(p2.y>63) p2.y=63;
 601   2                      min=MIN(p1.y/8,p2.y/8);
 602   2                      max=MAX(p1.y/8,p2.y/8);
 603   2                      for(i=max+1;i>=min+1;i--)
 604   2                      {
 605   3                                              
 606   3                              for(j=p1.x;j<=p2.x;j++)
 607   3                              {
 608   4                                      if(j<=63)                               
 609   4                                      {
 610   5                                              iwl(0xb8|(i-1));//page
 611   5                                              iwl(0x40|j);     
 612   5                                              a=drl();
 613   5                                              a=drl();
 614   5                                              iwl(0x40|j);
 615   5                                              if(min!=max)            
 616   5                                              {
 617   6                                                      if(i==min+1)//最上边一页的处理
 618   6                                                      {
 619   7                                                              if(s==0) dwl(a&(0xff>>(8-p1.y%8)));
 620   7                                                              else if(s==0xff) dwl(a|(0xff<<(p1.y%8)));
 621   7                                                              else {dwl(a^(0xff<<(p1.y%8)));}
 622   7                                                      }
 623   6                                                      else if(i==max+1)//最下边一页的处理
 624   6                                                      {
 625   7                                                              if(s==0) dwl(a&(0xff<<(p2.y%8+1)));
 626   7                                                              else if(s==0xff) dwl(a|(0xff>>(7-p2.y%8)));
 627   7                                                              else {dwl(a^(0xff>>(7-p2.y%8)));}
C51 COMPILER V7.06   LCDX1                                                                 02/28/2007 15:18:19 PAGE 15  

 628   7                                                      }
 629   6                                                      else //中间页的处理
 630   6                                                      {
 631   7                                                              if(s==0) {dwl(0);}
 632   7                                                              else if(s==0xff) {dwl(0xff);}
 633   7                                                              else {dwl(~a);}
 634   7                                                      }
 635   6                                              }
 636   5                                              else
 637   5                                              {
 638   6                                                      if(s==0) dwl(a&((0xff>>(8-p1.y%8))|(0xff<<(p2.y%8+1))));
 639   6                                                      else if(s==0xff) dwl(a|((0xff<<(p1.y%8))&(0xff>>(7-p2.y%8))));
 640   6                                                      else {dwl(a^((0xff<<(p1.y%8))&(0xff>>(7-p2.y%8))));}
 641   6                                              }
 642   5                                      }
 643   4                                      else                    
 644   4                                      {
 645   5                                              iwr(0xb8|(i-1));
 646   5                                              iwr(0x40|(j-64));
 647   5                                              a=drr();
 648   5                                              a=drr();
 649   5                                              iwr(0x40|(j-64));
 650   5                                              if(min!=max)
 651   5                                              {
 652   6                                                      
 653   6                                                      if(i==min+1)
 654   6                                                      {
 655   7                                                              if(s==0) {dwr(a&(0xff>>(8-p1.y%8)));}
 656   7                                                              else if(s==0xff) {dwr(a|(0xff<<(p1.y%8)));}
 657   7                                                              else {dwr(a^(0xff<<(p1.y%8)));}
 658   7                                                      }
 659   6                                                      else if(i==max+1)
 660   6                                                      {
 661   7                                                              if(s==0) {dwr(a&(0xff<<(p2.y%8+1)));}
 662   7                                                              else if(s==0xff) {dwr(a|(0xff>>(7-p2.y%8)));}
 663   7                                                              else {dwr(a^(0xff>>(7-p2.y%8)));}
 664   7                                                      }
 665   6                                                      else 
 666   6                                                      {
 667   7                                                              if(s==0) {dwr(0);}
 668   7                                                              else if(s==0xff) {dwr(0xff);}
 669   7                                                              else {dwr(~a);}
 670   7                                                      }
 671   6                                              }
 672   5                                              else
 673   5                                              {
 674   6                                                      if(s==0) dwr(a&((0xff>>(8-p1.y%8))|(0xff<<(p2.y%8+1))));
 675   6                                                      else if(s==0xff) dwr(a|((0xff<<(p1.y%8))&(0xff>>(7-p2.y%8))));
 676   6                                                      else {dwr(a^((0xff<<(p1.y%8))&(0xff>>(7-p2.y%8))));}
 677   6                                              }
 678   5                                      }
 679   4                              }
 680   3                      }
 681   2              }
 682   1      }
 683          
 684          /*将8位的字模数据写入光标指定的位置进行显示*/
 685          void disp_one_modu(uchar m)
 686          {
 687   1              uchar a;
 688   1              if((cursor.x<128)&&(cursor.y<64))
 689   1              {
C51 COMPILER V7.06   LCDX1                                                                 02/28/2007 15:18:19 PAGE 16  

 690   2                      if(cursor.x<=63)
 691   2                      {
 692   3                              iwl(0xb8|cursor.y/8);  
 693   3                              iwl(0x40|cursor.x);
 694   3                              a=drl();
 695   3                              a=drl();
 696   3                              iwl(0x40|cursor.x);
 697   3                              dwl((m<<(cursor.y%8))|(a&(0xff>>(8-cursor.y%8))));
 698   3                              if((cursor.y+8)<64)
 699   3                              {
 700   4                                      iwl(0xb8|(cursor.y+8)/8);
 701   4                                      iwl(0x40|cursor.x);
 702   4                                      a=drl();
 703   4                                      a=drl();
 704   4                                      iwl(0x40|cursor.x);
 705   4                                      dwl((a&(0xff<<(cursor.y%8)))|(m>>(8-cursor.y%8)));
 706   4                              }
 707   3                      }
 708   2                      else
 709   2                      {
 710   3                              iwr(0xb8|cursor.y/8);
 711   3                              iwr(0x40|(cursor.x-64));
 712   3                              a=drr();
 713   3                              a=drr();
 714   3                              iwr(0x40|(cursor.x-64));
 715   3                              dwr((m<<(cursor.y%8))|(a&(0xff>>(8-cursor.y%8))));
 716   3                              if((cursor.y+8)<64)
 717   3                              {               
 718   4                                      iwr(0xb8|(cursor.y+8)/8);
 719   4                                      iwr(0x40|(cursor.x-64));
 720   4                                      a=drr();
 721   4                                      a=drr();
 722   4                                      iwr(0x40|(cursor.x-64));
 723   4                                      dwr((a&(0xff<<(cursor.y%8)))|(m>>(8-cursor.y%8)));
 724   4                              }
 725   3                      }
 726   2              }
 727   1              else
 728   1              {
 729   2                      if(cursor.x>=128) zf_ovx=1;
 730   2                      if(cursor.y>=64) zf_ovy=1;
 731   2              }
 732   1      }
 733          
 734          /*在光标处显示一个汉字,n是字库中的位置,width表示字符的宽度,pt为字库首地址,s为1表示正显,为0表示反显*/
 735          void disp_one_hz(uchar n,uchar width,uchar code *pt,bit s)
 736          {
 737   1              uchar a,i;
 738   1              uint b;
 739   1              a=cursor.x;
 740   1              zf_ovx=0;
 741   1              zf_ovy=0;
 742   1              for(i=0;i<width;i++)
 743   1              {
 744   2                      if(zf_ovx==0) {b=i+n*(width<<1);disp_one_modu(s?*(pt+b):~(*(pt+b)));}
 745   2                      cursor.x++;
 746   2                      if(cursor.x==128) zf_ovx=1;
 747   2              }
 748   1              zf_ovx=0;
 749   1              if((cursor.y+8)<64)//张工编的程序总会执行这句,所以不会出错
 750   1              {
 751   2                      cursor.x=a;
C51 COMPILER V7.06   LCDX1                                                                 02/28/2007 15:18:19 PAGE 17  

 752   2                      a=cursor.y;
 753   2                      cursor.y+=8;
 754   2              for(i=width;i<(width<<1);i++)
 755   2              {
 756   3                      if(zf_ovx==0) {b=i+n*(width<<1);disp_one_modu(s?*(pt+b):~(*(pt+b)));}
 757   3                      cursor.x++;
 758   3                      if(cursor.x==128) zf_ovx=1;
 759   3              }
 760   2              }
 761   1              cursor.y=a;//有错
 762   1              zf_ovx=0;
 763   1              zf_ovy=0;
 764   1      }
 765          
 766          /*显示电量指示的外框;s=0清除,s=1显示*/
 767          void disp_bat_edge(bit s)
 768          {
 769   1              point p1,p2;  //定义结构体变量p1,p2
 770   1              p1.x=93+5;
 771   1              p1.y=00;
 772   1              p2.x=110+5;
 773   1              p2.y=7;
 774   1              draw_rec(p1,p2,s);
 775   1              p1.x=111+5;
 776   1              p1.y=3;
 777   1              p2.x=112+5;
 778   1              p2.y=4;
 779   1              if(s) {draw_srec(p1,p2,0xff);}
 780   1              else {draw_srec(p1,p2,s);}
 781   1      }
 782          
 783          /*显示电量标志图:num为数值,s=1为显示,s=0为清除*/
 784          void disp_bat(uchar num,bit s)
 785          {
 786   1              uchar i;
 787   1              point p1,p2;
 788   1              if(num!=batnum)
 789   1              {
 790   2                      p1.x=94+5;
 791   2                      p1.y=1;
 792   2                      p2.x=109+5;
 793   2                      p2.y=6;
 794   2                      draw_srec(p1,p2,0);
 795   2              }
 796   1                      p1.x=95+5;
 797   1                      p1.y=2;
 798   1                      p2.x=98+5;
 799   1                      p2.y=5;
 800   1                      for(i=0;i<num;i++)
 801   1                      {
 802   2                              if(s) {draw_srec(p1,p2,0xff);}
 803   2                              else {draw_srec(p1,p2,s);}
 804   2                              p1.x+=5;
 805   2                              p2.x+=5;
 806   2                      }
 807   1                      batnum=num; //batnum尽在此处被赋值
 808   1      }
 809          
 810          /*显示横向条形图的数值,入口参数:cursor.x以及cursor.y */
 811          void transfer(uchar a)
 812          {
 813   1              if(a>=0&&a<10) {disp_one_hz(a,5,sntab,1);}
C51 COMPILER V7.06   LCDX1                                                                 02/28/2007 15:18:19 PAGE 18  

 814   1              else if(a==100) {disp_one_hz(1,5,sntab,1);disp_one_hz(0,5,sntab,1);disp_one_hz(0,5,sntab,1);}
 815   1              else
 816   1              {
 817   2                      disp_one_hz(a/10,5,sntab,1);
 818   2                      disp_one_hz(a%10,5,sntab,1);
 819   2              }
 820   1      }
 821          
 822          /*简易的条形图显示方式*/
 823          void disp_lbar2(uchar num)
 824          {
 825   1              point p1,p2;
 826   1              p1.y=19;
 827   1              p2.y=32;
 828   1              if(lbarnum!=num)
 829   1              {
 830   2                      if(lbarnum<num)                                         /*本次数据大于上一次的数据*/
 831   2                      {
 832   3                              p2.x=num-1;                                             /*显示本次数据的条形图*/
 833   3                              p1.x=lbarnum;
 834   3                              draw_srec(p1,p2,0xff);
 835   3                      }
 836   2                      else if(lbarnum>num)                            /*本次数据小于上一次的数据*/
 837   2                      {
 838   3                              p1.x=num;
 839   3                              p2.x=lbarnum-1;
 840   3                              draw_srec(p1,p2,0);
 841   3                      }
 842   2      
 843   2                      p1.x=lbarnum;                                           /*清除上一次条形图数字*/                        
 844   2                      p1.y=34;
 845   2                      p2.x=lbarnum+15;
 846   2                      p2.y=40;
 847   2                      draw_srec(p1,p2,0);
 848   2      
 849   2                      cursor.x=num;                                           /*显示本次条形图数字*/  
 850   2                      cursor.y=33;
 851   2                      transfer(num);
 852   2              }
 853   1              lbarnum=num;                                                    /*存储本次数据*/
 854   1      }
 855          
 856          /*显示横向条形图:num范围0_100
 857            显示方式:保持显示数值的极大值直到极小值出现。
 858          */
 859          bit direction;          /*代表上一次数据的变化方向,1为上升,0为下降*/
 860          uchar max;                      /*数值上升过程中的极大值*/
 861          bit set1;                       /*当极大值时下降一格后置1,标志如果继续下降将显示保持条及数字*/
 862          bit set2;                       /*代表上一次数值下降两格的情况(置1),区分本次数值上升时清除保持条及数字的不同*/               
 863          bit set3;                       /*代表上一次数值下降三格及以上的情况(置1),区分本次数值上升时清除保持条及数字的不同*/
 864          bit set4;                       /*当极大值时下降一格后由下降一格(显示保持条及数字)后置1,区分本次数值上升时清除保持条及数字

⌨️ 快捷键说明

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