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

📄 op.c

📁 变压器绕线机源代码, 经过测试,可以正常运作.
💻 C
字号:
//============================
//绕线机程序
//designor:zhu guangming
//date:2009-5-6
//============================

#ifndef __op_c__
#define __op_c__
#include "included.h"

//=====一位数据设置-1子程序,不管高位==========================
void sub_1(uint data_sram)
{ 
  char temp_data;

  temp_data =XBYTE[data_sram];
  temp_data &=0x0f;
  temp_data--;
  if(temp_data<0)
  temp_data=0x09;
  XBYTE[data_sram]=temp_data;
   
}
//========一位数据设置+1子程序,不管高位=======================
void add_1(uint data_sram)
{
  char temp_data;

  temp_data = XBYTE[data_sram];
  temp_data &=0x0f;
  temp_data++;
  if(temp_data>9)
  temp_data=0x00;
  XBYTE[data_sram]=temp_data;

}
//===二位数据设置+1子程序 ============================
void add_2(uint sram_add)
{
   uchar temp_data;
   uchar temp_data_1;

   temp_data = XBYTE[sram_add];
   temp_data_1=temp_data;
   temp_data &=0x0f;
   temp_data++;
   if(temp_data!=0x0a)
     {
        temp_data_1 &=0xf0;
        temp_data |=temp_data_1;
        XBYTE[sram_add]=temp_data;
     }
  else
    {
       temp_data_1 &=0xf0;
       temp_data_1 +=0x10;
       if(temp_data_1==0xa0)
        XBYTE[sram_add]=0;
       else 
        XBYTE[sram_add]=temp_data_1;  
     }
}
//====二位数据设置-1子程序===================
void sub_2(uint sram_add)
{
   uchar temp_data;
   uchar temp_data_1;

   temp_data = XBYTE[sram_add];
   temp_data_1=temp_data;
   temp_data &=0x0f;
   temp_data--;
   if(temp_data!=0xff)
     {
        temp_data_1 &=0xf0;
        temp_data |=temp_data_1;
        XBYTE[sram_add]=temp_data;
      }
   else
     {
        temp_data_1 &=0xf0;
        temp_data_1 |=0x09;
        temp_data_1  -=0x10;
        if(temp_data_1 == 0xf9) 
          XBYTE[sram_add]=0x99;
        else
          XBYTE[sram_add]=temp_data_1; 
     }
}
//==========;一位数据设置子程序=====================
uchar  pa_1(uint sram_add,uchar spd)
{
  uchar value;
 
  while(1)
  {
     value = key();

     if(value ==11)
         {
             speak();
             return 0;
               }
     else if(value ==12)
         {
             speak();
             return 1;
               }
        
     else if(value ==13)
         {
           speak();
           add_1(sram_add);
           dis_p(spd);
               }
     else if(value ==14)
         {
           speak();
           sub_1(sram_add);
           dis_p(spd);
               }
      else if(value ==15)
         {
           speak();
           run();
           break;
               }
         else if((value>=0)&&(value<=9))
           {
             speak();
              XBYTE[sram_add]=value;
              dis_p(spd);   
             }
    }
}

//=====二位数据设置子程序====================
uchar pa_2(uint sram_add,uchar spd)
{
  uchar value;
  uchar temp_data;
  
   while(1)
     {
 
          value = key();
          if(value ==11)
           {
                speak();
                return 0;
               }
         else if(value ==12)
         {
             speak();
             return 1;
               }
        
        else if(value ==13)
         {
           speak();
           add_2(sram_add);
           dis_p(spd);
               }
       else if(value ==14)
         {
           speak();
           sub_2(sram_add);
           dis_p(spd);
               }
      else if(value ==15)
         {
           speak();
           run();
               }
         else if((value>=0)&&(value<=9))
           {
             speak();
              XBYTE[sram_add]=value;
              dis_p(spd); 
              break;  
             }
       
      }

//============================
    while(1)
         {
           value = key();

          if(value ==11)
             {
                speak();
                return 0;
                }
             else if(value ==12)
                 {
                    speak();
                   return 1;
                       }
        
            else if(value ==13)
                  {
                    speak();
                    add_2(sram_add);
                    dis_p(spd);
                  }
            else if(value ==14)
                 {
                   speak();
                   sub_2(sram_add);
                   dis_p(spd);
                 }
           else if(value ==15)
                {
                   speak();
                  run();;
               }
         else if((value>=0)&&(value<=9))
           {
            speak();
            value &=0x0f;
            temp_data=XBYTE[sram_add];
            temp_data =temp_data<<4;
            temp_data |=value;
            XBYTE[sram_add]=temp_data;
            dis_p(spd);
           
             }                    
       }      
 }
