menu.c

来自「Sirf/Centrality公司GPS平台AtlasIII芯片AT640的Nb」· C语言 代码 · 共 69 行

C
69
字号
#include "def.h"
#include "menu.h"
#include "debug.h"

extern NBOOT_MENU g_topMenu[];
NBOOT_MENU * g_pCurMenu;

static int _Menu_CheckType(char * pInstruction)
{
	if(*pInstruction == 0 || pInstruction == 0)
		return 0;
	if(g_pCurMenu->iInputType == MENU_INPUT_CHAR)
	{
		if(pInstruction[1] != 0)
			return 0;
	}

	return 1;
}

void Menu_Display(void)
{
	NBOOT_MENU * pCurMenu;
	pCurMenu = g_pCurMenu;
	while(pCurMenu->iMatch)
	{
		DbgPutString(pCurMenu->pStr);
		pCurMenu++;
	}
	DbgPutString("\r\nInput:");
}

int Menu_Process(char * pInstruction)
{
	NBOOT_MENU * pCurMenu;
	if(_Menu_CheckType(pInstruction) == 0)
		return 0;

	if(g_pCurMenu->iInputType == MENU_INPUT_CHAR)
	{
		pCurMenu = g_pCurMenu;
		while(pCurMenu->iMatch)
		{
			if(pCurMenu->iMatch == (int)(*pInstruction))
			{
				//We found a match
				if((pCurMenu->pMenuFunc))
				{
					if((*(pCurMenu->pMenuFunc))((int)(*pInstruction)) == 0)
					{
						//If the current function return false. We will not call the next menu
						break;
					}
				}
				if(pCurMenu->pNextMenu)
					g_pCurMenu = pCurMenu->pNextMenu;
				break;
			}
			pCurMenu++;
		}
	}
	return 0;
}

int Menu_IsCurTop(void)
{
	return (g_pCurMenu == g_topMenu);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?