⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.c

📁 万利ARM9的STR912开发板配套资料和源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
   MenuItemIndex = 0;
   psCurrentMenu = psMenuItem->psSubMenu;
   psMenuItem = &(psCurrentMenu->psItems)[MenuItemIndex];
   DisplayMenu();
   nMenuLevel++;
   psPrevMenu[nMenuLevel] = psCurrentMenu;
  }

  psCurrentMenuItem->pfMenuFunc();
}

/*******************************************************************************
* Function Name  : RightFunc
* Description    : This function is executed when "Right" push-buttton is pressed.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void RightFunc(void)
{
  /* Test on the MenuItemIndex value before incrementing it */
  if(MenuItemIndex >= ((psCurrentMenu->nItems)-1))
  {
    MenuItemIndex = 0;
  }
  else
  {
    MenuItemIndex++;
  }

  /* Get the current menu */
  psMenuItem = &(psCurrentMenu->psItems[MenuItemIndex]);

  DisplayMenu();

  ItemNumb[nMenuLevel] = MenuItemIndex;
}

/*******************************************************************************
* Function Name  : LeftFunc
* Description    : This function is executed when "Left" push-buttton is pressed.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LeftFunc(void)
{
  if(MenuItemIndex > 0)
  {
    MenuItemIndex--;
  }
  else
  {
    MenuItemIndex = psCurrentMenu->nItems - 1;
  }

  psMenuItem = &psCurrentMenu->psItems[MenuItemIndex];
  DisplayMenu();
  ItemNumb[nMenuLevel] = MenuItemIndex;
}

/*******************************************************************************
* Function Name  : UpDownFunc
* Description    : This function is executed when any of "UP"/"Down" push-butttons
*                  is pressed.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void UpDownFunc(void)
{
  psMenuItem->pfUpDownMenuFunc();

  if(nMenuLevel == 0)
  {
    nMenuLevel++;
  }

  psCurrentMenu = psPrevMenu[nMenuLevel-1];
  psMenuItem = &psCurrentMenu->psItems[ItemNumb[nMenuLevel-1]];
  DisplayMenu();
  ItemNumb[nMenuLevel] = 0;
  MenuItemIndex = ItemNumb[nMenuLevel-1];
  nMenuLevel--;
}

/*******************************************************************************
* Function Name  : ReadKey
* Description    : Reads key from demoboard.
* Input          : None
* Output         : None
* Return         : Return RIGHT, LEFT, SEL, UP, DOWN or NOKEY
*******************************************************************************/
u8 ReadKey ( void )
{
  u8 port=0;
  u32 i;

  for(i=0x7FFFF; i>0; i--);
  port = GPIO_Read(GPIO7);
  if((port & 0xF0)!= 0x10)
  {
    if((port&0xE0) == 0x80)
      return(UP);
    if((port&0xE0) == 0x20)
      return(DOWN);
    if((port&0xE0) == 0x60)
      return(RIGHT);
    if((port&0xE0) == 0x40)
      return(LEFT);
    if((port&0xE0) == 0x00)
      return(SEL);
    if((port&0xE0) == 0xA0)
      return(KEY);
    else return(NOKEY);
  }
  else return(NOKEY);

}

/*******************************************************************************
* Function Name  : IdleFunc
* Description    : Idle function.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void IdleFunc(void)
{
  /* Nothing to execute: return */
  return;
}

/*******************************************************************************
* Function Name  : HelpMenu
* Description    : Display the Help menu.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void HelpMenu(void)
{
  u8 MyKey = 0;
  PlayIntroDelay = 20;

  VIC_ITCmd(EXTIT3_ITLine, DISABLE);

  /* Wait any bushbuttons press */
  while(MyKey == NOKEY)
  {
    /* Clear the LCD screen */
    LCD_Clear();
    /* Display "         Enter to" message */
    LCD_DisplayString(Line1, "         Enter to", BlackText);
    /* Display "         Sub-Menu" message */
    LCD_DisplayString(Line2, "         Sub-Menu", BlackText);
    /* Display SELHelp graphic */
    LCD_DrawMasterGraphic(SELHelp);
    /* Wait 2sec or return if any pushbutton is pressed */
    while(PlayIntroDelay != 0)
    {
      /* If any key is pressed */
      if(JoyState() != NOKEY)
      {
        /* Display "Help" menu */
        DisplayMenu();
        VIC_ITCmd(EXTIT3_ITLine, ENABLE);
        /* Exit the while loop */
        return;
      }
    }
    /* Reinitialize PlayIntroDelay to 2sec */
    PlayIntroDelay = 20;
    /* Clear the LCD screen */
    LCD_Clear();
    /* Display "         To Exit " message */
    LCD_DisplayString(Line1, "         To Exit ", BlackText);
    /* Display "         Sub-Menu" message */
    LCD_DisplayString(Line2, "         Sub-Menu", BlackText);
    /* Display UPDOWNHelp graphic */
    LCD_DrawMasterGraphic(UPDOWNHelp);
    /* Wait 2sec or return if any pushbutton is pressed */
    while(PlayIntroDelay != 0)
    {
      /* If any key is pressed */
      if(JoyState()  != NOKEY)
      {
        /* Display "Help" menu */
        DisplayMenu();
        VIC_ITCmd(EXTIT3_ITLine, ENABLE);
        /* Exit the while loop */
        return;
      }
    }
    /* Reinitialize PlayIntroDelay to 2sec */
    PlayIntroDelay = 20;

    /* Clear the LCD screen */
    LCD_Clear();
    /* Display "          Scroll " message */
    LCD_DisplayString(Line1, "          Scroll ", BlackText);
    /* Display "         Sub-Menu" message */
    LCD_DisplayString(Line2, "         Sub-Menu", BlackText);
    /* Display LEFTRIGHTHelp graphic */
    LCD_DrawMasterGraphic(LEFTRIGHTHelp);
    /* Wait 2sec or return if any pushbutton is pressed */
    while(PlayIntroDelay != 0)
    {
      /* If any key is pressed */
      if(JoyState() != NOKEY)
      {
        /* Display "Help" menu */
        DisplayMenu();
        VIC_ITCmd(EXTIT3_ITLine, ENABLE);
        /* Exit the while loop */
        return;
      }
    }
    /* Reinitialize PlayIntroDelay to 2sec */
    PlayIntroDelay = 20;
    /* read the pressed key */
    MyKey = JoyState();
  }
  VIC_ITCmd(EXTIT3_ITLine, ENABLE);
}

/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/

⌨️ 快捷键说明

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