📄 gpmenu.c
字号:
/*
******************************************************************
* XIAMEN YAXON NETWORK CO.LTD.
* XINXI BUILDING,HULI,XIAMEN
* (c) Copyright 2002,XIAMEN YAXON NETWORK CO.LTD. ,XIAMEN
* All Rights Reserved
*
* FileName : GPMENU.C
* Programmer(s): WuJingYu
* Description :
******************************************************************
*/
/*
*****************************************************************
* REVISION HISTORY
*
* Date: 2002-10-23
*****************************************************************
*/
#define GPMENU_GLOBALS
#include "includes.h"
#include "Lcd.h"
//#include "InField.h"
static INT8U NumLine,NumColumn;
//static INT8U lock;
void GetGpMenuPara(GPMENU *gpmenu)
{
NumLine = gpmenu->gpout->numrow;
NumColumn = gpmenu->gpout->numcol;
}
void ReverseSelMenuItem(GPMENU *gpmenu,BOOLEAN updatelcd)
{
ReverseGpOut(gpmenu->currow,gpmenu->curcol);
if (updatelcd) {
UpdateGpOut_PartLcd(gpmenu->currow,gpmenu->curcol);
}
}
void GpMenuSelectProc(GPMENU *gpmenu)
{
void (*selfunc)(void*);
INT8U i;
GetGpMenuPara(gpmenu);
i = gpmenu->currow * NumColumn + gpmenu->curcol;
if (i > gpmenu->menucnt) return;
selfunc = gpmenu->gpmenuitem[i].selfunc;
if (selfunc != NULL) {
(*selfunc)((void*)&i);
}
}
void GpMenuExecProc(GPMENU *gpmenu)//将菜单按键的exec按序号排列,根据序号i来判断执行哪个exec
{
void (*execfunc)(void);
INT8U i;
GetGpMenuPara(gpmenu);
i = gpmenu->currow * NumColumn + gpmenu->curcol;
if (i > gpmenu->menucnt) return;
execfunc = gpmenu->gpmenuitem[i].execfunc;
if (execfunc != NULL) {
(*execfunc)();
}
}
void ShowGpMenuData(GPMENU *gpmenu,BOOLEAN updatelcd)
{
INT8U i,j;
LockGpOut(gpmenu->gpout);
GetGpMenuPara(gpmenu);
for (i=0;i<NumLine;i++) {
for (j=0;j<NumColumn;j++) {
//Print_Gpdata(i,j,gpmenu->gpmenuitem[i*NumColumn + j].gpdata);
Print_Gpdata_ROM(i,j,gpmenu->gpmenuitem[i*NumColumn + j].gpdata);
}
}
if (updatelcd) UpdateGpOut_LCD();
}
void GotoNextGpItem(GPMENU *gpmenu)
{
INT8U currow,curcol;
LockGpOut(gpmenu->gpout);
GetGpMenuPara(gpmenu);
currow = gpmenu->currow;
curcol = gpmenu->curcol;
ReverseSelMenuItem(gpmenu,1);
if (curcol < NumColumn-1) {
curcol++;
} else {
curcol = 0;
if (currow < NumLine - 1) {
currow++;
} else {
currow = 0;
}
}
gpmenu->curcol = curcol;
gpmenu->currow = currow;
GpMenuSelectProc(gpmenu);
ReverseSelMenuItem(gpmenu,1);
//UpdateOutBox_LCD();
//UnLockGpOut(gpmenu->gpout);
}
void GotoPrevGpItem(GPMENU *gpmenu)
{
INT8U currow,curcol;
LockGpOut(gpmenu->gpout);
GetGpMenuPara(gpmenu);
currow = gpmenu->currow;
curcol = gpmenu->curcol;
ReverseSelMenuItem(gpmenu,1);
if (curcol != 0)
{
curcol--;
}
else
{
curcol = NumColumn - 1;
if (currow != 0)
{
currow--;
}
else
{
currow = NumLine - 1;
}
}
gpmenu->curcol = curcol;
gpmenu->currow = currow;
GpMenuSelectProc(gpmenu);
ReverseSelMenuItem(gpmenu,1);
//UpdateOutBox_LCD();
//UnLockGpOut(gpmenu->gpout);
}
void UnIndicateGpMenu(GPMENU *gpmenu)
{
LockGpOut(gpmenu->gpout);
GetGpMenuPara(gpmenu);
ReverseSelMenuItem(gpmenu,1);
//UnLockGpOut(gpmenu->gpout);
}
void IndicateGpMenu(GPMENU *gpmenu)
{
UnIndicateGpMenu(gpmenu);
GpMenuSelectProc(gpmenu);
}
void InitGpMenu(GPMENU *gpmenu)
{
void (*initfunc)(void);
gpmenu->currow = 0;
gpmenu->curcol = 0;
initfunc = gpmenu->initfunc;
if (initfunc !=NULL) {
(*initfunc)();
}
}
void CreateGpMenu(GPMENU *gpmenu)
{
ShowGpMenuData(gpmenu,0);
GrawGpOutBorder();
}
void DestroyGpMenu(GPMENU *gpmenu)
{
gpmenu->currow = 0;
gpmenu->curcol = 0;
gpmenu->menucnt = 0;
}
void ClearGpMenu(GPMENU *gpmenu)
{
gpmenu = gpmenu;
}
INT8U GetGpMenuSelItem(GPMENU *gpmenu)
{
if (gpmenu->menucnt == 0) {
return 0xFF;
} else {
return gpmenu->gpout->numcol * gpmenu->currow + gpmenu->curcol;
}
}
BOOLEAN GpMenu_HdlKey(GPMENU *gpmenu)
{
INT8U key;
key = GetCurLcdKey();
switch (key)
{
case KEY_UP :
GotoPrevGpItem(gpmenu);
return TRUE;
case KEY_DOWN:
GotoNextGpItem(gpmenu);
return TRUE;
case KEY_ACK:
GpMenuExecProc(gpmenu);
return TRUE;
default:
return FALSE;
}
}
INT8U AddGpMenuItem(GPMENU *gpmenu,GPITEM *item)
{
INT8U menucnt;
menucnt = gpmenu->menucnt;
gpmenu->gpmenuitem[menucnt].gpdata = item->gpdata;
gpmenu->gpmenuitem[menucnt].selfunc = item->selfunc;
gpmenu->gpmenuitem[menucnt].execfunc = item->execfunc;
menucnt++;
gpmenu->menucnt = menucnt;
return menucnt;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -