Skip to content

Commit

Permalink
Update SimpleRotary Example
Browse files Browse the repository at this point in the history
- Added ItemWidget.h and WidgetList.h
- Replaced ITEM_STRING_LIST with ITEM_WIDGET for colors
  • Loading branch information
forntoh committed Oct 28, 2024
1 parent f03ca96 commit 7dcb67f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/SimpleRotary/SimpleRotary.ino
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
#include <ItemIntRange.h>
#include <ItemList.h>
#include <ItemToggle.h>
#include <ItemWidget.h>
#include <LcdMenu.h>
#include <MenuScreen.h>
#include <SimpleRotary.h>
#include <display/LiquidCrystal_I2CAdapter.h>
#include <input/SimpleRotaryAdapter.h>
#include <renderer/CharacterDisplayRenderer.h>
#include <widget/WidgetList.h>

#define LCD_ROWS 2
#define LCD_COLS 16

// Declare the callbacks
void callback(int pos);
void colorsCallback(uint8_t pos);
void toggleBacklight(bool isOn);

String colors[] = {"Red", "Green", "Blue", "Orange", "Aqua", "Yellow", "Purple", "Pink"};
const char* colors[] = {"Red", "Green", "Blue", "Orange", "Aqua", "Yellow", "Purple", "Pink"};

// clang-format off
MENU_SCREEN(mainScreen, mainItems,
ITEM_BASIC("Connect to WiFi"),
ITEM_STRING_LIST("Color", colors, 8, colorsCallback),
ITEM_WIDGET(
"Color",
[](const char* color) { Serial.println(color); },
WIDGET_LIST(colors, 8, 0, "%s")),
ITEM_BASIC("Blink SOS"),
ITEM_INT_RANGE("Dist", 0, 50, 0, callback, "%dm"),
ITEM_TOGGLE("Backlight", toggleBacklight),
Expand Down Expand Up @@ -51,7 +55,3 @@ void toggleBacklight(bool isOn) {
void callback(int pos) {
Serial.println(pos);
}

void colorsCallback(uint8_t pos) {
Serial.println(colors[pos]);
}

0 comments on commit 7dcb67f

Please sign in to comment.