//============================
uchar pa_3(uint sram_add,uchar spd)
{
  uchar value,temp;
  uchar temp_data;

   while(1)
     {
  
          value = key();
          if(value ==11)
           {
                speak();
                return 0;
               }
         else if(value ==12)
         {
             speak();
             return 1;
               }
        
        else if(value ==13)
         {
           speak();
           add_2(sram_add);
           dis_p(spd);
               }
       else if(value ==14)
         {
           speak();
           sub_2(sram_add);
           dis_p(spd);
               }
      else if(value ==15)
         {
           speak();
           run();
               }
         else if((value>=0)&&(value<=9))
           {
              speak();
              XBYTE[sram_add]=value;
              sram_add--;
              XBYTE[sram_add]=0;
              sram_add++;
              dis_p(spd); 
              break;  
             }
      }

//============================
   while(1)
         {
           value = key();

          if(value ==11)
             {
                speak();
                return 0;
                }
             else if(value ==12)
                 {
                    speak();
                   return 1;
                       }       
             else if(value ==13)
                  {
                    speak();
                    add_2(sram_add);
                    dis_p(spd);
                  }
             else if(value ==14)
                 {
                   speak();
                   sub_2(sram_add);
                   dis_p(spd);
                 }
             else if(value ==15)
                {
                   speak();
                  run();
                   break;
               }
         else if((value>=0)&&(value<=9))
           {
            speak();
            value &=0x0f;
            temp_data=XBYTE[sram_add];
            temp_data =temp_data<<4;
            temp_data |=value;
            XBYTE[sram_add]=temp_data;
            dis_p(spd);
            break;
             }
         } 
    //===============================
         while(1)
         {
           value = key();

          if(value ==11)
             {
                speak();
                return 0;
                }
             else if(value ==12)
                 {
                    speak();
                   return 1;
                       }
        
            else if(value ==13)
                  {
                    speak();
                    add_2(sram_add);
                    dis_p(spd);
                  }
            else if(value ==14)
                 {
                   speak();
                   sub_2(sram_add);
                  dis_p(spd);
                 }
           else if(value ==15)
                {
                   speak();
                  run();
                   break;
               }
         else if((value>=0)&&(value<=9))
           {
            speak();
            value &=0x0f;
            temp_data=XBYTE[sram_add];
            temp     = temp_data;
            temp_data =temp_data>>4;
            sram_add--;
            XBYTE[sram_add]=temp_data;
            temp  = temp<<4;

            temp|=value;
            sram_add++;
            XBYTE[sram_add]=temp;
            dis_p(spd);
           
              }
         }   
}
//================================
//四位数据设置子程序========
uchar pa_4(uint sram_add,uchar spd)
{
  uchar value,temp,temp_0,temp_1,temp_2;
  uchar temp_data;

   while(1)
     {
          value = key();
          if(value ==11)
           {
                speak();
                return 0;
               }
         else if(value ==12)
         {
             speak();
             return 1;
               }
        
        else if(value ==13)
         {
           speak();
           add_2(sram_add);
           dis_p(spd);
               }
       else if(value ==14)
         {
           speak();
           sub_2(sram_add);
           dis_p(spd);
               }
         else if(value ==15)
         {
           speak();
           run();
            break;
               }
         else if((value>=0)&&(value<=9))
           {
              speak();
              XBYTE[sram_add]=value;
              dis_p(spd); 
              sram_add--;
              XBYTE[sram_add]=0;
              sram_add++;
              break;  
             }      
      }

//============================
         while(1)
         {
           value = key();
          if(value ==11)
             {
                speak();
                return 0;
                }
             else if(value ==12)
                 {
                    speak();
                   return 1;
                       }
        
            else if(value ==13)
                  {
                    speak();
                    add_2(sram_add);
                    dis_p(spd);
                  }
            else if(value ==14)
                 {
                   speak();
                   sub_2(sram_add);
                  dis_p(spd);
                 }
           else if(value ==15)
                {
                   speak();
                  run();
                   break;
               }
         else if((value>=0)&&(value<=9))
           {
            speak();
            value &=0x0f;
            temp_data=XBYTE[sram_add];
            temp_data =temp_data<<4;
            temp_data |=value;
            XBYTE[sram_add]=temp_data;
            dis_p(spd);
            break;
             }
         } 
    //===============================
         while(1)
         {
           value = key();
          if(value ==11)
             {
                speak();
                return 0;
                }
             else if(value ==12)
                 {
                    speak();
                   return 1;
                       }
        
            else if(value ==13)
                  {
                    speak();
                    add_2(sram_add);
                    dis_p(spd);
                  }
            else if(value ==14)
                 {
                   speak();
                   sub_2(sram_add);
                  dis_p(spd);
                 }
           else if(value ==15)
                {
                   speak();
                  run();
                   break;
               }
         else if((value>=0)&&(value<=9))
           {
            speak();
            value &=0x0f;
            temp_data=XBYTE[sram_add];
            temp     = temp_data;
            temp_data =temp_data>>4;
            sram_add--;
            XBYTE[sram_add]=temp_data;
            temp  = temp<<4;

            temp|=value;
            sram_add++;
            XBYTE[sram_add]=temp;
            dis_p(spd);
            break;
              }
         } 
//============================= 
         while(1)
         {
           value = key();
          if(value ==11)
             {
                speak();
                return 0;
                }
             else if(value ==12)
                 {
                    speak();
                   return 1;
                       }
        
            else if(value ==13)
                  {
                    speak();
                    add_2(sram_add);
                    dis_p(spd);
                  }
            else if(value ==14)
                 {
                   speak();
                   sub_1(sram_add);
                  dis_p(spd);
                 }
           else if(value ==15)
                {
                   speak();
                 run();
                   break;
               }
         else if((value>=0)&&(value<=9))
           {
            speak();
            value &=0x0f;
//=======================
            sram_add--;            
            temp_data=XBYTE[sram_add];//h
            temp_0    = temp_data;
//=======================
             sram_add++;
            temp_1=XBYTE[sram_add];   //l
            temp_2=temp_1;
            temp_1 <<=4;
            temp_1 |=value;
            XBYTE[sram_add]=temp_1;  //l
            //**************

            temp_2 >>=4;
            temp_data <<=4;

            temp_data|=temp_2;
            sram_add--;
            XBYTE[sram_add]=temp_data;
            sram_add++;
            dis_p(spd); 
                    
              } 
             
         }    
 }
//==========================
#endif

⌨️ 快捷键说明

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