ArduinoMenu
ArduinoMenu copied to clipboard
SubMenu does not respond unless extra menu item is added
Hi, I'm having a problem that looks like a memory overwrite problem. I made a submenu with 3 items:
MENU(GenMenu, "General", doNothing,noEvent,wrapStyle,
OP("Battery", menu_item_battery_status, (eventMask)(focusEvent | blurEvent)),
OP("About", menu_item_about_status, (eventMask)(focusEvent | blurEvent)),
EXIT("<BACK")
);
And when I press on the EXIT(), menu_item_battery_status()
is executed. The other menu items when selected, don't call any of the callbacks.
Now, when I add in another menu item, lablelled "Sound" below, everything works:
MENU(GenMenu, "General", doNothing,noEvent,wrapStyle,
OP("Sound", menu_item_sound_status, enterEvent),
OP("Battery", menu_item_battery_status, (eventMask)(focusEvent | blurEvent)),
OP("About", menu_item_about_status, (eventMask)(focusEvent | blurEvent)),
EXIT("<BACK")
);
I checked the generated code after macro expansion, and I get this for
Broken with 3 menu items:
const char title_52[] ="Battery";
Menu::promptShadows opShadows52={ (Menu::callback)menu_battery_status, _noStyle, title_52, (eventMask)(focusEvent | blurEvent), noStyle };
prompt op52(opShadows52.obj);
const char title_53[] ="About";
Menu::promptShadows opShadows53={ (Menu::callback)menu_about_status, _noStyle, title_53, (eventMask)(focusEvent | blurEvent), noStyle };
prompt op53(opShadows53.obj);
const char title_54[] ="<BACK";
Menu::promptShadows opShadows54 = { (Menu::callback)Menu::doExit, Menu::_Exit, title_54, Menu::enterEvent };
Menu::prompt op54(opShadows54.obj);
const char GenMenu_text[] ="General";
Menu::prompt* GenMenu_data[] ={ &op52, &op53, &op54, };
Menu::menuNodeShadows GenMenuShadows={ (Menu::callback)doNothing, (Menu::systemStyles)((Menu::_menuData|Menu::_canNav)|Menu::_menuData|Menu::_canNav), GenMenu_text, noEvent, wrapStyle, sizeof(GenMenu_data)/sizeof(Menu::prompt*), GenMenu_data };
Menu::menu GenMenu(GenMenuShadows.obj);
Works with 4 menu items:
const char title_52[] ="Sound";
Menu::promptShadows opShadows52={ (Menu::callback)menu_sound_status, _noStyle, title_52, enterEvent, noStyle };
prompt op52(opShadows52.obj);
const char title_53[] ="Battery";
Menu::promptShadows opShadows53={ (Menu::callback)menu_battery_status, _noStyle, title_53, (eventMask)(focusEvent | blurEvent), noStyle };
prompt op53(opShadows53.obj);
const char title_54[] ="About";
Menu::promptShadows opShadows54={ (Menu::callback)menu_about_status, _noStyle, title_54, (eventMask)(focusEvent | blurEvent), noStyle };
prompt op54(opShadows54.obj);
const char title_55[] ="<BACK";
Menu::promptShadows opShadows55 = { (Menu::callback)Menu::doExit, Menu::_Exit, title_55, Menu::enterEvent };
Menu::prompt op55(opShadows55.obj);
const char GenMenu_text[] ="General";
Menu::prompt* GenMenu_data[] ={ &op52, &op53, &op54, &op55, };
Menu::menuNodeShadows GenMenuShadows={ (Menu::callback)doNothing, (Menu::systemStyles)((Menu::_menuData|Menu::_canNav)|Menu::_menuData|Menu::_canNav), GenMenu_text, noEvent, wrapStyle, sizeof(GenMenu_data)/sizeof(Menu::prompt*), GenMenu_data };
Menu::menu GenMenu(GenMenuShadows.obj);
For the life of me, I can't see any code differences (besides the numbering) between the two macro expansions. So is there some memory setting or Menu settings that I have to change to get the above 3 menu time code to work?
Thanks for any pointers cytan