Usage

To use the LcdMenu library in your project, follow these steps:

1. Include the LcdMenu library in your sketch

#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.

#include LcdMenu.h should always be the last include statement after all menu-item type imports

2. Create the main menu, using the provided macro MAIN_MENU() e.g.

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:

TypeDescriptionImport

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.

3. Once you have created your menu, initialize LcdMenu with the menu items in the setup()

menu.setupLcdWithMenu(0x27, mainMenu); //I2C
// or
menu.setupLcdWithMenu(rs, en, d0, d1, d2, d3, mainMenu); // Standard

4. In the loop() function, define how you want to navigate the menu

You can use any input method of your choice to perform actions on the menu

Last updated