You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
First, I would like to thank you for the menu system it seems well thought out.
But I have a few questions.
In my use case I will be re-using menu items in multiple menus. I think this is possible but I am having some confusion.
Here is an example, this is for a sprinkler controller if it helps.
The Menu would like like this:
Manual
---Valve 1
------Set Minutes
Program
---Valve 1
------Set Minutes
Code snippet:
// Define menus and menu items
Menu mu1("Manual");
Menu v1("Valve 1");
MenuItem setmin("Set Minutes",&on_setMinutes_selected);
Menu mu2("Program");
Menu mu3("Valve Run Time");
// Build Menu
ms.get_root_menu().add_menu(&mu1); // Add "Manual" to root menu
mu1.add_menu(&v1); // Add "Valve 1" menu under "Manual"
v1.add_item(&setmin); // Add "Set Minutes" under "Valve 1"
ms.get_root_menu().add_menu(&mu2); // Add "Program" to root menu
mu2.add_menu(&mu3); // Add "Valve Run Time" menu under "Program"
mu3.add_menu(&v1); // Add "Valve 1" (and "Set Minutes") under "Valve Run Time"
My question is in the callback function on_setMinutes_selected, I need to know if the menu path started at "Program" or "Manual". Is there a way to keep track of the menu path taken to a given callback.
It would be a bit wasteful if different MenuItems were needed for each endpoint callback.
I see that support for NumericMenuItem but I am not understanding its purpose. Can you elaborate with a small sample?
Thank you!
The text was updated successfully, but these errors were encountered:
In your example I think they are two different menu items: one in the "manual" context and the other in the "program" context. If you really want code reuse, have two callback functions call a common setMinutes function.
As for actually reusing a menu item, this isn't possible I'm afraid. You could hack it by adding path information to the menu name, but I doubt you want that.
For NumericMenuItem check out the serial_nav example. In short, the NumericMenuItem is a concrete MenuItem that holds a numeric value that can be incremented or decremented.
Hello,
First, I would like to thank you for the menu system it seems well thought out.
But I have a few questions.
Here is an example, this is for a sprinkler controller if it helps.
The Menu would like like this:
Manual
---Valve 1
------Set Minutes
Program
---Valve 1
------Set Minutes
Code snippet:
// Define menus and menu items
Menu mu1("Manual");
Menu v1("Valve 1");
MenuItem setmin("Set Minutes",&on_setMinutes_selected);
Menu mu2("Program");
Menu mu3("Valve Run Time");
// Build Menu
ms.get_root_menu().add_menu(&mu1); // Add "Manual" to root menu
mu1.add_menu(&v1); // Add "Valve 1" menu under "Manual"
v1.add_item(&setmin); // Add "Set Minutes" under "Valve 1"
ms.get_root_menu().add_menu(&mu2); // Add "Program" to root menu
mu2.add_menu(&mu3); // Add "Valve Run Time" menu under "Program"
mu3.add_menu(&v1); // Add "Valve 1" (and "Set Minutes") under "Valve Run Time"
My question is in the callback function on_setMinutes_selected, I need to know if the menu path started at "Program" or "Manual". Is there a way to keep track of the menu path taken to a given callback.
It would be a bit wasteful if different MenuItems were needed for each endpoint callback.
Thank you!
The text was updated successfully, but these errors were encountered: