12684メニュー機能実装


/*******************************
*    ,         ,         ,       ,
*       ,      。        
/*******************************


//***************************************//
//    :choose
//    : 
//    :       
//**************************************//
void Choose()//     
{
	unsigned char Key_data = 0x00;
	Key_data = Key();
	switch(Key_data)
	{
	 	case 0x01: 			   //Up_key
		{
			Up_Func();			//  UP  
			Index = Menu_Tab[Index].Up_data;	// Index  
			LCD12864_Clean();									//    
			(*(Menu_Tab[Index].Operate))(); 	//      
			break;
		}
		case 0x02: 			   //Down_key
		{
			Down_Func();
			Index = Menu_Tab[Index].Down_data; 
			LCD12864_Clean();
			(*(Menu_Tab[Index].Operate))();
			break;
		}
		case 0x03: 			   //Left_key
		{
			Left_Func();
			Index = Menu_Tab[Index].Left_data; 
			LCD12864_Clean();
			(*(Menu_Tab[Index].Operate))();
			break;
		}
		case 0x04: 			   //Right_key
		{
			Right_Func();
			Index = Menu_Tab[Index].Right_data;
			LCD12864_Clean();
			(*(Menu_Tab[Index].Operate))();
			break;
		}
		case 0x05: 			   //Ok_key
		{
			Ok_Func();
			Index = Menu_Tab[Index].Ok_data;
			LCD12864_Clean();
			(*(Menu_Tab[Index].Operate))();
			break;
		}
		case 0x06: 			   //Ese_key
		{
			Ese_Func();
			Index = Menu_Tab[Index].Ese_data;
			LCD12864_Clean();
			(*(Menu_Tab[Index].Operate))();
			break;
		}
	}
}

//***************************************//
//    :Up_Func
//    : 
//    :         
//**************************************//

