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

📄 key.bak

📁 C51单片机一个小项目源程序:包含液晶12232驱动,AD7705驱动,按键扫描及单片机内部EEPROM的驱动,是一个比较值得参考的源程序
💻 BAK
📖 第 1 页 / 共 2 页
字号:
#include "mylib.h"
uchar countclr;
uchar  KEY_NO,count1=0,count2=0,count3=0,count4=0;
uint Ch1k,Ch2k,AD_data;
uint k_ch1a,k_ch1b,k_ch2a,k_ch2b;
uint k_1;
uint k_max1a=0,k_max1b=0,k_max2a=0,k_max2b=0;
extern Ck1,Ck2;
uint AD_getvalue1[2]={0,0};
uint AD_getvalue2[2]={0,0};
uint AD_getvalue3[2]={0,0};
uint AD_getvalue4[2]={0,0};
uchar Turnaround_CornerORPower_Value[2]={0,0};
uchar Turnaround_CornerORPower_Value2[4]={0,0,0,0};
uchar Turnaround_CornerORPower_Value3[4]={0,0,0,0};

uchar Turnaround_CornerValue1[4]={0,0,0,0};
uchar Turnaround_Power_Value2[4]={0,0,0,0};

float  Nt=0,Nt1=0,Nt2=0,Nt3=0,Nt4=0;
uint max1=0,max2=0,max3=0,max4=0;
uchar data MENU_NO;
uchar data MENU_MENU1_NO;
uchar data MENU_MENU2_NO;
uchar  Data_AD[4];
//uchar Baudrate;
extern uint  k;
extern uint Turnaround_Corner_0,Turnaround_Corner_360;
extern uint Turnaround_Power_0,Turnaround_Power_200;
extern uchar i,serio_data;
extern uint  j,ReaddataChx;
extern uchar idata buf_data[4];
uchar ChoiceSend=0;

