Wed Aug 20, 2014 10:05 pm
case -1:
break;
Thu Aug 21, 2014 1:32 am
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb = Gamebuino();
#define MAINMENU_LENGTH 2
const char strSubMenu1[] PROGMEM = "Submenu 1";
const char strSubMenu2[] PROGMEM = "Submenu 2";
const char* const main_menu[MAINMENU_LENGTH] PROGMEM = {
strSubMenu1,
strSubMenu2
};
#define SUBMENU1_LENGTH 2
const char strItem1a[] PROGMEM = "Item1a";
const char strItem1b[] PROGMEM = "Item1b";
const char* const sub_menu_1[SUBMENU1_LENGTH] PROGMEM = {
strItem1a,
strItem1b
};
#define SUBMENU2_LENGTH 2
const char strItem2a[] PROGMEM = "Item2a";
const char strItem2b[] PROGMEM = "Item2b";
const char* const sub_menu_2[SUBMENU2_LENGTH] PROGMEM = {
strItem2a,
strItem2b
};
void setup() {
gb.begin();
show_opening_screen();
}
void loop() {
boolean itemSelected = false;
while (!itemSelected) {
switch(gb.menu(main_menu, MAINMENU_LENGTH))
{
case 0:
itemSelected = show_sub_menu_1();
break;
case 1:
itemSelected = show_sub_menu_2();
break;
default:
break;
}
}
show_opening_screen();
}
void show_opening_screen() {
gb.titleScreen(F("Menu Test"));
}
boolean show_sub_menu_1() {
switch(gb.menu(sub_menu_1, SUBMENU1_LENGTH)) {
case 0:
gb.popup(F("You selected item 1a"), 100);
return true;
case 1:
gb.popup(F("You selected item 1b"), 100);
return true;
default:
return false; // nothing selected
}
}
boolean show_sub_menu_2() {
switch(gb.menu(sub_menu_2, SUBMENU2_LENGTH)) {
case 0:
gb.popup(F("You selected item 2a"), 100);
return true;
case 1:
gb.popup(F("You selected item 2b"), 100);
return true;
default:
return false; // nothing selected
}
}
Thu Aug 21, 2014 1:50 am
Thu Aug 21, 2014 3:25 am
qubist wrote:Is the "default" what you do if there was nothing chosen, or is it the "case -1:"
Thu Aug 21, 2014 3:41 am