Hi all,
I've created a new release of my OpenMoCo libraries for motion control applications (available here: Dynamic Perception ), but I wanted to bring attention to a new library included in it: OMMenuMgr, which is a completely automated menuing system for the arduino.
I know there are a number of menuing libraries out there, but none of them met our needs as we have several different projects active, some of which use up to dozens of menu items. One of the key problems I needed to eliminate were duplicated code in menu handling - such as needing to determine which value is being edited, display it properly, allow temporary edits, and then save it to the final value only when the user chooses to. Using any existing menu libraries would've required a great deal of code, and provided little advantage for us when the base menu navigation was the easiest part of the project. Essentially, the only thing this menu system doesn't do for you is draw the characters on the LCD (but it does call your function to do it =)
This is a first release of the library, so obviously it has some limitations, and there may be some warts left to uncover, but for a high-level description:
The OpenMoCo Menu Manager provides a nearly complete automation of a menuing system. This class is designed to allow for rapid development of menuing systems on Arduino devices, using up to five input controls (buttons), and character displays of at least two rows. Designed to make it easy to implement menu systems, the Menu Manager requires the developer to do little more than specify the structure of the menu, and how to draw on the display.
Key features:
- Menu structures automatically and easily stored in program memory instead of SRAM
- Automatic handling of either analog or digital button inputs
- Automatic management of user inputs for numeric and select list types
-- In-place editing with ability for user to abort
-- Write-back on user save to original variables
-- Specify lists of display values for users to select between
-- Control over user input precision in floats, and more - Ability to trigger code actions from menu items
- One-method polling automatically handles and executes menu as-needed
- Streamlined setup for complex and even recursive menus
- Support for any width screen
- Reduced memory footprint
- No fixed limitations on menu depths, have as many sub-menus as you require
- Flexible drawing methodology allows the use of any character-based (or even graphic) display
The Menu Manager displays a character-based menu when triggered by the user. Five user inputs are used (although only four are required): Enter, Up, Down, Back, and Forward. Forward is optional. These inputs may either be buttons tied to digital pins, or up to five buttons tied to a single analog pin using a series of resistors to present different analog values when a button is pressed.
The menu is triggered by hitting the Enter key by the user when the menu is enabled. When it is displayed, the user is presented with all available options at the current menu level, one per row, with a cursor indicating the currently selected item. The up and down keys scroll the list through all available items at the current menu level. If the user presses enter, or forward on the current item, the item will be presented as either a value edit, a new menu, or an action will be executed as defined by the user based on the type of the menu entry. The back button will cancel out of the current input, go back one menu level, or exit the menu entirely if the user is at the root menu level.
When a value is being edited, the user may adjust the value within the range specified by the developer non-destructively using the up and down buttons. The user may cancel the edit of the value by using the back button, or may save the value using either of enter or forward. When the user saves the value, it is written directly to the variable specified by the developer. All numeric types are supported, and special select lists are supported as well. For select lists, the user is presented with strings defined by the developer for the numeric values stored in the target variable, providing the ability to give the user a more complete and obvious solution.
Menu items may also be sub-menus. You can even re-use the same sub-menus under different menus with minimal impact to flash size and SRAM usage, letting you use the same menus under different contexts.
Menu items may be actions - you may wish to draw special screens and allow for use-case driven inputs. In this manner, you can trigger callbacks when menu items are triggered and disable the menu easily while interacting with the user, and then seamlessly place the user back into the menu where they left off when they are done.
Finally, the Menu Manager can be used to easily poll the user inputs without drawing the menu as needed by the developer.
The complete documentation for the menu manager is available here, which covers its capabilities and usage in great detail: Dynamic Perception
The library is available for download as part of the OpenMoCo AVR Libraries here: Dynamic Perception
I'd love your feedback!