version 4.0 8/21/2024 kasprzak fixed a nast bug if number of menu items = MAX_OPT in the .h (before fix MAX_OPT had to be 1 more than number of menu items
- This library now supports use of mechanical and touch. You can press a menu item to edit, the scroll through values with an encoder.
This library will simplify creating and implementing a menu system for TFT displays that use the ILI9341_t3 library and Teensy(R) microcontrollers.
See my other repository for the AdaFruit_ILI9341 library for prjects that use that driver and an MCU such as and ESP32.
This library includes two menu objects:
- A simple selection menu (ItemMenu) where the user can scroll up/down and select an item and some programmer defined action can be performed such as drawing a screen or activating a sub menu
- A menu with in-line edit capability (EditMenu) where the user can scroll up/down the list and select an item however the difference is that move/up down on a selected item will then scroll the values stored with that menu item, selecting a selected item will restore control to moving up/down the menu list
Watch this YouTube video to see the library with touch input: https://youtu.be/wfMcTC3_8bI
Watch this YouTube video to see the library with mechanical input: https://youtu.be/KUi9f4hcV6A
To activate touch input or mechanical input just pass the in the display object
- EditMenu(&YourDisplayObject);
- ItemMenu(&YourDisplayObject);
Library highlights
- Menu control with touch screens and mechanical input such as rotary encoders or buttons
- Automatic wrapping for menu rows that exceed screen size
- For EditMenu objects, edits can be within a defined range or from an array
- Menus can include no icon, mono icon, or color icons
- Programmer has full control over margins, colors, fonts, etc.
- Menus can have up to 15 items, but expandable to more by editing the #define MAX_OPT 15
- Menu items can be enabled or disabled through code
- Automatic wrapping during editing for items within editable menus
- Menu item text can be changed at any time through code
- Initial data in EditMenu objects can be set based on stored or set values
- Menu selector bars can have round or sharp corners and have a border to accentuate selection
- Automatic up/down arrows on top and bottom screen rows to indicate to the user "there's more"
While this library was created for the ILI9341_t3 drivers with Teensy-based MCU's, the library can be adapted to other display drivers. Note the driver must use the Adafruit_GFX libraries. To allow other display drivers, modify the lines in the .h and .cpp files to allow a different driver to be passed in. For example change call such as SliderH(ILI9341_t3 *disp,... to SliderH(Adafruit_RA8875 *disp,... and in the .cpp files you may have to change how fonts are passed in using either setFont(&SomeFont) or setFont(SomeFont)
I have included an example that shows how to create multi-menu system with both a simple select menu that call editable menus
1.0 1/11/22 initial code
2.0 1/28/22 added touch support