/************************************************************ FileName: menu.c
Author:胡贵
Version :V1.0
Date: 2007.9.13
Description: 菜单 History:
<author> <time> <version > <desc>
************************************************************/
#include "includes.h"
#include "global_variable.h"
/******************************************************************** UINT8 Index;//菜单索引 UINT8 KeyOkIndex;//按下OK转向的菜单项索引 UINT8 KeyPreIndex;//按下PRE转向的菜单项索引 UINT8 KeyNextIndex;//按下NEXT转向的菜单项索引 UINT8 KeyCancleIndex;//按下CANCLE转向的菜单项索引
UINT8 ExcuteMode;//0x01:base only 0x02:special only 0x03:base%special
EXP_FUN *p_ExpFun; ***********************************************************************/
//菜单结构表格 struct _menu_ code MenuTable[30]= //MENU MenuTable[]= { {0, 1, 0, 0, 0, TXT0, KEY1_EXP_ONLY|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_EXP_ONLY, ExpFunCodeCheckEnter, ExpFunMainOnPre, ExpFunMainOnNxt, ExpFunMainOnQuit},
{1, 2, 0, 0, 0, TXT1, KEY1_EXP_ONLY|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_EXP_ONLY, ExpFunCodeCheckOnOk, ExpFunCodeCheckOnPre, ExpFunCodeCheckOnNxt, ExpFunRefreshMainInterface},
{2, 6, 0, 3, 0, TXT2, KEY1_BASE_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_EXP_ONLY, NULL, NULL, NULL, ExpFunRefreshMainInterface},
{3, 9, 2, 4, 0, TXT3, KEY1_BASE_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_EXP_ONLY, NULL, NULL, NULL, ExpFunRefreshMainInterface},
{4, 12, 3, 5, 0, TXT4, KEY1_BASE_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_EXP_ONLY, NULL, NULL, NULL, ExpFunRefreshMainInterface},
{5, 14, 4, 0, 0, TXT5, KEY1_BASE_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_EXP_ONLY, NULL, NULL, NULL, ExpFunRefreshMainInterface},
{6, 18, 0, 7, 2, TXT6, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunDataSearchEnter, NULL, NULL, NULL},
{7, 19, 6, 8, 2, TXT7, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunDataClearSelEnter, NULL, NULL, NULL},
{8, 20, 7, 0, 2, TXT8, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunDataClearAllEnter, NULL, NULL, NULL},
{9, 21, 0, 10, 3, TXT9, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunPrintModeSetEnter, NULL, NULL, NULL},
{10, 22, 9, 11, 3, TXT10, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunDataPrintSelEnter, NULL, NULL, NULL},
{11, 23, 10, 0, 3, TXT11, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunDataPrintAllEnter, NULL, NULL, NULL},
{12, 24, 0, 13, 4, TXT12, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunYYMMDDCreat, NULL, NULL, NULL},
{13, 25, 12, 0, 4, TXT13, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunHHMMSSCreat, NULL, NULL, NULL},
{14, 26, 0, 15, 5, TXT14, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunTimeSetForSleepEnter,NULL, NULL, NULL},
{15, 27, 14, 16, 5, TXT15, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunCodeSetEnter, NULL, NULL, NULL},
{16, 28, 15, 17, 5, TXT16, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunSysInfoEnter, NULL, NULL, NULL},
{17, 29, 16, 0, 5, TXT17, KEY1_EXP_ONLY|KEY2_BASE_ONLY|KEY3_BASE_ONLY|KEY4_BASE_ONLY, ExpFunSysResetEnter, NULL, NULL, NULL},
{18, 18, 0, 0, 6, TXT18, KEY1_EXP_ONLY|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunDataSearchOnOk, ExpFunDataSearchOnPre,ExpFunDataSearchOnNxt, ExpFunDataSearchQuit},
{19, 19, 0, 0, 7, TXT19, KEY1_EXP_ONLY|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunDataClearSelOnOk,ExpFunDataClearSelOnPre,ExpFunDataClearSelOnNxt, ExpFunDataClearSelectQuit},
{20, 8, 0, 0, 8, TXT20, KEY1_EXP_ONLY|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunDataClearAllOnOk, ExpFunNop, ExpFunNop, ExpFunDataClearAllQuit},
{21, 9, 0, 0, 9, TXT21, KEY1_BASE_EXP|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunPrintModeSetOnOk, ExpFunPrintModeSetOnPre, ExpFunPrintModeSetOnNxt, ExpFunDataPrintModeSetQuit},
{22, 22, 0, 0, 10, TXT22, KEY1_EXP_ONLY|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunDataPrintSelOnOk, ExpFunDataPrintSelOnPre, ExpFunDataPrintSelOnNxt, ExpFunDataPrintSelectQuit},
{23, 11, 0, 0, 11, TXT23, KEY1_EXP_ONLY|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunDataPrintAllOnOk, ExpFunDataPrintAllOnPre,ExpFunNop, ExpFunDataPrintAllQuit},
{24, 12, 0, 0, 12, TXT24, KEY1_BASE_EXP|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunYYMMDDOnOk, ExpFunYYMMDDOnPre, ExpFunYYMMDDOnNxt, ExpFunTimeSetEsc},
{25, 13, 0, 0, 13, TXT25, KEY1_BASE_EXP|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunHHMMSSOnOk, ExpFunHHMMSSOnPre, ExpFunHHMMSSOnNxt, ExpFunTimeSetEsc},
{26, 14, 0, 0, 14, TXT26, KEY1_BASE_EXP|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunTimeSetForSleepOnOk,ExpFunTimeSetForSleepPre, ExpFunTimeSetForSleepNxt, ExpFunTimeSetForSleepQuit},
{27, 15, 0, 0, 15, TXT27, KEY1_BASE_EXP|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunCodeSetOnOk, ExpFunCodeSetPre, ExpFunCodeSetNxt, ExpFunCodeSetQuit},
{28, 16, 0, 0, 16, TXT28, KEY1_BASE_EXP|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunSysInfoOk, ExpFunNop, ExpFunNop, ExpFunSysInfoBack},
{29, 29, 0, 0, 17, TXT29, KEY1_EXP_ONLY|KEY2_EXP_ONLY|KEY3_EXP_ONLY|KEY4_BASE_EXP, ExpFunSysReset, ExpFunNop, ExpFunNop, ExpFunSysResetQuit}, };
//UINT8 FocusIndex=0; //UINT8 xdata CursorLocation=0;//base to 0
//UINT8 xdata IndexStack[10]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; //UINT8 *xdata p_Stack=IndexStack;
/********************************************************************* Description:光标位置入栈 Input: CursorLocation:光标位置,基于0 Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void CursorLocationPush(UINT8 CursorLocation) { *p_Stack++=CursorLocation; }
/********************************************************************* Description:光标位置出栈 Input: CursorLocation:光标位置,基于0 Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ UINT8 CursorLocationPop(void) { UINT8 tmp;
tmp=*(--p_Stack); *p_Stack=0xff; return tmp; }
/********************************************************************* Description:绘制菜单项 Input: index:菜单编号 Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void DrawMenu(UINT8 index) { UINT8 IndexTmp[3], TextLen[3]; UINT8 i;
i=sizeof(struct _menu_); switch(CursorLocation) { case 0: { IndexTmp[0]=index; IndexTmp[1]=MenuTable[index].KeyNextIndex; if(IndexTmp[1]) IndexTmp[2]=MenuTable[IndexTmp][1]].KeyNextIndex; else IndexTmp[2]=0x00; } break; case 1: { IndexTmp[0]=MenuTable[index].KeyPreIndex; IndexTmp[1]=index; IndexTmp[2]=MenuTable[index].KeyNextIndex; } break; case 2: { IndexTmp[2]=index; IndexTmp[1]=MenuTable[index].KeyPreIndex; if(IndexTmp[1]) IndexTmp[0]=MenuTable[IndexTmp][1]].KeyPreIndex; else IndexTmp[0]=0x00; } break; }
if(IndexTmp[0] || IndexTmp[1] || IndexTmp[2]) {
GUI_ClearRect(0, 127, 0, 46); // GUI_ClearRect(0, 127, 0, 46); /*GUI_DrawHLine(1, 100, 0); GUI_DrawVLine(0, 10, 1); GUI_DrawHLine(2, 64, 44); GUI_DrawHLine(14, 92, 45); GUI_DrawHLine(30, 125, 46); GUI_DrawVLine(0, 15, 123); GUI_DrawVLine(4, 22, 124); GUI_DrawVLine(8, 32, 125);*/
GUI_DrawRect(1, 125, 0, 44); GUI_DrawHLine(2, 126, 45); GUI_DrawVLine(1, 45, 126); for(i=0;i<3;i++) { if(IndexTmp) TextLen=GUI_DispLine_(MenuTable[IndexTmp]].p_Text, MENU_TXT_X_COORDINATE, MENU_TXT_Y_COORDINATE+i*MENU_TXT_Y_SPACE); }
GUI_InvertRect(MENU_TXT_X_COORDINATE-1, MENU_TXT_X_COORDINATE+12*TextLen[CursorLocation], MENU_TXT_Y_COORDINATE+MENU_TXT_Y_SPACE*CursorLocation-12, MENU_TXT_Y_COORDINATE+MENU_TXT_Y_SPACE*CursorLocation);
//GUI_InvertRect(1, 83, 0, 46); Display(); } }
/********************************************************************* Description:菜单上下行 Input: key:按键消息 Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void MenuServer(UINT8 key) { EXTERN_INT1_DISABLE; switch (key) { case KEY_SET: { switch(MenuTable[FocusIndex].ExcuteMode&0x000f) { case KEY1_BASE_ONLY: { FocusIndex=MenuTable[FocusIndex].KeyOkIndex; CursorLocationPush(CursorLocation); CursorLocation=0; DrawMenu(FocusIndex); } break; case KEY1_EXP_ONLY: { (*MenuTable[FocusIndex].p_Btn1Serv)(); } break; case KEY1_BASE_EXP: { (*MenuTable[FocusIndex].p_Btn1Serv)(); FocusIndex=MenuTable[FocusIndex].KeyOkIndex; //CursorLocationPush(CursorLocation); //CursorLocation=0; DrawMenu(FocusIndex); } break; } } break; case KEY_PRE: { switch(MenuTable[FocusIndex].ExcuteMode&0x00f0) { case KEY2_BASE_ONLY: { if(MenuTable[FocusIndex].KeyPreIndex) FocusIndex=MenuTable[FocusIndex].KeyPreIndex; CursorLocation--; if(CursorLocation==255) CursorLocation=0; DrawMenu(FocusIndex); } break; case KEY2_EXP_ONLY: { (*MenuTable[FocusIndex].p_Btn2Serv)(); } break; case KEY2_BASE_EXP: { (*MenuTable[FocusIndex].p_Btn2Serv)(); if(MenuTable[FocusIndex].KeyPreIndex) FocusIndex=MenuTable[FocusIndex].KeyPreIndex; CursorLocation--; if(CursorLocation==255) CursorLocation=0; DrawMenu(FocusIndex); } break; } } break; case KEY_NXT: { switch(MenuTable[FocusIndex].ExcuteMode&0x0f00) { case KEY3_BASE_ONLY: { if(MenuTable[FocusIndex].KeyNextIndex) { FocusIndex=MenuTable[FocusIndex].KeyNextIndex; CursorLocation++; } if(CursorLocation==3) CursorLocation=2; DrawMenu(FocusIndex); } break; case KEY3_EXP_ONLY: { (*MenuTable[FocusIndex].p_Btn3Serv)();
} break; case KEY3_BASE_EXP: { (*MenuTable[FocusIndex].p_Btn3Serv)(); if(MenuTable[FocusIndex].KeyNextIndex) { FocusIndex=MenuTable[FocusIndex].KeyNextIndex; CursorLocation++; } if(CursorLocation==3) CursorLocation=2; DrawMenu(FocusIndex); } break; } } break; case KEY_ESC: { switch(MenuTable[FocusIndex].ExcuteMode&0xf000) { case KEY4_BASE_ONLY: { FocusIndex=MenuTable[FocusIndex].KeyCancleIndex; CursorLocation=CursorLocationPop(); DrawMenu(FocusIndex); } break; case KEY4_EXP_ONLY: { (*MenuTable[FocusIndex].p_Btn4Serv)();
} break; case KEY4_BASE_EXP: { (*MenuTable[FocusIndex].p_Btn4Serv)(); FocusIndex=MenuTable[FocusIndex].KeyCancleIndex; CursorLocation=CursorLocationPop(); DrawMenu(FocusIndex);
} break; } } break; } EXTERN_INT1_ENABLE; }
/********************************************************************* Description:重绘主界面 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunRefreshMainInterface(void) { FlagIdleMode=1; FocusIndex=MenuTable[FocusIndex].KeyCancleIndex; CursorLocation=CursorLocationPop(); DrawManiInterface(); DrawFlash(1); ExperimentStep=1; TIMER0_START; }
/********************************************************************* Description:创建设置年月日的标签 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunYYMMDDCreat(void) { CursorLocationPush(CursorLocation); FocusIndex=MenuTable[FocusIndex].KeyOkIndex; CreateStpLabel_YMD(MenuTable[FocusIndex].p_Text, 32, 20, &SystemTime, 44, 40, 1); ExpFunBtnRedraw3(); Display(); }
/********************************************************************* Description:创建设置时分秒的标签 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunHHMMSSCreat(void) { CursorLocationPush(CursorLocation); FocusIndex=MenuTable[FocusIndex].KeyOkIndex; CreateStpLabel_YMD(MenuTable[FocusIndex].p_Text, 32, 20, &SystemTime, 44, 40, 0); ExpFunBtnRedraw3(); Display(); }
/*******************************************************************
the following functions are the response of key when in the time setup
*******************************************************************/ void ExpFunHHMMSSOnOk(void) { OnOK_YMD(0); CursorLocation=CursorLocationPop(); ExpFunBtnRedraw2(); }
void ExpFunYYMMDDOnOk(void) { OnOK_YMD(1); CursorLocation=CursorLocationPop(); ExpFunBtnRedraw2(); }
void ExpFunHHMMSSOnPre(void) { OnPre_YMD(0); Display(); }
void ExpFunYYMMDDOnPre(void) { OnPre_YMD(1); Display(); }
void ExpFunHHMMSSOnNxt(void) { OnNxt_YMD(0); // CursorLocation=CursorLocationPop(); Display(); }
void ExpFunYYMMDDOnNxt(void) { OnNxt_YMD(1); Display(); }
/*******************************************************************
the following function ---------->redraw button
********************************************************************/
/********************************************************************* Description:重绘按钮 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunBtnRedraw1(void) { GUI_DrawButton(&btn1, "设置", 4, 62, 27, 15); GUI_DrawButton(&btn2, "测试", 35, 62, 27, 15); GUI_DrawButton(&btn3, "复位", 66, 62, 27, 15); GUI_DrawButton(&btn4, "打印", 97, 62, 27, 15); }
void ExpFunBtnRedraw2(void) { GUI_DrawButton(&btn1, "确定", 4, 62, 27, 15); GUI_DrawButton(&btn2, "向上", 35, 62, 27, 15); GUI_DrawButton(&btn3, "向下", 66, 62, 27, 15); GUI_DrawButton(&btn4, "退出", 97, 62, 27, 15); }
void ExpFunBtnRedraw3(void) { GUI_DrawButton(&btn1, "确定", 4, 62, 27, 15); GUI_DrawButton(&btn2, "增加", 35, 62, 27, 15); GUI_DrawButton(&btn3, "移位", 66, 62, 27, 15); GUI_DrawButton(&btn4, "退出", 97, 62, 27, 15); }
void ExpFunBtnRedraw4(void) { GUI_DrawButton(&btn1, "确定", 4, 62, 27, 15); GUI_DrawButton(&btn2, "向左", 35, 62, 27, 15); GUI_DrawButton(&btn3, "向右", 66, 62, 27, 15); GUI_DrawButton(&btn4, "退出", 97, 62, 27, 15); }
void ExpFunBtnRedraw5(void) { GUI_DrawButton(&btn1, "确定", 4, 62, 27, 15); GUI_DrawButton(&btn2, "空空", 35, 62, 27, 15); GUI_DrawButton(&btn3, "空空", 66, 62, 27, 15); GUI_DrawButton(&btn4, "退出", 97, 62, 27, 15); }
void ExpFunBtnRedraw6(void) { GUI_DrawButton(&btn1, "确定", 4, 62, 27, 15); GUI_DrawButton(&btn2, "终止", 35, 62, 27, 15); GUI_DrawButton(&btn3, "空空", 66, 62, 27, 15); GUI_DrawButton(&btn4, "退出", 97, 62, 27, 15); }
/********************************************************************* Description:进入设置 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunEnterSetMode(void) { TIMER0_CLOSE; FlagTimeRefresh=0; ExpFunBtnRedraw2(); CursorLocationPush(CursorLocation); }
/********************************************************************* Description:空函数 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunNop(void) {
}
/********************************************************************* Description:系统参数查看返回 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunSysInfoBack(void) { //CursorLocation=CursorLocationPop(); ExpFunBtnRedraw2(); }
/********************************************************************* Description:进入查看系统参数 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunSysInfoEnter(void) { CursorLocationPush(CursorLocation); FocusIndex=MenuTable[FocusIndex].KeyOkIndex; GUI_ClearRect(2, 124, 1, 43); GUI_DispLine_(MenuTable[FocusIndex].p_Text, 40, 30); ExpFunBtnRedraw5(); Display(); }
/********************************************************************* Description:系统复位 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunSysReset(void) { SysPara.FlagNewMachine=0xff; FlashPacketSysWr(&SysPara); (*((void (*)(void))(0)))(); }
/********************************************************************* Description:系统参数查看响应OK键 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunSysInfoOk(void) { CursorLocation=CursorLocationPop(); ExpFunBtnRedraw2(); }
/********************************************************************* Description:进入密码设置 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunCodeSetEnter(void) { CursorLocationPush(CursorLocation); FocusIndex=MenuTable[FocusIndex].KeyOkIndex; GUI_ClearRect(2, 124, 1, 43); Gui_CharacterStyle_Set12_6(); // DataSetTmp=0; CreateStpLabel_Int(MenuTable[FocusIndex].p_Text, 28,20,&SysPara.SysCode,51,40,4); ExpFunBtnRedraw3(); Display(); }
/********************************************************************* Description:进入待机时间设置 Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunTimeSetForSleepEnter(void) { CursorLocationPush(CursorLocation); FocusIndex=MenuTable[FocusIndex].KeyOkIndex; GUI_ClearRect(2, 124, 1, 43); Gui_CharacterStyle_Set12_6(); CreateStpLabel_Int(MenuTable[FocusIndex].p_Text, 23,20,&SysPara.TimeForSleep,51,40,4); ExpFunBtnRedraw3(); Display(); }
/********************************************************************* Description:密码设置OK Input: Output:
Return:
Gloable:
Calls:
Called By:
Others:
Modify Record: *********************************************************************/ void ExpFunCodeSetOnOk(void) { struct StpLabelBlk_Int *pTmp;
pTmp=(struct StpLabelBlk_Int *)p_S_L_B;
OnOk_Int();
//to add:para store function SysPara.SysCode=pTmp->Dat_Temp; FlashPacketSysWr(&S |