/** * @brief Run the 8 uart application * @param None. * @note run and display information about the uart transaction. * @retval None. */ KMODULE_RETURN _ImageBrowserDemoExec(void) { /* Prepare the main MMI */ kMenu_Execute(ImageBrowserMenu); /* Execute the app 8uart */ /* App initialization */ return KMODULE_OK; }
/** * @brief Run the Lowpower application * @param None. * @note run and display information about the lowpower feature. * @retval None. */ KMODULE_RETURN _LowPowerDemoExec(void) { /* Prepare Execute the main MMI of lowpower application */ kMenu_Execute(LowpowerMenu); return KMODULE_OK; }
/** * @brief Run the main application * @param None. * @note run and display main menu. * @retval None. */ KMODULE_RETURN AppMainExec(void) { kMenu_Execute(MainMenu); return KMODULE_OK; }
/** * @brief Function in charge to execture a menu * @param menu * @retval None */ void kMenu_Execute(tMenu psCurrentMenu) { uint32_t index = 0, exit = 1; uint32_t k_MenuState = KMENU_HEADER; uint8_t sel = 0; do { switch(k_MenuState) { case KMENU_HEADER : { /****************************** Display Header *************************/ /* Clear the LCD Screen */ BSP_LCD_Clear(LCD_COLOR_WHITE); if(psCurrentMenu.pszTitle != NULL) { /* Set the Back Color */ BSP_LCD_SetFont(&Font24); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), Font24.Height); /* Set the Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)psCurrentMenu.pszTitle, CENTER_MODE); } switch(psCurrentMenu.nType) { case TYPE_ICON : k_MenuState = KMENU_ICON; break; case TYPE_TEXT : k_MenuState = KMENU_TEXT; break; case TYPE_EXEC : k_MenuState = KMENU_EXEC; break; default : k_MenuState = KMENU_EXIT; break; } } break; case KMENU_ICON : { BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), Font24.Height); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)psCurrentMenu.psItems[0].pszTitle, CENTER_MODE); for(index = 0; index < psCurrentMenu.nItems; index++) { if(psCurrentMenu.psItems[index].pIconPath != NULL) { kStorage_OpenFileDrawBMP(psCurrentMenu.psItems[index].x, psCurrentMenu.psItems[index].y, (uint8_t *)psCurrentMenu.psItems[index].pIconPath); } } k_MenuState = KMENU_WAITEVENT; } break; case KMENU_TEXT : { /* Set the Back Color */ BSP_LCD_SetBackColor(LCD_COLOR_WHITE); /* Set the Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); k_MenuState = KMENU_WAITEVENT; } break; case KMENU_EXEC : { while(BSP_JOY_GetState() != JOY_NONE); /* if the function need user feedback enable JOY interrupt and set callback function */ if(psCurrentMenu.psItems[0].pfActionFunc != NULL) { /* start the Joystick interrupt */ BSP_JOY_Init(JOY_MODE_EXTI); HAL_Delay(300); /* set the function to report joystick event */ kMenuEventForward = psCurrentMenu.psItems[0].pfActionFunc; } kMenu_Header(psCurrentMenu.psItems[0].pszTitle); /* Execute the test */ psCurrentMenu.psItems[0].pfExecFunc(); /* rest user feedback, in polling mode */ if(psCurrentMenu.psItems[0].pfActionFunc != NULL) { /* stop the Joystick interrupt */ BSP_JOY_Init(JOY_MODE_GPIO); HAL_Delay(300); /* set the function to report to NULL */ kMenuEventForward = NULL; } k_MenuState = KMENU_EXIT; } break; case KMENU_WAITEVENT: { kMenu_HandleSelection(psCurrentMenu,&sel); /* The user has selected an execution menu */ switch(psCurrentMenu.psItems[sel].SelType) { case SEL_MODULE: /* start the module execution */ kModule_Execute(psCurrentMenu.psItems[sel].ModuleId); k_MenuState = KMENU_HEADER; break; case SEL_EXEC : while(BSP_JOY_GetState() != JOY_NONE); /* if the function need user feedback enable JOY interrupt and set callback function */ if(psCurrentMenu.psItems[sel].pfActionFunc != NULL) { /* start the Joystick interrupt */ BSP_JOY_Init(JOY_MODE_EXTI); HAL_Delay(300); /* set the function to report joystick event */ kMenuEventForward = psCurrentMenu.psItems[sel].pfActionFunc; } /* start the function execution */ psCurrentMenu.psItems[sel].pfExecFunc(); /* rest user feedback, in polling mode */ if(psCurrentMenu.psItems[sel].pfActionFunc != NULL) { /* stop the Joystick interrupt */ BSP_JOY_Init(JOY_MODE_GPIO); HAL_Delay(300); /* set the function to report to NULL */ kMenuEventForward = NULL; } k_MenuState = KMENU_HEADER; break; case SEL_SUBMENU : /* Select submenu or return on the main module menu */ kMenu_Execute(*(psCurrentMenu.psItems[sel].psSubMenu)); k_MenuState = KMENU_HEADER; break; case SEL_EXIT : k_MenuState = KMENU_EXIT; break; } } break; case KMENU_EXIT : exit = 0; break; } }while(exit); }