String List
This is a basic example, it will show you how to use lists in the LcdMenu library.
Requested, inspired and based on previous work by @thijstriemstra 🙏
The supported datatype for the list is String
. This can be used for other primitive datatypes, you just need to pass it as a string and then parse the result to the desired datatype.
Includes
Declare the array
Initialize the array
Add the array to your MenuItem
MenuItem
You must add the size of the array in order for the menu to know when to stop or loop while cycling through the items in the list.
Constructor reference:
key: The key of the menu item.
items: The array of items to display.
itemCount: The number of items in the array.
callback: A pointer to the callback function to execute when this menu item is selected.
Enter edit mode
Cycle through the list
Use menu.left()
and/or menu.right()
to cycle through the items
When
left()
is invoked the view cycles down the listWhen
right()
is invoked the view cycles up the list, you can use onlyright()
if you have a single button, because once the menu reaches the end of the list, it automatically goes to the beginning.
5. Run when an item is selected
When back()
is invoked, the command (callback) bound to the item is invoked.
Full example 👉 .../examples/List/List.ino
Last updated