Skip to content

Commit abc82e6

Browse files
committed
updated examples - ESP32 includes preferences and eink.
1 parent 243a8fc commit abc82e6

File tree

6 files changed

+70
-20
lines changed

6 files changed

+70
-20
lines changed

examples/esp/esp32SimHub/dashboardSetup.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,26 @@ void CustomDashboardDelegate::dashboardDidDraw(unsigned int encVal, RenderPressM
4242
// DashDrawParametersIntUpdateRange that can change colors when certain ranges are met, and finally a text matching
4343
// DashDrawParametersTextUpdateRange that changes color for certain string matches.
4444
DashDrawParametersIntUpdateRange::IntColorRange const rpmRanges[] = {
45-
{ ILI9341_GREEN, ILI9341_BLACK, 7000, 13000},
46-
{ ILI9341_ORANGE, ILI9341_BLACK, 13000, 14000 },
47-
{ ILI9341_RED, ILI9341_YELLOW , 14000, 20000},
45+
{ RGB_COL_GREEN, RGB_COL_BLACK, 7000, 13000},
46+
{ RGB_COL_ORANGE, RGB_COL_BLACK, 13000, 14000 },
47+
{ RGB_COL_RED, RGB_COL_YELLOW , 14000, 20000},
4848
};
4949
DashDrawParametersIntUpdateRange rpmDrawParams(ILI9341_WHITE, ILI9341_BLACK, ILI9341_WHITE, ILI9341_BLACK, &FreeSans18pt7b, rpmRanges, 3);
5050

5151
DashDrawParametersTextUpdateRange::TextColorOverride const gearRanges[] = {
52-
{ "R", ILI9341_GREEN, ILI9341_BLACK },
53-
{ "N", ILI9341_ORANGE, ILI9341_BLACK }
52+
{ "R", RGB_COL_GREEN, RGB_COL_BLACK },
53+
{ "N", RGB_COL_ORANGE, RGB_COL_BLACK }
5454
};
5555
DashDrawParametersTextUpdateRange gearDrawParams(ILI9341_WHITE, ILI9341_BLACK, ILI9341_WHITE, ILI9341_PURPLE, &RobotoMono_SemiBold60pt7b,
5656
gearRanges, 2, DashDrawParameters::NO_TITLE_VALUE_LEFT);
5757

58-
DashDrawParameters white18ptNoUpdate(ILI9341_WHITE, ILI9341_BLACK, &FreeSans18pt7b);
58+
DashDrawParameters white18ptNoUpdate(RGB_COL_WHITE, RGB_COL_BLACK, &FreeSans18pt7b);
5959

60-
DashDrawParametersUpdate white18ptUpdateRightParam(ILI9341_WHITE, ILI9341_BLACK, ILI9341_CYAN, ILI9341_PURPLE, &FreeSans18pt7b);
60+
DashDrawParametersUpdate white18ptUpdateRightParam(RGB_COL_WHITE, RGB_COL_BLACK, RGB_COL_CYAN, RGB_COL_PURPLE, &FreeSans18pt7b);
6161

62-
DashDrawParametersUpdate yellow9PtUpdateLeft(ILI9341_YELLOW, ILI9341_BLACK, ILI9341_CYAN, ILI9341_PURPLE,
62+
DashDrawParametersUpdate yellow9PtUpdateLeft(RGB_COL_YELLOW, RGB_COL_BLACK, RGB_COL_CYAN, RGB_COL_PURPLE,
6363
&FreeSans9pt7b, DashDrawParameters::TITLE_LEFT_VALUE_LEFT);
64-
DashDrawParametersUpdate yellow9PtUpdateRight(ILI9341_YELLOW, ILI9341_BLACK, ILI9341_CYAN, ILI9341_PURPLE,
64+
DashDrawParametersUpdate yellow9PtUpdateRight(RGB_COL_YELLOW, RGB_COL_BLACK, RGB_COL_CYAN, RGB_COL_PURPLE,
6565
&FreeSans9pt7b, DashDrawParameters::TITLE_LEFT_VALUE_RIGHT);
6666

6767
//
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#ifndef TCMENU_THEME_BLOCK
2+
#define TCMENU_THEME_BLOCK
3+
4+
#include <graphics/TcThemeBuilder.h>
5+
#include <UnicodeFontDefs.h>
6+
#include <Fonts/OpenSansRegular7pt.h>
7+
8+
9+
color_t defaultItemPalette[] = { 1, 0, 1, 1 };
10+
color_t defaultTitlePalette[] = { 0, 1, 1, 1 };
11+
12+
/**
13+
* This is one of the stock themes, you can modify it to meet your requirements, and it will not be updated by tcMenu
14+
* Designer unless you delete it. This sets up the fonts, spacing and padding for all items.
15+
* @param gr the graphical renderer
16+
*/
17+
void applyTheme(GraphicsDeviceRenderer& gr) {
18+
19+
// See https://tcmenu.github.io/documentation/arduino-libraries/tc-menu/themes/rendering-with-themes-icons-grids/
20+
TcThemeBuilder themeBuilder(gr);
21+
themeBuilder.withSelectedColors(0, 1)
22+
.dimensionsFromRenderer()
23+
.withItemPadding(MenuPadding(2))
24+
.withRenderingSettings(BaseGraphicalRenderer::TITLE_FIRST_ROW, false)
25+
.withPalette(defaultItemPalette)
26+
.withTcUnicodeFont(OpenSansRegular7pt)
27+
.withSpacing(1)
28+
.withStandardLowResCursorIcons()
29+
.enableTcUnicode();
30+
31+
themeBuilder.defaultTitleProperties()
32+
.withTcUnicodeFont(OpenSansRegular7pt)
33+
.withPalette(defaultTitlePalette)
34+
.withPadding(MenuPadding(2))
35+
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE)
36+
.withSpacing(2)
37+
.apply();
38+
39+
themeBuilder.defaultActionProperties()
40+
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE)
41+
.apply();
42+
43+
themeBuilder.defaultItemProperties()
44+
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT)
45+
.apply();
46+
47+
themeBuilder.apply();
48+
}
49+
50+
#endif //TCMENU_THEME_BLOCK
51+

