int main (int argc, char ** argv) { nvInit(); menuInit(); NavEvent nav; while (1) { nav = navWaitForEvent(); switch (nav) { case NAV_LEFT: menuLeft(); break; case NAV_RIGHT: menuRight(); break; case NAV_UP: menuUp(); break; case NAV_DOWN: menuDown(); break; //case NAV_TAP: menuSelect(); break; case NAV_ACCESS_1: case NAV_ACCESS_2: case NAV_HOTKEY_1: case NAV_HOTKEY_2: case NAV_HOTKEY_3: case NAV_HOTKEY_4: case NAV_HOTKEY_5: case NAV_HOTKEY_6: case NAV_HOTKEY_7: case NAV_HOTKEY_8: case NAV_HOTKEY_9: default: printf("Unknown NAV option\n"); return 1; break; } } }
//functions to move the menu selection void Pause_Menu::moveButtons(){ //if key was just pressed, then move button and update still_pressed bools //if key was just released, then update still_pressed bools //key up if (keys[KEY_UP] && !key_up_still_pressed){ menuUp(); key_up_still_pressed = true; } else if (!keys[KEY_UP] && key_up_still_pressed){ key_up_still_pressed = false; } //key down if (keys[KEY_DOWN] && !key_down_still_pressed){ menuDown(); key_down_still_pressed = true; } else if (!keys[KEY_DOWN] && key_down_still_pressed){ key_down_still_pressed = false; } }
/****************************************************************************** * @fn main * * @brief Main handles all applications attached to the menu system * * input parameters * * output parameters * *@return */ void main( void ) { // Init clocks and I/O bspInit(BSP_SYS_CLK_16MHZ); // Init leds bspLedInit(); // Init Buttons bspKeyInit(BSP_KEY_MODE_POLL); // Initialize SPI interface to LCD (shared with SPI flash) bspIoSpiInit(BSP_FLASH_LCD_SPI, BSP_FLASH_LCD_SPI_SPD); /* Init Buttons */ bspKeyInit(BSP_KEY_MODE_ISR); bspKeyIntEnable(BSP_KEY_ALL); /* Init LCD and issue a welcome */ lcdInit(); lcdClear(); // Instantiate tranceiver RF spi interface to SCLK ~ 4 MHz */ //input clockDivider - SMCLK/clockDivider gives SCLK frequency trxRfSpiInterfaceInit(0x10); /* Welcome Screen Part */ lcdSendBuffer(trxebWelcomeScreen); lcdBufferPrintString(lcdDefaultBuffer,"TEXAS",60,eLcdPage6); lcdBufferPrintString(lcdDefaultBuffer,"INSTRUMENTS",60,eLcdPage7); lcdSendBufferPart(lcdDefaultBuffer, 60,127,eLcdPage6, eLcdPage7); /* MCU will stay in sleep until button is pressed */ __low_power_mode_3(); bspKeyPushed(BSP_KEY_ALL); //Clear screen lcdBufferClear(0); /* Menu Driver */ menu_t *pCurrentMenu = &mainMenu; uint8 menuButtonsPressed; menuDisplay(pCurrentMenu); __low_power_mode_3(); while(1) { menuButtonsPressed = bspKeyPushed(BSP_KEY_ALL); switch(menuButtonsPressed) { case BSP_KEY_LEFT: pCurrentMenu = menuBack(pCurrentMenu); break; case BSP_KEY_RIGHT: pCurrentMenu = menuEnter(pCurrentMenu); break; case BSP_KEY_DOWN: menuDown(pCurrentMenu); break; case BSP_KEY_UP: menuUp(pCurrentMenu); break; default: break; } menuDisplay(pCurrentMenu); /* Enter low power mode while menu driver waits on user input */ __low_power_mode_3(); } }
/** * Method used to display menu. */ void Menu::showMenu() { bool quit = false; try { configureMenu("fonts/arial.ttf", "Data/background.bmp", 20); } catch (FontException font) { //AllocConsole(); //freopen("CONOUT$", "wb", stdout); std::cout << "Nieprawidlowa sciezka do czcionki. Zakonczenie aplikacji.\n"; //system("pause"); //fclose(stdout); //FreeConsole(); exit(0); } catch (TextCreationException text) { ///AllocConsole(); //freopen("CONOUT$", "wb", stdout); std::cout << "Brak mozliwosci inicjalizacji czcionek. Zakonczenie aplikacji.\n"; //system("pause"); //fclose(stdout); //FreeConsole(); exit(0); } displayMenuBackground(); stateContext->printMenu(font, screen); while( !quit ) { SDL_Event event; if( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_KEYDOWN: { int key = event.key.keysym.sym; if( key == SDLK_UP) { menuUp(); displayMenuBackground(); stateContext->printMenu(font, screen); continue; } if( key == SDLK_DOWN) { menuDown(); displayMenuBackground(); stateContext->printMenu(font, screen); continue; } if ( key == SDLK_RETURN ) { quit = stateContext->performAction(); if (!quit) { displayMenuBackground(); stateContext->printMenu(font, screen); continue; } } if( key == SDLK_ESCAPE ) { quit = stateContext->performQuitMenuAction(); } break; } } } } }
void LCDST7565::buttonEvent(int buttonIndex, button_event_e event) { pressedButtonIndex = buttonIndex; if( event == RELEASE_EVENT ) { pressedButtonIndex = -1; //return; } if(currentMenu == MENU_HOME) { if(event == PRESS_EVENT) { switch(buttonIndex) { case 3: { menuSelect(); break; } case 0: { midi->setEnabled( ! midi->configuration()->enabled ); break; } case 1: { synth->setEnabled( ! synth->configuration()->enabled ); break; } } } } else // We are in a menu or sub menu { if(event == PRESS_EVENT || event == REPEATED_PRESS_EVENT) { if(event == PRESS_EVENT) { valStepFactor = 1; } else if(valueMenuActive) { if(++valRepeatedCount >= cSynthVal.incSpeed) { valRepeatedCount = 0; valStepFactor *= 2; } } switch(buttonIndex) { case BUT_BACK: { if( event == REPEATED_PRESS_EVENT ) { if( _menu_items[_item_index].type == MENU_ITEM_TYPE_INLINE_INT ) menuBack(); } else { menuBack(); } break; } case BUT_UP: { if(valueMenuActive) { valueMenuUp(); } else { menuUp(); } break; } case BUT_DOWN: { if(valueMenuActive) { valueMenuDown(); } else { menuDown(); } break; } case BUT_OK: { if( event == REPEATED_PRESS_EVENT ) { if( _menu_items[_item_index].type == MENU_ITEM_TYPE_INLINE_INT ) menuSelect(); } else { if(valueMenuActive) { menuBack(); } else { menuSelect(); } } break; } } } } update(); }