Skip to main content

Overview

The Display module provides menu systems for LCD and OLED displays with built-in navigation, callbacks, and state management.

LCD Menu System

LcdMenu

Comprehensive LCD menu system with I2C support and WiFi integration.
#define ENABLE_MODULE_LCD_MENU
#include "Kinematrix.h"

LcdMenu lcd(0x27, 16, 2);  // Address 0x27, 16x2 display
MenuCursor cursor = {false, false, false, false, true};
MenuProperties* mainMenu;

void setup() {
  lcd.initialize(true);  // Debug mode
  lcd.setLen(16, 2);
  
  mainMenu = lcd.createMenu(3, "Main Menu", "Settings", "Exit");
  
  lcd.showMenu(mainMenu);
}

void loop() {
  lcd.onListen(&cursor, []() {
    // Handle button inputs
  });
}
initialize
void
Initialize LCD display
setLen
void
Set display dimensions
createMenu
MenuProperties*
Create menu with variadic items
showMenu
void
Display menu on LCD
onListen
void
Listen for cursor input
onSelect
void
Handle menu selection
formatMenu
void
Format menu item text
getState
int
Get menu item state
setState
void
Set menu item state
connectToWiFi
bool
Connect to WiFi (ESP32/ESP8266 only)
struct MenuCursor {
    bool up;      // Up button pressed
    bool down;    // Down button pressed
    bool select;  // Select button pressed
    bool back;    // Back button pressed
    bool show;    // Show menu flag
};
struct MenuProperties {
    char option[24];         // Current option
    char** text;             // Menu text array
    bool* isHasCb;          // Has callback flags
    CallbackMenu* callbackMenu;  // Callback array
    uint8_t len;            // Number of items
    int select;             // Selected index
    int index;              // Current index
    int upCount;            // Up scroll count
    int* itemState;         // Item states
};

OLED Menu System

OledMenu

OLED menu system for SSD1306 displays with custom rendering.
#define ENABLE_MODULE_OLED_MENU
#include "Kinematrix.h"

OledMenu oled(128, 64);  // 128x64 OLED
MenuCursor cursor = {false, false, false, false, true};

void setup() {
  oled.initialize(true);
  oled.setDisplayParams(16, 10, 10, 3);  // itemHeight, startY, cursorW, rows
  
  MenuProperties* menu = oled.createMenu(4, "Option 1", "Option 2", 
                                             "Option 3", "Option 4");
  oled.showMenu(menu);
}

void loop() {
  oled.onListen(&cursor, []() {
    // Handle navigation
  });
}
OledMenu
constructor
Create OLED menu instance
initialize
void
Initialize OLED display
setDisplayParams
void
Configure display parameters
drawCursor
void
Draw cursor indicator
showMenu
void
Display menu on OLED
createMenu
MenuProperties*
Create menu with items
onSelect
void
Handle selection with callback

Example: Complete Menu System

#define ENABLE_MODULE_LCD_MENU
#include "Kinematrix.h"

LcdMenu lcd(0x27, 16, 2);
MenuCursor cursor;
MenuProperties *mainMenu, *settingsMenu;

void settingsHandler() {
  lcd.clear();
  lcd.showMenu(settingsMenu);
}

void setup() {
  lcd.initialize();
  
  // Create main menu
  mainMenu = lcd.createMenu(3, "Start", "Settings", "About");
  
  // Create settings menu
  settingsMenu = lcd.createMenu(2, "Brightness", "Back");
  
  // Add callbacks
  lcd.onSelect(mainMenu, "Settings", settingsHandler);
  
  lcd.showMenu(mainMenu);
}

void loop() {
  // Read buttons and update cursor
  cursor.up = digitalRead(BTN_UP) == LOW;
  cursor.down = digitalRead(BTN_DOWN) == LOW;
  cursor.select = digitalRead(BTN_SELECT) == LOW;
  
  lcd.onListen(&cursor, []() {
    lcd.onCursor(mainMenu);
  });
  
  delay(10);
}

Display Comparison

FeatureLCD MenuOLED Menu
ResolutionCharacter-basedPixel-based
InterfaceI2CI2C/SPI
GraphicsLimitedFull graphics
PowerHigherLower
Viewing AngleWideLimited
CostLowerHigher

Platform Support

ESP32

Full support with WiFi features

ESP8266

Full support with WiFi

AVR

Full support (no WiFi)

Build docs developers (and LLMs) love