Skip to content

Commit

Permalink
Update tolerance widget to display correctly in Widgets example.
Browse files Browse the repository at this point in the history
- Fix tolerance spelling in Quantity widget lambda function
- Change Freq widget ranges to not allow wrapping
  • Loading branch information
forntoh committed Oct 29, 2024
1 parent 4e12256 commit bbb3347
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/Widgets/Widgets.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@

#define LCD_ROWS 2
#define LCD_COLS 16
#define LCD_ADDR 0x27

// Custom characters
byte plusMinus[8] = {B00000, B00100, B01110, B00100, B00000, B01110, B00000, B00000}; // ±
byte euro[8] = {B00111, B01000, B11110, B01000, B11110, B01000, B00111, B00000}; //

const char* options[] = {"Buy", "Sell"};
const char* days[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
const char* pinChars = "123456789ABCDEF";
const char pinChars[] = "123456789ABCDEF";

MENU_SCREEN(
mainScreen,
Expand All @@ -33,14 +34,14 @@ MENU_SCREEN(
WIDGET_RANGE(10, 5, 0, 1000, "%.1d\003", 1)),
ITEM_WIDGET(
"Quantity",
[](float quantity, int tollerance) { Serial.println(quantity); Serial.println(tollerance); },
[](float quantity, int tolerance) { Serial.println(quantity); Serial.println(tolerance); },
WIDGET_RANGE(1.0f, 0.1f, 0.1f, 100.0f, "%.1f", 0),
WIDGET_RANGE(10, 1, 0, 100, "\002%d%%", 1)),
ITEM_WIDGET(
"Freq",
[](int hour, int minute, const char* day) { Serial.println(hour); Serial.println(minute); Serial.println(day); },
WIDGET_RANGE(0, 1, 0, 23, "%02d", 0, true),
WIDGET_RANGE(0, 1, 0, 59, ":%02d", 0, true),
WIDGET_RANGE(0, 1, 0, 23, "%02d", 0, false),
WIDGET_RANGE(0, 1, 0, 59, ":%02d", 0, false),
WIDGET_LIST(days, sizeof(days) / sizeof(days[0]), 0, " on %s", 0, true)),
ITEM_WIDGET(
"Start",
Expand All @@ -56,7 +57,7 @@ MENU_SCREEN(
WIDGET_LIST(pinChars, strlen(pinChars), 10, "%c", 0, true),
WIDGET_LIST(pinChars, strlen(pinChars), 14, "%c", 0, true)));

LiquidCrystal_I2C lcd(0x27, LCD_COLS, LCD_ROWS);
LiquidCrystal_I2C lcd(LCD_ADDR, LCD_COLS, LCD_ROWS);
LiquidCrystal_I2CAdapter lcdAdapter(&lcd);
CharacterDisplayRenderer renderer(&lcdAdapter, LCD_COLS, LCD_ROWS);
LcdMenu menu(renderer);
Expand Down

0 comments on commit bbb3347

Please sign in to comment.