void Up_Func()
{
	if(Index >= 1 && Index <= 3)								// main   Up    
	{	
		Main_Menu_Index--;
		if(Main_Menu_Index == 0xff)								
		{
			Main_First_Index = 3-3;									//Main_First_Index   Main_Menu_Index       :
			Main_Menu_Index  = 2;										//          ,    ,                   
		}
		else if(Main_Menu_Index == (Main_First_Index - 1))
		{
			
			Main_First_Index--;
		}	
	}
	
	//                 ,          
	/*
	if((Index >= 5 && Index <= 7)||Index==16)								// Work_mode   Up    
	{	
		Work_mode_Menu_Index--;
		if(Work_mode_Menu_Index == 0xff)
		{
			Work_mode_First_Index = 4-3;
			Work_mode_Menu_Index  = 3;	
		}
		else if(Work_mode_Menu_Index == (Work_mode_First_Index - 1))
		{
			
			Work_mode_First_Index--;
		}	
	}
	if(Index >= 8 && Index <= 9)								// Zizhu_mode   Up    
	{	
		Zizhu_mode_Menu_Index--;
		if(Zizhu_mode_Menu_Index == 0xff)
		{
			Zizhu_mode_Menu_Index  = 1;	
		}	
	}

		if(Index >= 17 && Index <= 18)								// Zizhu_mode   Up    
	{	
		Duibi_mode_Menu_Index--;
		if(Duibi_mode_Menu_Index == 0xff)
		{
			Duibi_mode_Menu_Index  = 1;	
		}	
	}


	if(Index == 4)												// Work_param   Up    
	{
		Work_param_Menu_Index--;
		if(Work_param_Menu_Index == 0xff)
		{
			Work_param_First_Index = 0;
			Work_param_Menu_Index  = 2;	
		}
		else if(Work_param_Menu_Index == (Work_param_First_Index - 1))
		{
			
			Work_param_First_Index--;
		}
	}
	if(Index == 11)												// Shoudong_mode   Up    
	{
		Shoudong_mode_Menu_Index--;
		if(Shoudong_mode_Menu_Index == 0xff)
		{
			Shoudong_mode_First_Index = 4-3;
			Shoudong_mode_Menu_Index  = 3;	
		}
		else if(Shoudong_mode_Menu_Index == (Shoudong_mode_First_Index - 1))
		{
			
			Shoudong_mode_First_Index--;
		}
	}
	if(Index == 12 || Index == 13 || Index ==25)								// System_set   Up    
	{	
		System_set_Menu_Index--;
		if(System_set_Menu_Index == 0xff)
		{
			System_set_First_Index = 3-3;
			System_set_Menu_Index  = 2;	
		}
		else if(System_set_Menu_Index == (System_set_First_Index - 1))
		{
			
			System_set_First_Index--;
		}	
	}
	if(Index == 14)												// Time_set   Up    
	{
		Time_set_Menu_Index--;
		if(Time_set_Menu_Index == 0xff)
		{
			Time_set_Menu_Index = 5;
		}
	}
	if(Index == 15)												// Work_param   Up    
	{
		Work_time_Menu_Index--;
		if(Work_time_Menu_Index == 0xff)
		{
			Work_time_First_Index = 8-3;
			Work_time_Menu_Index  = 7;	
		}
		else if(Work_time_Menu_Index == (Work_time_First_Index - 1))
		{
			
			Work_time_First_Index--;
		}
	}
	if(Index == 20 || Index == 21)								// System_param   Up    
	{
		System_param_Menu_Index--;
		if(System_param_Menu_Index == 0xff)
		{
			System_param_Menu_Index = 1;
		}
	}
	if(Index == 22)												// Warm_info   Up    
	{
		Warm_infor_Menu_Index--;
		if(Warm_infor_Menu_Index == 0xff)
		{
			Warm_infor_Menu_Index = 16;
		}
	}
}*/


typedef struct													 //       
{
  unsigned char  Index_data;               								 //        	          
	unsigned char  Up_data;                 									 //        
	unsigned char  Down_data;                								 //        
	unsigned char  Left_data;												 //        
	unsigned char  Right_data;               								 //        
	unsigned char  Ok_data;               									 //        	
	unsigned char  Ese_data;													 //        
	void   (*Operate)();	    								 //          
}   StateTab;

/*********************    ***********************/                     //   ,   ,       
code StateTab Menu_Tab[27]=										 //      
{
		/*---Index--Up---Down--Left--Right--Ok--Ese--Operate--------*/
		{	   0,	 		0,	   0,			0,	   0,	 1,	  0,     (*Home_Show)    	     },  //        ,    OK ,Index = 1
		{	   1,	 		3,	   2,			1,	   1,	 23,  0,     (*Main_Show)    	     },	 //(*(Menu_Tab[Index].Operate))();      Main_Show  
		{	   2,	 		1,	   3,			2,	   2,	 20,  0,     (*Main_Show)   	     },  //  ,  Main    ,    OK    Index = 23
		{	   3,	 		2,	   1,			3,	   3,	 12,  0,     (*Main_Show)    	     },	 //    Password_menu_Show    
		/************************      ************************/
		{	   4,	 		4,	   4,			4,	   4,	 4,	  9,     (*Work_param_Show)      },//      ,            ,     
		
		/************************        ********************/
		{	   23,	 23,   23,  23,    23,   23,   1,    (*Password_menu_Show)   },
		{	   24,	 24,   24,  24,    24,   5,   24,    (*Password_menu_Show)   },
		/************************      ************************/
		{	   25,	 13,   12,	25,	   25,	 26,   3,    (*System_set_Show)      },
		/************************      ************************/
		{	   26,	 26,   26,	26,	   26,	 26,   3,    (*Password_set_menu_Show) },
};

//***************************************//
//    :Main_Show
//    : 
//    :         
//**************************************//
void Main_Show()
{
	Show_Menu(1,Main_menu,Main_First_Index,Main_Menu_Index);
}
//**********************************************************
//    :void Show_Menu(unsigned char kong,unsigned char *(*p),unsigned char First_Index,unsigned char Menu_Index)
//    :   、 、        
//    :unsigned char kong,unsigned char *(*p),unsigned char First_Index,unsigned char Menu_Index
//    :        (kong*16   ),      ,       ,        
//    : 
//    : 
//  :     16*8       ,         
//**********************************************************

void Show_Menu(unsigned char kong,unsigned char *(*p),unsigned char First_Index,unsigned char Menu_Index)
{
	unsigned char a,b,c;
	if(First_Index == Menu_Index)					  	//                      
	{
		a = 1;
		b = 0;
		c = 0;
	}
	if((First_Index + 1) == Menu_Index)				
	{
		a = 0;
		b = 1;
		c = 0;
	}
	if((First_Index + 2) == Menu_Index)
	{
		a = 0;
		b = 0;
		c = 1;
	}
	if(Menu_Index == 0xff)
	{
		a = 0;
		b = 0;
		c = 0;
	}
	Serial_DisplayStrings_WithFistaddress(0x90+kong,p[First_Index],a);
	Serial_DisplayStrings_WithFistaddress(0x88+kong,p[First_Index+1],b);
	Serial_DisplayStrings_WithFistaddress(0x98+kong,p[First_Index+2],c);  	 
}