examples/esp/esp32s2Saola/esp32s2Saola.emf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,12 @@
517517
},
518518
{
519519
"name": "THEME_COLOR_ITEM_HL",
520-
"latestValue": "2",
520+
"latestValue": "1",
521521
"subsystem": "THEME"
522522
},
523523
{
524524
"name": "THEME_COLOR_ITEM_EX",
525-
"latestValue": "2",
525+
"latestValue": "1",
526526
"subsystem": "THEME"
527527
},
528528
{
@@ -560,7 +560,7 @@
560560
"useCppMain": false,
561561
"saveLocation": "ALL_TO_CURRENT",
562562
"usingSizedEEPROMStorage": false,
563-
"eepromDefinition": "eeprom:",
563+
"eepromDefinition": "prefs:menuStore:1024",
564564
"authenticatorDefinition": "rom:200:4",
565565
"projectIoExpanders": [
566566
"deviceIO:"

examples/esp/esp32s2Saola/esp32s2Saola.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Getting started: https://tcmenu.github.io/documentation/arduino-libraries/tc-menu/tcmenu-overview-quick-start/
66
//
77

8-
#include "generated/esp32s2Saola_menu.h"
8+
#include "esp32s2Saola_menu.h"
99
#include <PlatformDetermination.h>
1010

1111
#include <TaskManagerIO.h>
@@ -14,7 +14,6 @@
1414
#include <WiFi.h>
1515
#include <stockIcons/wifiAndConnectionIcons16x12.h>
1616
#include <tcUtil.h>
17-
#include "u8g2DashConfig.h"
1817
#include <SPI.h>
1918

2019
#define MENU_WIFIMODE_STATION 0

examples/esp/esp32s2Saola/esp32s2Saola_menu.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use elsewhere.
99
*/
1010

11-
// Generated for Arduino ESP32 by TcMenu 4.5.0 on 2026-01-10T09:26:38.026123Z.
11+
// Generated for Arduino ESP32 by TcMenu 4.5.0 on 2026-01-10T12:21:58.926913300Z.
1212

1313
#include <tcMenu.h>
1414
#include "esp32s2Saola_menu.h"
@@ -17,7 +17,7 @@
1717
// Global variable declarations
1818
const PROGMEM ConnectorLocalInfo applicationInfo = { "ESP32-S2 Saola board", "b447b433-fe4f-4ce7-8746-d94bfeefc707" };
1919
TcMenuRemoteServer remoteServer(applicationInfo);
20-
ArduinoEEPROMAbstraction glArduinoEeprom(&EEPROM);
20+
EspPreferencesEeprom glEspRom("menuStore", 1024);
2121
EepromAuthenticatorManager authManager(4);
2222
TcGxEPD2 display(GxEPD2_154_GDEY0154D67(-1, -1, -1, -1));
2323
TcMenuGxEPDeInk drawable(display);
@@ -85,12 +85,12 @@ AnalogMenuItem menuIntEdit(&minfoIntEdit, 0, &menuDecEdit, INFO_LOCATION_PGM);
8585
void setupMenu() {
8686
// First we set up eeprom and authentication (if needed).
8787
setSizeBasedEEPROMStorageEnabled(false);
88-
menuMgr.setEepromRef(&glArduinoEeprom);
88+
menuMgr.setEepromRef(&glEspRom);
8989
authManager.initialise(menuMgr.getEepromAbstraction(), 200);
9090
menuMgr.setAuthenticator(&authManager);
9191
// Now add any readonly, non-remote and visible flags.
92-
menuConnectivityIoTMonitor.setLocalOnly(true);
9392
menuConnectivityAuthenticator.setLocalOnly(true);
93+
menuConnectivityIoTMonitor.setLocalOnly(true);
9494

9595
// Code generated by plugins and new operators.
9696
display.init(115200, true, 10, false);

examples/esp/esp32s2Saola/esp32s2Saola_menu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <ScrollChoiceMenuItem.h>
2424
#include <IoAbstraction.h>
2525
#include <EepromItemStorage.h>
26-
#include <ArduinoEEPROMAbstraction.h>
26+
#include <esp32/EspPreferencesEeprom.h>
2727
#include <RemoteAuthentication.h>
2828

2929
// variables we declare that you may need to access
@@ -36,7 +36,7 @@ extern WiFiServer server;
3636
extern EthernetInitialisation ethernetInitialisation;
3737

3838
// Any externals needed by IO expanders, EEPROMs etc
39-
39+
extern EspPreferencesEeprom glEspRom;
4040

4141
// Global Menu Item exports
4242
extern EepromAuthenticationInfoMenuItem menuConnectivityAuthenticator;

0 commit comments

Comments
 (0)