Skip to content

Latest commit

History

History
44 lines (30 loc) 路 2.78 KB

usage.md

File metadata and controls

44 lines (30 loc) 路 2.78 KB

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.

{% hint style="warning" %}

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

{% endhint %}

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_BASICa basic menu item with no functionalityN/A
ITEM_COMMANDa menu item that executes a function when selected<ItemCommand.h>
ITEM_TOGGLEa menu item that toggles a value when selected<ItemToggle.h>
ITEM_INPUTa menu item that prompts the user to enter a value<ItemInput.h>
ITEM_SUBMENUa menu item that leads to a sub-menu when selected<ItemSubMenu.h>
ITEM_STRING_LISTa menu item that displays a value that is chosen form a list of strings<ItemList.h>
ITEM_PROGRESSa 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