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

📄 dph.c

📁 动平衡机 51单片机
💻 C
📖 第 1 页 / 共 5 页
字号:
            save_para[save_no].R_r=compen.R_r     ;
            save_para[save_no].t  =compen.t       ;
            save_para[save_no].speed=compen.speed ;
            save_para[save_no].range=compen.range ;
          }
          save_no++;
          if(save_no>99)  save_no=0;
          sprintf(lcd_buf[30],"    No. %02d&",save_no);
          break;
         }
       }

       void state03(void) 
       {
         uchar xdata i,c; 
         switch(key)
         {
          case 2:
          cp++;
          if(cp>7)
          {
          cp=0;
          busy();
          LCDS=0x86;
          }
          else if(cp==4)
          {
          busy();
          LCDS=0xc6;
          }
          else
          {
          busy();
          LCDS=0x14;
          }
          break;
          case 1:
          busy();
          c=LCDR;
          busy();
          LCDS=0x10;
          if(c>=0x39) c=0x30;
          else c++;
          busy();
          LCDD=c;
          busy();
          LCDS=0x10;
          break;
          case 3:
          menu_state=4;
          cp=0;
          re_scr=1;
          busy();
          LCDS=0x86;
          for(i=0;i<4;i++)
          {
          busy();
          c=LCDR;
          set_buf[i]=c;
          lcd_buf[6][i+6]=c;
          }
          set_buf[4]=0x00;
          compen.speed=atoi(set_buf); 
          busy();
          LCDS=0xc6;
          for(i=0;i<4;i++)
          {
          busy();
          c=LCDR;
          set_buf[i]=c;
          lcd_buf[7][i+6]=c;
          }
          set_buf[4]=0x00;
          compen.range=atoi(set_buf); 
          break;
         }
       }

       void state04(void)     /*11状态下各键功能*/
       {
         uchar xdata i,c; 
         switch(key)
         {
          case 2:
          if(cp==9) cp=0;
          else      cp++;
          if(cp==1)
          {
          busy();
          LCDS=0x87;
          }
          else if(cp==2)
          {
          busy();
          LCDS=0x88;
          }
          else if(cp==3)
          {
          busy();
          LCDS=0x89;
          }
          else if(cp==4)
          {
          busy();
          LCDS=0x8a;
          }

          else if(cp==5)
          {
          busy();
          LCDS=0xc5;
          }
          else if(cp==6)
          {
          busy();
          LCDS=0xc7;
          }
          else if(cp==7)
          {
          busy();
          LCDS=0xc8;
          }
          else if(cp==8)
          {
          busy();
          LCDS=0xc9;
          }
          else if(cp==9)
          {
          busy();
          LCDS=0xca;
          }

          else if(cp==0)
          {
          busy();
          LCDS=0x85;
          }
          break;
          case 1:
          busy();
          c=LCDR;
          busy();
          LCDS=0x10;
          if(c>=0x39) c=0x30;
          else c++;
          busy();
          LCDD=c;
          busy();
          LCDS=0x10;
          break;
          case 3:
          menu_state=5;
          cp=0;
          re_scr=1;
          busy();
          LCDS=0x85;
          for(i=0;i<6;i++)
          {
          busy();
          c=LCDR;
          set_buf[i]=c;
          lcd_buf[8][5+i]=c;
          }
          set_buf[6]=0x00;
          compen.kbl=atof(set_buf);
          busy();
          LCDS=0xc5;
          for(i=0;i<6;i++)
          {
          busy();
          c=LCDR;
          set_buf[i]=c;
          lcd_buf[9][5+i]=c;
          }
          set_buf[6]=0x00;
          compen.kbr=atof(set_buf);
          break;
         }
       }

       void state05(void)
       {
         uchar xdata i,c; 
         switch(key)
         {
          case 2:
          if(cp==11) cp=0;
          else      cp++;
          if(cp==0)
          {
           LCDS=0x87;
          }
          else if(cp==1)
          {
           LCDS=0x88;
          }
          else if(cp==2)
          {
           LCDS=0x8a;
          }
          else if(cp==3)
          {
           busy();
           LCDS=0x8b;
          }
          else if(cp==4)
          {
           LCDS=0x8c;
          }

          else if(cp==5)
          {
           busy();
           LCDS=0x8d;
          }

          else if(cp==6)
          {            
           busy();
           LCDS=0xc7;
          }
          else if(cp==7)
          {
           busy();
           LCDS=0xc8 ;
          }
          else if(cp==8)
          {
           busy();
           LCDS=0xca;
          }
          else if(cp==9)
          {
           busy();
           LCDS=0xcb;
          }
          else if(cp==10)
          {
           busy();
           LCDS=0xcc;
          }
          else if(cp==11)
          {
           busy();
           LCDS=0xcd;
          }

          break;
          case 1:
          busy();
          c=LCDR;
          busy();
          LCDS=0x10;
          if(c=='+')  c='-';
          else
          if(c=='-')  c='+';
          else 
          {
           if(c>=0x39) c=0x30;
           else c++;
          }
          busy();
          LCDD=c;
          busy();
          LCDS=0x10;
          break;
          case 3:
          menu_state=6;
          cp=0;
          re_scr=1;
          busy();
          LCDS=0x87;
          for(i=0;i<7;i++)
          {
          busy();
          c=LCDR;
          set_buf[i]=c;
          lcd_buf[10][i+7]=c;
          }
          set_buf[7]=0x00;
          compen.kfl=atof(set_buf);
          busy();
          LCDS=0xc7;
          for(i=0;i<7;i++)
          {
          busy();
          c=LCDR;
          set_buf[i]=c;
          lcd_buf[11][i+7]=c;
          }
          set_buf[7]=0x00;
          compen.kfr=atof(set_buf);
          break;
         }
       }

       void state06(void)
       {
        uchar xdata i,c; 
        switch(key)
         {
          case 2:
          cp++  ;
          if(cp==6)
          {
          cp=0;
          busy();
          LCDS=0x86;
          }
          else  if(cp==3)
          {
          busy();
          LCDS=0xc6;
          }
          else
          {
          busy();
          LCDS=0x14;
          }
          break;
          case 1:
          busy();
          c=LCDR;
          busy();
          LCDS=0x10;
          if(c>=0x39) c=0x30;
          else c++;
          busy();
          LCDD=c;
          busy();
          LCDS=0x10;
          break;
          case 3:
          menu_state=7;
          cp=0;
          re_scr=1;
          busy();
          LCDS=0x86;
          for(i=0;i<3;i++)
          {
          busy();
          c=LCDR;
          lcd_buf[12][i+6]=c;
          set_buf[i]=c;
          }
          set_buf[3]=0x00;
          compen.L_r=atoi(set_buf); 
          busy();
          LCDS=0xc6;
          for(i=0;i<3;i++)
          {
          busy();
          c=LCDR;
          lcd_buf[13][i+6]=c;
          set_buf[i]=c;
          }
          set_buf[3]=0x00;
          compen.R_r=atoi(set_buf);
          break;
         }
       }

       void state07(void)
       {
        uchar xdata i,c; 
        switch(key)
         {
          case 2:
          cp++  ;
          if(cp==6)
          {
          cp=0;
          busy();
          LCDS=0x86;
          }
          else  if(cp==3)
          {
          busy();
          LCDS=0xc6;
          }
          else
          {
          busy();
          LCDS=0x14;
          }
          break;
          case 1:
          busy();
          c=LCDR;
          busy();
          LCDS=0x10;
          if(c>=0x39) c=0x30;
          else c++;
          busy();
          LCDD=c;
          busy();
          LCDS=0x10;
          break;
          case 3:
          menu_state=8;
          cp=0;
          re_scr=1;
          busy();
          LCDS=0x86;
          for(i=0;i<3;i++)
          {
          busy();
          c=LCDR;
          lcd_buf[14][i+6]=c; 
          set_buf[i]=c;
          }
          set_buf[3]=0x00;
          compen.a=atoi(set_buf);  
          busy();
          LCDS=0xc6;
          for(i=0;i<3;i++)
          {
          busy();
          c=LCDR;
          lcd_buf[15][i+6]=c;
          set_buf[i]=c;
          }
          set_buf[3]=0x00;
          compen.b=atoi(set_buf); 

          break;
         }
       }

       void state08(void)
       {
        uchar xdata i,c; 
        switch(key)
         {
          case 2:
          cp++  ;
          if(cp==7)
          {
          cp=0;
          busy();
          LCDS=0x86;
          }
          else  if(cp==4)
          {
          busy();
          LCDS=0xc6;
          }
          else  if(cp==6)
          {
          busy();
          LCDS=0xc9;
          }
          else
          {
          busy();
          LCDS=0x14;
          }
          break;
          case 1:
          busy();
          c=LCDR;
          busy();
          LCDS=0x10;
          if(c>=0x39) c=0x30;
          else c++;
          busy();
          LCDD=c;
          busy();
          LCDS=0x10;
          break;
          case 3:
          menu_state=1;
          cp=0;
          re_scr=1;
          busy();
          LCDS=0x86;
          for(i=0;i<4;i++)
          {
          busy();
          c=LCDR;
          lcd_buf[16][i+6]=c;
          set_buf[i]=c;
          }
          set_buf[4]=0x00;
          compen.c=atoi(set_buf);
          busy();
          LCDS=0xc6;
          for(i=0;i<4;i++)
          {
          busy();
          c=LCDR;
          lcd_buf[17][i+6]=c;
          set_buf[i]=c;
          }
          set_buf[4]=0x00;
          compen.m=atof(set_buf);
          break;
         }
       }



       void state09(void)
       {
        switch(key)
         {
          case 1:
          if(cp==0)  cp=3;
          else       cp--;
          if(cp>=2)
          {
          busy();
          LCDS=0xc0+(cp-2)*8;
          }
          else

⌨️ 快捷键说明

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