| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include "Menu.h"
- #define uchar u8
- #define code const
- typedef struct
- {
- uchar KeyStateIndex ; //当前状态索引号
- uchar KeyDnState ; //按下 “向下” 键时转向的状态索引号
- uchar KeyUpState ; //按下 “向上” 键时转向的状态索引号
- uchar KeyCrState ; //按下 “回车” 键时转向的状态索引号
- uchar KeyBackState ; //按下 “退回” 键时转向的状态索引号
- void ( *CurrentOperate ) ( ) ; //当前状态应该执行的功能操作
- } KbdTabStruct ;
- #define SIZE_OF_KEYBD_MENU 55 //菜单总长度
- KbdTabStruct code KeyTab[SIZE_OF_KEYBD_MENU] =
- {
- /*
- {0 ,0 ,0 ,1 ,0 , ( *MainJob1) } ,
- {1 ,7 ,2 ,8 ,0 , ( *Dsp Point) } , //第一层
- {2 ,1 ,3 ,8 ,0 , ( *DspCurve) ) , //第一层
- {3 ,2 ,4 ,36 ,0 , ( *Dsp Kout) } , //第一层
- {4 ,3 ,5 ,50 ,0 , ( *DisCloseDown) } , //第一层
- {5 ,4 ,6 ,8 ,0 , ( *ModifyPoint) } , //第一层
- {6 ,5 ,7 ,52 ,0 , ( *SetCloseDown) } , //第一层
- {7 ,6 ,1 ,0 ,0 , ( *Cancel) } , //第一层
- // ....
- // ....
- {52 ,53 ,53 ,0 ,1 , ( *OkSetCloseDown1) } ,
- {53 ,52 ,52 ,0 ,1 , ( *OkSetCloseDown2) } ,
- {54 ,0 ,0 ,0 ,0 , ( *Disable) } ,
- */
- };
- uchar KeyFuncIndex = 0; //当前画面索引号
- /*
- 1.由当前画面的[按键],找到下个画面
- 2.在下个画面,执行对应程序
- */
- void GetKeylnput ( void )
- {
- void *KeyFuncPtr = NULL;
- switch ( status & 0xf0 )
- {
- case 0xe0 : //回车键,找出新的菜单状态编号
- KeyFuncIndex = KeyTab[ KeyFuncIndex ].KeyCrState ;
- break ;
- case 0xb0 : //向下键,找出新的菜单状态编号
- KeyFuncIndex = KeyTab[ KeyFuncIndex ].KeyDn2State ;
- break ;
- case 0xd0 : //向上键,找出新的菜单状态编号
- KeyFuncIndex = KeyTab[ KeyFuncIndex ].KeyUp2State ;
- break ;
- case 0x70 : //回退键,找出新的菜单状态编号
- KeyFuncIndex = KeyTab[ KeyFuncIndex ].KeyBack2State ;
- break ;
- case 0 ;
- return;
- //错误的处理
- break ;
- }
- KeyFuncPtr = KeyTab[ KeyFuncIndex ].CurrentOperate ;
- ( *KeyFuncPtr ) () ; //执行当前按键的操作
- }
|