The following controls exist for the menu

This library already contains pre-made menu control helpers that you can use and extend.

To use the existing helpers, add the following import (preferably after all imports)

#include <utils/commandProccesors.h>

Then do the following in the loop function

void loop() {
    byte command = // read my command from an input device (serial, keypad, etc);
    // Process the command
    processMenuCommand(menu, command, UP, DOWN, ENTER, BACK);
    // UP, DOWN, ENTER, BACK are the values used to match the value of command

processMenuCommand has multiple definitions depending on the type of menu items you have in your menu. See commandProcessors.h and the example code.

Under the hood, commandProcessors use the following functions, you can use them directly if you don't want to use the helpers provided.

Navigate up and down the menu. When the menu is in edit mode, this action has no effect.

If the menu is in edit mode,

  • for ITEM_INPUT it moves along the characters of the value.

  • for ITEM_STRING_LIST it cycles through the items.

  • for ITEM_PROGRESS it decrements and increments the progress respectively

If the active item is:

  • ITEM_INPUT, ITEM_STRING_LIST or ITEM_PROGRESS It goes into edit mode.

  • ITEM_COMAND or ITEM_TOGGLE it executes the bound callback

  • ITEM_SUBMENU it enters the sub-menu.

If the current menu displayed is a sub-menu, it navigates back to the parent menu.

If the current item is ITEM_INPUT, ITEM_STRING_LIST or ITEM_PROGRESS it exits edit mode and executes the callback bound to the item.

If the current item is ITEM_INPUT, it removes one character from the end of the current value.

If the current item is ITEM_INPUT, it appends one character at the current cursor position to the current value of the item.

It does the same as type but doesn't set the value, it just draws it to the display.

Last updated