程序中的菜单架构提取出来,让大家查看更直观。
/* 菜单架构 */ typedef struct { INT8U KeyTab_MenuIndex; // 当前状态索引号 INT8U KeyTab_MaxItems; // 本级菜单最大条目数 INT8U KeyTab_PressOk; // 按下"回车"键时转向的状态索引号 INT8U KeyTab_PressEsc; // 按下"返回"键时转向的状态索引号 INT8U KeyTab_PressDown; // 按下"向下"键时转向的状态索引号 INT8U KeyTab_PressUp; // 按下"向上"键时转向的状态索引号 void (*CurrentOperate)( void ); // 当前状态应该执行的功能操作 }KeyTabStruct; void ( *KeyFuncPtr )( void ); // 按键功能指针 /*--------------------------------显示菜单(字库)----------------------------*/ INT8U *TestFace[3]={ "测试中", "当前端口", "接触电流" }; INT8U *Power[3]={ "设定电压", "当前电压", "工作电流" }; INT8U *MenuRoot[5]={ "一设备类型", "二端口设定", "三参数设置", "四系统设定", "五关闭系统" }; INT8U MenuRootID[5]={EUTtype,PortSet,Paramete,SystemSet,ShutOff}; INT8U *MenuEutTpye[4] ={ "壹类", "贰类", "接地", "不接地" }; INT8U MenuPortID[9] ={Port0,Port1,Port2,Port3,Port4,Port5,Port6,Port7,Port8}; INT8U *MenuParam[4] ={ "电源电压", "测试时间", "间隔时间", "外部采样" }; INT8U MenuParamID[4] ={Voltage,Testtime,Spacetime,Exterior}; INT8U *MenuSystem[3] ={ "时间设定", "背光设定", "键音设定" }; INT8U MenuSystemID[3] ={Time,Backlight,Buzzer}; INT8U *MenuBackLight[2] ={ "绿光", "红光" }; INT8U MenuBackLightID[2] ={Green,Red}; INT8U *Adjust[1]={ "校正因子" }; INT8U*Msg[7] = { "启动中…", "关机中…", "已保存!", "电源电压不稳", "请稍等!", "合格", "不合格!" }; /*-----------------------------------按键架构---------------------------------*/ /*CurMenuID = 本菜单ID MaxMenuItem = 同级菜单最大项数 OkMenuID = 子菜单层所对应的菜单ID,ID=255为菜单已经到底了 EscMenuID = 父菜单层所对应的菜单ID,ID=255为菜单已经到顶了 DownMenuID = 弟菜单层所对应的菜单ID,ID=255为菜单是独生子 UpMenuID = 兄菜单层所对应的菜单ID,ID=255为菜单是独生子 CurFunction = 本菜单所对应的菜单函数指针 */ KeyTabStruct KeyTab[MAX_KEYTABSTRUCT_NUM]={ /* CurID Max Ok Esc Down Up CurFunction */ {FACE, 0, Menu, Menu, 255, 255, *FunctionNul }, {Menu, 5, EUTtype, FACE, PortSet, ShutOff, *FunctionNul }, {EUTtype, 2, I_type, Menu, PortSet, ShutOff, *FunctionNul }, {I_type, 0, 255, EUTtype, II_type, II_type, *Function_I }, {II_type, 0, 255, EUTtype, I_type, I_type, *Function_II }, {PortSet, 9, Port0, Menu, Paramete, EUTtype, *FunctionNul }, {Port0, 0, 255, PortSet, Port1, Port8, *Function_Port }, {Port1, 0, 255, PortSet, Port2, Port0, *Function_Port }, {Port2, 0, 255, PortSet, Port3, Port1, *Function_Port }, {Port3, 0, 255, PortSet, Port4, Port2, *Function_Port }, {Port4, 0, 255, PortSet, Port5, Port3, *Function_Port }, {Port5, 0, 255, PortSet, Port6, Port4, *Function_Port }, {Port6, 0, 255, PortSet, Port7, Port5, *Function_Port }, {Port7, 0, 255, PortSet, Port8, Port6, *Function_Port }, {Port8, 0, 255, PortSet, Port0, Port7, *Function_Port }, {Paramete, 3, Voltage, Menu, SystemSet, PortSet, *FunctionNul }, {Voltage, 0, 255, Paramete, Testtime, Exterior, *Function_Paramet}, {Testtime, 0, 255, Paramete, Spacetime, Voltage, *Function_Paramet}, {Spacetime, 0, 255, Paramete, Exterior, Testtime, *Function_Paramet}, {Exterior, 0, 255, Paramete, Voltage, Spacetime,*Function_Paramet}, {SystemSet, 3, Time, Menu, ShutOff, Paramete, *Function_System }, {Time, 7, Year, SystemSet, Backlight, Buzzer, *FunctionNul }, {Year, 0, 255, Time, Month, Second, *Function_Time }, {Month, 0, 255, Time, Day, Year, *Function_Time }, {Day, 0, 255, Time, Week, Month, *Function_Time }, {Week, 0, 255, Time, Hour, Day, *Function_Time }, {Hour, 0, 255, Time, Minute, Week, *Function_Time }, {Minute, 0, 255, Time, Second, Hour, *Function_Time }, {Second, 0, 255, Time, Year, Minute, *Function_Time }, {Backlight, 2, Green, SystemSet, Buzzer, Time, *FunctionNul }, {Green, 0, 255, Backlight, Red, Red, *Function_BkLight}, {Red, 0, 255, Backlight, Green, Green, *Function_BkLight}, {Buzzer, 2, Open, SystemSet, Time, Backlight,*FunctionNul }, {Open, 0, 255, Buzzer, Close, Close, *Function_Open }, {Close, 0, 255, Buzzer, Open, Open, *Function_Close }, {ShutOff, 0, 255, Menu, EUTtype, SystemSet,*Function_ShutOff} |