void key()
{
  KEY_NO=0;
  if((P2&0x1f)!=0x1f)
  {
	  delay();
	  delay();
	  //delay();
	  //Wait7705(10);
	  if((P2&0x1f)!=0x1f)
	  {
	     Bell=0;
		 Led=0;
		 Wait7705(6000);
	  }
	  Led=1;
	  Bell=1;
	  KEY_NO=(P2&0x1f);
	  KEY_NO=~KEY_NO;
      KEY_NO&=0x1f;
     switch(KEY_NO)
    {	  
        case 1:	    
           KEY_NO=1;
           break;
        case 2:
		   KEY_NO=2;
           break;
		case 4:
		   KEY_NO=3;
		   break;
		case 8:
		   KEY_NO=4;
		   break; 
		case 16:
		   KEY_NO=5;
		   break;  
        default:
           KEY_NO=0;
           break;
     }
  }		
     if(KEY_NO!=0)
	 {
	    keyprocess(KEY_NO); 
	 }
}
void keyprocess(uchar KEY_NO)
{    
	switch(MENU_NO)
	{     
		case IDMENU_TEST://测量屏
		      MENU_MENU1_NO=1;
		      switch(KEY_NO)
		      {
		    	  MENU_MENU1_NO=1;
				  case 1:
						  ISP_CONTR=0x60;	 //复位
				          break;
			      case 2:	  
				          Biao_ding(); 		 //标定选择
				          break;      
			      case 3:
				          //SetSerio=1;
				          Turnaround_Corner_test3();
				          break;
				  case 4: 
						  Turnaround_Corner_test();
				          break;
				  case 5: 
				          Turnaround_Corner_test2();
				          break;
				  default:
			              break;
		      }
		      break;
		case Bd_jm:	                                    //标定选择界面
			switch(KEY_NO)
			{	
		        	case 1:
					       ISP_CONTR=0x60;	            //复位
			          	   break;
				    case 2:	                            //选择扭矩或转向角标定
                        switch(MENU_MENU2_NO)
				        {	
				            case 1:	         					 	  
								  Turnaround_Power();	//扭矩零位标定
					              break;
				            case 2:    					              
							      Turnaround_Corner();	//转向角零位标定
					              break;      
					   	    default:
				              	  break;
					    }
			          	    break;      
				    case 3:	                            //向上选择子菜单 
			          	    turn_up(0);
			          	    break;
					case 4: 
						    Turnaround_Corner_test();
				            break;
				    default:
			          	    break;
		      }
			  break;
	   case Turnaround_Power_ling:                      
	   {		  
	         switch(KEY_NO)
			 {
			       case 1:
						  ISP_CONTR=0x60;				  //复位
						  break;
				   case 2:
				          Turnaround_Power_ling_data();	  //扭矩零位确定界面
						  break;
				   case 3:
				          Biao_ding();					  //返回标定选择界面
						  break;
				   default:break;
	          }
	   }
	   break;
	   case Turnaround_Power_20NM:	                      //扭矩20N.M标定
	   {
	         switch(KEY_NO)
		     {
			     case 1:
				          ISP_CONTR=0x60;				  //复位
						  break;
				  case 2:
				          Turnaround_Power_20_data();	  //扭矩20N.M确定界面
						  break;
				  case 3: 
						  Biao_ding();					  //返回标定选择界面
						  break; 		  		  				          
				  default:break;
			 }
		}
		break;
		case Turnaround_Corner_ling:	        		  //转向角零位标定界面
		{
			  switch(KEY_NO)
			 {
			       case 1:
						  ISP_CONTR=0x60;			      //复位
						  break;
				   case 2:
					      Turnaround_Corner_ling_data();  //转向角零位确定界面
						  break;
				   case 3:
				          Biao_ding();		              //返回标定选择界面
						  break;
				   default:break;
	          }
		}
		break;
		case Turnaround_Corner_20NM:		              //转向角360标定界面
		{
		   	 switch(KEY_NO)
		     {
			     case 1:
				          ISP_CONTR=0x60;				  //复位
						  break;
				  case 2:
						  Turnaround_Corner_20_data();	  //转向角360标定确定界面
						  break;
				  case 3: 
                          Biao_ding();					  //返回标定选择界面
						  break; 		  		  				          
				  default:break;
			 }
		}
		break;
		case Turnaround_Corner_Tstg:
		{
			 switch(KEY_NO)
		     {
			     case 1:
				          ISP_CONTR=0x60;				  
						  break;
				  case 2:
						  Biao_ding(); 
						  break;		   		  		  				          
				  default:break;
			 }
		}
		break;
		case Turnaround_Corner_Tstg2:
		{
		  	 switch(KEY_NO)
		     {
			      case 1:
				          ISP_CONTR=0x60;				  
						  break;
				  case 2:
						  Biao_ding(); 
						  break;
				  case 5:
				          test2();
				          break;		  		   		  		  				          
				  default:break;
			 }
		}
		break;
		case Turnaround_Corner_Tstg3:
		      switch(KEY_NO)
		     {
			      case 1:
				          ISP_CONTR=0x60;				  
						  break;		  		   		  		  				          
				  default:break;
			 }
		break;
		default:
		break;
	 	}	   
}
void RTDkey()
{
   switch(MENU_NO)
   {
       case 1:
	   case 10:
	   {
	       Test_Case_9();
	   }	   
	   break;
	   case 3:
	   case 5:
	   {
	      CH2_init();
		  k=filter(0);
		  display_num(1,80,1,1,1,k);
	   }
	   break;
	   case 4:
	   case 6:
	   {
	   	  CH1_init();
		  k=filter(1);
		  display_num(1,80,1,1,1,k);
	   }
	   break;
	   case 7:
	   {
	      Turnaround_CornerORPower_SendValue(); 
	   }
	   break;
	   case 8:
	   {
	   	  Turnaround_CornerORPower_SendORnot();
	   }
	   break;
	   default:
	   break;
   }
}


void test2()
{
        SetSerio=1;
        send_char(0xaa);		     //左转角
		delay();
		send_string_com(Turnaround_CornerORPower_Value2,2);
		delay();
		send_char(0xbb);			 //右转角
		send_string_com(Turnaround_CornerORPower_Value2+2,2);
		delay();
		send_char(0xcc);			 //左转矩
		delay();
		send_string_com(Turnaround_CornerORPower_Value3,2);
		delay();
		send_char(0xdd);			  //右转矩
		send_string_com(Turnaround_CornerORPower_Value3+2,2);
		//SetSerio=1;
		Turnaround_CornerORPower_Value2[0]=0;
	    Turnaround_CornerORPower_Value2[1]=0;
		Turnaround_CornerORPower_Value2[2]=0;
	    Turnaround_CornerORPower_Value2[3]=0;

		Turnaround_CornerORPower_Value3[0]=0;
	    Turnaround_CornerORPower_Value3[1]=0;
		Turnaround_CornerORPower_Value3[2]=0;
	    Turnaround_CornerORPower_Value3[3]=0;

		AD_getvalue1[0]=AD_getvalue1[1]=0;
        AD_getvalue2[0]=AD_getvalue2[1]=0;
		AD_getvalue3[0]=AD_getvalue3[1]=0;
		AD_getvalue4[0]=AD_getvalue4[1]=0;

		k_max1a=k_max1b=k_max2a=k_max2b=0;
		MENU_NO=8;
	    MENU_MENU1_NO=8;
	    EA=0;

⌨️ 快捷键说明

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