ViewShifting

 1/**
 2 * This example demonstrates how the view shifting feature works.
 3 * The view shifting feature allows the user to scroll through an item that is too long to fit on the screen.
 4 * The user can scroll the view to the left or right to see the entire item.
 5 */
 6#include <LcdMenu.h>
 7#include <MenuScreen.h>
 8#include <display/LiquidCrystal_I2CAdapter.h>
 9#include <input/KeyboardAdapter.h>
10#include <renderer/CharacterDisplayRenderer.h>
11
12#define LCD_ROWS 2
13#define LCD_COLS 16
14
15// clang-format off
16MENU_SCREEN(mainScreen, mainItems,
17    ITEM_BASIC("I'm short"),
18    ITEM_BASIC("I'm a very long item that doesn't fit on the screen"),
19    ITEM_BASIC("I'm another very long item that doesn't fit on the screen"),
20    ITEM_BASIC("I'm quite long too"));
21// clang-format on
22
23LiquidCrystal_I2C lcd(0x27, LCD_COLS, LCD_ROWS);
24CharacterDisplayRenderer renderer(new LiquidCrystal_I2CAdapter(&lcd), LCD_COLS, LCD_ROWS);
25LcdMenu menu(renderer);
26KeyboardAdapter keyboard(&menu, &Serial);
27
28void setup() {
29    Serial.begin(9600);
30    renderer.begin();
31    menu.setScreen(mainScreen);
32}
33
34void loop() {
35    keyboard.observe();
36}