To use the LcdMenu library in your project, follow these steps:
#include <LcdMenu.h>
You will need to add other includes for the types of menu items you wish to use, the available types are described in the next step.
{% hint style="warning" %}
{% endhint %}
MAIN_MENU(
ITEM_INPUT("Connect", resultCallback),
ITEM_BASIC("Settings"),
ITEM_COMMAND("Backlight", toggleBacklight),
ITEM_TOGGLE("Toggle", "ON", "OFF", toggleStuff)
);
Replace the sample menu items with your own menu items. Here are the different types of menu items available:
Type | Description | Import |
---|---|---|
ITEM_BASIC | a basic menu item with no functionality | N/A |
ITEM_COMMAND | a menu item that executes a function when selected | <ItemCommand.h> |
ITEM_TOGGLE | a menu item that toggles a value when selected | <ItemToggle.h> |
ITEM_INPUT | a menu item that prompts the user to enter a value | <ItemInput.h> |
ITEM_SUBMENU | a menu item that leads to a sub-menu when selected | <ItemSubMenu.h> |
ITEM_STRING_LIST | a menu item that displays a value that is chosen form a list of strings | <ItemList.h> |
ITEM_PROGRESS | a menu item that displays a mappable progress value from 0 to 1000. | <ItemProgress.h> |
For each menu item, specify the menu item text, and any necessary parameters. For example, in ITEM_COMMAND("Backlight", toggleBacklight)
, "Backlight"
is the menu item text and toggleBacklight
is the function to be executed when the item is selected.
menu.setupLcdWithMenu(0x27, mainMenu); //I2C
// or
menu.setupLcdWithMenu(rs, en, d0, d1, d2, d3, mainMenu); // Standard
You can use any input method of your choice to perform actions on the menu