Skip to content
Logo LogoLcdMenu
Docs Changelog License
⌘ K
Logo LogoLcdMenu
Docs Changelog License

Overview

  • Getting started
  • Menu Screen
  • Item overview
    • Basic menu item
    • Value display item
    • Command menu item
    • Sub-menu item
    • Item Widget
    • Item List
    • Item Range
    • Item Bool
    • Input item
    • Charset input item
  • Widget overview
    • WidgetBool
    • WidgetList
    • WidgetRange
  • Controlling the menu
    • Keyboard Adapter
    • Button Adapter
    • Rotary Encoder Adapter
    • Analog Button Adapter
  • Rendering the menu
    • Character display renderer

Reference

  • Code samples
    • InputRotary
    • SubMenu
    • SimpleRotary
    • IntFloatValues
    • SimpleInput
    • KeyboardAdapter
    • pcf8574_i2c
    • ItemValue
    • RTOS
    • KeypadShield
    • ViewShifting
    • MenuTimeout
    • DynamicMenu
    • ButtonWithRotaryAdapter
    • UseByRef
    • List
    • ItemBack
    • Basic
    • Widgets
    • Callbacks
    • CharsetInput
    • SSD1803A_I2C
    • ButtonAdapter
  • API reference
    • MenuItem
    • ItemCommand
    • MenuScreen
    • ItemBool
    • ItemInput
    • ItemSubMenu
    • ItemToggle
    • ItemInputCharset
    • ItemValue
    • ItemWidget
    • ItemRange
    • BaseItemManyWidgets
    • ItemList
    • ItemBack
    • LcdMenu
    • BaseItemZeroWidget
    • renderer
    • input
    • display
    • widget
  • Migration
  • FAQ

Star on GitHub
Edit on GitHub
Arduino Library Badge PlatformIO Badge Check Runs Badge Documentation Status Badge GitHub Commits Badge

LcdMenu
/
API reference
/
MenuScreen

MenuScreen

Defines

MENU_SCREEN(screen, items, ...)
class MenuScreen
#include <MenuScreen.h>

Represents single screen with number of menu items. Contains logic of navigating between items. Stores current cursor and view.

Public Functions

MenuScreen(const std::vector<MenuItem*> &items = std::vector<MenuItem*>())

Constructor

void setParent(MenuScreen *parent)

Set new parent screen.

uint8_t getCursor()

Get current cursor position.

MenuItem *getItemAt(uint8_t position)

Get a MenuItem at position.

Returns:

MenuItem - item at position

MenuItem *operator[](const uint8_t position)

Get a MenuItem at position.

Returns:

MenuItem - item at position

void addItem(MenuItem *item)

Add a new item to the menu.

void addItemAt(uint8_t position, MenuItem *item)

Add a new item to the menu at the specified position.

Parameters:
  • position – The position to add the item.

  • item – The item to add.

void removeItemAt(uint8_t position)

Remove an item from the menu at the specified position.

Parameters:

position – The position of the item to remove.

void removeLastItem()

Remove the last item from the menu.

void clear()

Clear all items from the menu.

inline const size_t size()

Get the number of items in the menu.

Protected Functions

void setCursor(MenuRenderer *renderer, uint8_t position)

Move cursor to specified position.

void draw(MenuRenderer *renderer)

Draw the screen on screen.

Parameters:

renderer – The renderer to use for drawing.

void syncIndicators(uint8_t index, MenuRenderer *renderer)

Sync indicators with the renderer.

bool process(LcdMenu *menu, const unsigned char command)

Process the command.

Returns:

true if the command was processed, false otherwise.

void up(MenuRenderer *renderer)

Move cursor up.

void down(MenuRenderer *renderer)

Move cursor down.

void reset(MenuRenderer *renderer)

Reset the screen to initial state.

void poll(MenuRenderer *renderer, uint16_t pollInterval)

Poll the screen for changes.

Parameters:
  • renderer – The renderer to use for drawing.

  • pollInterval – The interval to poll the screen.

Private Members

friend LcdMenu
MenuScreen *parent = NULL

Previous screen. When BACK command received this screen will be shown.

std::vector<MenuItem*> items

The menu items to be displayed on screen. These items will be drawn on renderer.

uint8_t cursor = 0

Cursor position.

    X X
    X X X X X
┌───────────────┐
│   X X X       │
│   X X X X     │
│ > X X X X X X │ <── cursor
│   X X X X X   │
└───────────────┘
    X X X X
    X X X X X X

When up or down then this position will be moved over the items accordingly. Always in range [view, view + renderer.getMaxRows() - 1].

uint8_t view = 0

First visible item’s position in the menu array.

    X X
    X X X X X
┌───────────────┐
│   X X X       │ <── view
│   X X X X     │
│ > X X X X X X │
│   X X X X X   │
└───────────────┘
    X X X X
    X X X X X X

Is moved when cursor crosses the borders of visible area. When number of items < renderer.getMaxRows() this index should be 0. The size of the view is always the same and equals to renderer.getMaxRows().

ItemCommand
ItemBool

On this page

  • MENU_SCREEN
  • MenuScreen
    • MenuScreen()
    • setParent()
    • getCursor()
    • getItemAt()
    • operator[]()
    • addItem()
    • addItemAt()
    • removeItemAt()
    • removeLastItem()
    • clear()
    • size()
    • setCursor()
    • draw()
    • syncIndicators()
    • process()
    • up()
    • down()
    • reset()
    • poll()
    • parent
    • items
    • cursor
    • view

© 2025, Thomas Forntoh