Skip to content

Commit 0ed487c

Browse files
committed
Prepare for release.
1 parent cb79992 commit 0ed487c

File tree

10 files changed

+113
-38
lines changed

10 files changed

+113
-38
lines changed

examples/arduino32/nano33ble/generated/nano33ble_menu.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
#include <tcMenu.h>
1212
#include "nano33ble_menu.h"
13-
#include "ThemeMonoInverse.h"
14-
#include "tcMenuBLERemoteConnector.h"
13+
#include "../ThemeMonoInverse.h"
1514

1615
// Global variable declarations
1716
const ConnectorLocalInfo applicationInfo = { "Nano 33 BLE Sense", "e95fcf8a-8a03-4043-9313-01fd8b8e8707" };
@@ -50,10 +49,6 @@ AnalogMenuItem menuHumidity(&minfoHumidity, 0, &menuBPressure, INFO_LOCATION_PGM
5049
const AnalogMenuInfo minfoTemp = { "Temp", 1, 0xffff, 2000, NO_CALLBACK, 0, 10, "C" };
5150
AnalogMenuItem menuTemp(&minfoTemp, 0, &menuHumidity, INFO_LOCATION_PGM);
5251

53-
tcremote::TcMenuRemoteServer remoteServer(applicationInfo);
54-
tcremote::BLEDeviceInitialisation bleInitialisation;
55-
tcremote::BLETagValTransport bleTransport;
56-
5752
void setupMenu() {
5853
// First we set up eeprom and authentication (if needed).
5954
setSizeBasedEEPROMStorageEnabled(false);
@@ -62,15 +57,13 @@ void setupMenu() {
6257
menuHumidity.setReadOnly(true);
6358
menuTemp.setReadOnly(true);
6459

65-
// Code generated by plugins.
60+
// Code generated by plugins and new operators.
6661
gfx.begin();
6762
renderer.setUpdatesPerSecond(10);
6863
switches.init(internalDigitalIo(), SWITCHES_POLL_EVERYTHING, true);
6964
menuMgr.initForEncoder(&renderer, &menuTemp, 5, 6, 4);
7065
renderer.setTitleMode(BaseGraphicalRenderer::TITLE_FIRST_ROW);
7166
renderer.setUseSliderForAnalog(false);
7267
installMonoInverseTitleTheme(renderer, MenuFontDef(nullptr, 1), MenuFontDef(nullptr, 1), true);
73-
74-
remoteServer.addConnection(new tcremote::TagValueRemoteServerConnection(bleTransport, bleInitialisation));
7568
}
7669

examples/arduino32/nano33ble/generated/nano33ble_menu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "tcMenuU8g2.h"
1717
#include <IoAbstraction.h>
1818
#include <EepromItemStorage.h>
19-
#include "tcMenuBLERemoteConnector.h"
2019

2120
// variables we declare that you may need to access
2221
extern const PROGMEM ConnectorLocalInfo applicationInfo;

examples/arduino32/nano33ble/nano33ble.emf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,15 @@
369369
"eepromDefinition": "",
370370
"authenticatorDefinition": "",
371371
"projectIoExpanders": [
372-
"deviceIO:",
373-
"customIO:io23017"
372+
"customIO:io23017",
373+
"deviceIO:"
374374
],
375375
"menuInMenuCollection": {
376376
"menuDefinitions": []
377377
},
378378
"packageNamespace": "",
379-
"appIsModular": false
379+
"appIsModular": false,
380+
"listOfEmbeddedForms": []
380381
},
381382
"stringLists": []
382383
}

examples/arduino32/nano33ble/nano33ble.ino

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "MotionDetection.h"
1515
#include <AnalogDeviceAbstraction.h>
1616
#include <tcMenuVersion.h>
17+
#include <ArduinoBLE.h>
1718
#include <stockIcons/wifiAndConnectionIcons16x12.h>
1819

1920
// on the analog menu, we both have an analog input and an analog output (PWM). You can configure those pins here.
@@ -74,13 +75,7 @@ void setup() {
7475
// the tcMenu version number in a dialog.
7576
// https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/rendering-with-tcmenu-lcd-tft-oled/#presenting-a-dialog-to-the-user
7677
setTitlePressedCallback([](int id) {
77-
withMenuDialogIfAvailable([](MenuBasedDialog* dlg) {
78-
dlg->setButtons(BTNTYPE_CLOSE, BTNTYPE_NONE);
79-
dlg->showRam("Nano BLE Example", false);
80-
char szVer[10];
81-
tccore::copyTcMenuVersion(szVer, sizeof szVer);
82-
dlg->copyIntoBuffer(szVer);
83-
});
78+
showVersionDialog(&applicationInfo);
8479
});
8580

8681
// lastly we set up something simple to read from analog in

examples/arduino32/picoAdafruitDashboard/picoAdafruitDashboard_menu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ AnalogMenuItem menuAnalog(&minfoAnalog, 222, &menuFloat, INFO_LOCATION_PGM);
5151

5252
void setupMenu() {
5353
// First we set up eeprom and authentication (if needed).
54+
CombinedMessageProcessor::setFormTemplatesInFlash(tcMenuAllEmbeddedForms);
5455
setSizeBasedEEPROMStorageEnabled(false);
5556
// Code generated by plugins and new operators.
5657
gfx.begin();
@@ -62,7 +63,6 @@ void setupMenu() {
6263
renderer.setTitleMode(BaseGraphicalRenderer::TITLE_FIRST_ROW);
6364
renderer.setUseSliderForAnalog(true);
6465
installCoolBlueModernTheme(renderer, MenuFontDef(&RobotoMedium24, 1), MenuFontDef(&RobotoMedium24, 1), false);
65-
CombinedMessageProcessor::setFormTemplatesInFlash(tcMenuAllEmbeddedForms);
6666
}
6767

6868
// Embedded form data

examples/arduino32/picoAdafruitDashboard/picoAdafruitDashboard_menu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ void setupMenu();
5353

5454
void CALLBACK_FUNCTION onSettingsAction(int id);
5555

56-
const EmbedControlFlashedForm*[] tcMenuAllEmbeddedForms;
56+
extern const EmbedControlFlashedForm* tcMenuAllEmbeddedForms[];
5757

5858
#endif // MENU_GENERATED_CODE_H

examples/arduino32/picoAdafruitDashboard/tcMenuAdaFruitGfx.cpp

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ using namespace tcgfx;
3434
#endif // AVR reduced size buffer
3535
#endif // COOKIE_CUT_MEMBUFFER_SIZE
3636

37+
uint16_t memBuffer[COOKIE_CUT_MEMBUFFER_SIZE];
38+
3739
void AdafruitDrawable::transaction(bool isStarting, bool redrawNeeded) {
3840
if(!isStarting) refreshDisplayIfNeeded(graphics, redrawNeeded);
3941
}
@@ -52,15 +54,58 @@ void AdafruitDrawable::drawBitmap(const Coord &where, const DrawableIcon *icon,
5254
if(icon->getIconType() == DrawableIcon::ICON_XBITMAP) {
5355
graphics->fillRect(where.x, where.y, icon->getDimensions().x, icon->getDimensions().y, backgroundColor);
5456
graphics->drawXBitmap(where.x, where.y, icon->getIcon(selected), icon->getDimensions().x, icon->getDimensions().y, drawColor);
55-
}
56-
else if(icon->getIconType() == DrawableIcon::ICON_NATIVE) {
57+
} else if(icon->getIconType() == DrawableIcon::ICON_NATIVE) {
5758
graphics->drawRGBBitmap(where.x, where.y, (const uint16_t*)icon->getIcon(selected), icon->getDimensions().x, icon->getDimensions().y);
58-
}
59-
else if(icon->getIconType() == DrawableIcon::ICON_MONO) {
59+
} else if(icon->getIconType() == DrawableIcon::ICON_MONO) {
6060
graphics->drawBitmap(where.x, where.y, icon->getIcon(selected), icon->getDimensions().x, icon->getDimensions().y, drawColor, backgroundColor);
61+
} else if(icon->getPalette() != nullptr){
62+
auto bpp = icon->getIconType() == tcgfx::DrawableIcon::ICON_PALLETE_2BPP ? 2 : 4;
63+
drawBitmapNbpp(where, icon->getIcon(selected), icon->getDimensions(), bpp, icon->getPalette());
6164
}
6265
}
6366

67+
void AdafruitDrawable::drawBitmapNbpp(const Coord& where, const uint8_t* data, const Coord& size, int bpp, const color_t* palette) {
68+
auto* asTft = reinterpret_cast<Adafruit_SPITFT *>(graphics);
69+
auto yTot = int16_t(where.y + size.y);
70+
auto xTot = int16_t(where.x + size.x);
71+
int bitsInByte = bpp == 2 ? 4 : 2;
72+
uint8_t downShift = bpp == 2 ? 6 : 4;
73+
74+
uint16_t next = 0;
75+
uint8_t byteIteration = bitsInByte;
76+
uint8_t current;
77+
78+
asTft->startWrite();
79+
80+
for(int16_t y = where.y; y<yTot; y++) {
81+
asTft->setAddrWindow(where.x, y, size.x, 1);
82+
for(int16_t x = where.x; x<xTot; x++) {
83+
if(byteIteration == bitsInByte) {
84+
current = pgm_read_byte(data);
85+
data += 1;
86+
byteIteration = 0;
87+
}
88+
uint8_t idx = current >> downShift;
89+
current = current << bpp;
90+
byteIteration++;
91+
92+
memBuffer[next] = palette[idx];
93+
next = next + 1;
94+
if(next == COOKIE_CUT_MEMBUFFER_SIZE) {
95+
asTft->writePixels(memBuffer, next);
96+
next = 0;
97+
}
98+
}
99+
if(next != 0) {
100+
asTft->writePixels(memBuffer, next);
101+
next = 0;
102+
}
103+
byteIteration = bitsInByte; // always need a new byte in this case
104+
}
105+
106+
asTft->endWrite();
107+
}
108+
64109
void AdafruitDrawable::drawXBitmap(const Coord &where, const Coord &size, const uint8_t *data) {
65110
graphics->fillRect(where.x, where.y, size.x, size.y, backgroundColor);
66111
graphics->drawXBitmap(where.x, where.y, data, size.x, size.y, drawColor);
@@ -69,8 +114,7 @@ void AdafruitDrawable::drawXBitmap(const Coord &where, const Coord &size, const
69114
void AdafruitDrawable::drawBox(const Coord &where, const Coord &size, bool filled) {
70115
if(filled) {
71116
graphics->fillRect(where.x, where.y, size.x, size.y, drawColor);
72-
}
73-
else {
117+
} else {
74118
graphics->drawRect(where.x, where.y, size.x, size.y, drawColor);
75119
}
76120
}
@@ -157,8 +201,6 @@ UnicodeFontHandler *AdafruitDrawable::createFontHandler() {
157201
// helper functions
158202
//
159203

160-
uint16_t memBuffer[COOKIE_CUT_MEMBUFFER_SIZE];
161-
162204
void drawCookieCutBitmap(Adafruit_SPITFT* gfx, int16_t x, int16_t y, const uint8_t *bitmap, int16_t w,
163205
int16_t h, int16_t totalWidth, int16_t xStart, int16_t yStart,
164206
uint16_t fgColor, uint16_t bgColor) {
@@ -519,7 +561,7 @@ DeviceDrawable *AdafruitDrawable::getSubDeviceFor(const Coord &where, const Coor
519561
}
520562

521563
AdafruitCanvasDrawable2bpp::AdafruitCanvasDrawable2bpp(AdafruitDrawable *root, int width, int height) : root(root),
522-
sizeMax({width, height}), sizeCurrent(), palette{} {
564+
sizeMax({width, height}), sizeCurrent(), palette{} {
523565
canvas = new TcGFXcanvas2(width, height);
524566
setGraphics(canvas);
525567
}
@@ -561,3 +603,26 @@ DeviceDrawable *AdafruitCanvasDrawable2bpp::getSubDeviceFor(const Coord&, const
561603
return nullptr; // don't allow further nesting.
562604
}
563605

606+
void AdafruitCanvasDrawable2bpp::drawBitmapNbpp(const Coord& where, const uint8_t* data, const Coord& size, int bpp, const uint16_t* palette) {
607+
auto yTot = int16_t(where.y + size.y);
608+
auto xTot = int16_t(where.x + size.x);
609+
int bitsInByte = bpp == 2 ? 4 : 2;
610+
uint8_t downShift = bpp == 2 ? 6 : 4;
611+
612+
uint8_t byteIteration = bitsInByte;
613+
uint8_t current;
614+
for(int16_t y = where.y; y<yTot; y++) {
615+
for(int16_t x = where.x; x<xTot; x++) {
616+
if(byteIteration == bitsInByte) {
617+
current = pgm_read_byte(data);
618+
data += 1;
619+
byteIteration = 0;
620+
}
621+
uint8_t idx = current >> downShift;
622+
current = current << bitsInByte;
623+
byteIteration++;
624+
canvas->drawPixel(x, y, idx);
625+
}
626+
byteIteration = bitsInByte; // always need a new byte in this case
627+
}
628+
}

examples/arduino32/picoAdafruitDashboard/tcMenuAdaFruitGfx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class AdafruitDrawable : public DeviceDrawable {
176176
void internalDrawText(const Coord &where, const void *font, int mag, const char *text) override;
177177
void drawBitmap(const Coord &where, const DrawableIcon *icon, bool selected) override;
178178
void drawXBitmap(const Coord &where, const Coord &size, const uint8_t *data) override;
179+
virtual void drawBitmapNbpp(const Coord& where, const uint8_t* data, const Coord& size, int bpp, const color_t* palette);
179180
void drawBox(const Coord &where, const Coord &size, bool filled) override;
180181
void drawCircle(const Coord& where, int radius, bool filled) override;
181182
void drawPolygon(const Coord points[], int numPoints, bool filled) override;
@@ -212,6 +213,7 @@ class AdafruitCanvasDrawable2bpp : public AdafruitDrawable {
212213
void transaction(bool isStarting, bool redrawNeeded) override;
213214
color_t getUnderlyingColor(color_t col) override;
214215
DeviceDrawable *getSubDeviceFor(const Coord &where, const Coord &size, const color_t *palette, int paletteSize) override;
216+
void drawBitmapNbpp(const Coord& where, const uint8_t* data, const Coord& size, int bpp, const color_t* palette) override;
215217
};
216218

217219
#endif /* _TCMENU_TCMENUADAFRUITGFX_H_ */

examples/esp/esp32Amplifier/esp32Amplifier.ino

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,42 @@ void setup() {
8484
#else
8585
touchScreen.calibrateMinMaxValues(0.250F, 0.890F, 0.09F, 0.88F);
8686
#endif // TC_TFT_ESPI_NEEDS_TOUCH
87+
8788
/**
88-
* Here we use the theme builder to modify the drawing of certain menu items, we want three of the main menu
89-
* items to render using icons, we therefore request a "menuItemOverride" from the theme and then we simply
90-
* say the item will render as an image.
89+
* In the event that we want to modify how menu items are drawn, the easiest way is to use TcThemeBuilder.
90+
* Here we use it to modify the drawing of certain menu items, we want three of the main menu items to render
91+
* using icons, to do so we call `menuItemOverride` on the builder, and it returns a "properties builder" that is
92+
* pre-prepared to adjust the menu item.
93+
*
94+
* See https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/themes/rendering-with-themes-icons-grids/
9195
*/
9296
TcThemeBuilder themeBuilder(renderer);
9397
const Coord iconSize(APPICONS_WIDTH, APPICONS_HEIGHT);
98+
99+
// get the properties editor for the settings submenu item itself and override it to draw as an icon. Also make it
100+
// draw in a specific row and column grid, then finally call `apply` to make the adjustment. Note that in this case
101+
// use a 4BPP (16 color) icon bitmap by providing both the data and the palette.
94102
themeBuilder.menuItemOverride(menuSettings)
95103
.withImage4bpp(Coord(31, 40), statusBitmap_palette0, statusBitmap0)
96104
.onRow(3).multiCol(1, 3)
97105
.apply();
98-
//themeBuilder.menuItemOverride(menuSettings)
99-
// .withImageXbmp(iconSize, settingsIcon40Bits)
100-
// .onRow(3).multiCol(1, 3)
101-
// .apply();
106+
107+
// Again we take a menu item override for the status submenu item, and this time it will render a single color bitmap
102108
themeBuilder.menuItemOverride(menuStatus)
103109
.withImageXbmp(iconSize, statusIcon40Bits)
104110
.onRow(3).multiCol(2, 3)
105111
.apply();
112+
113+
// Again we take a menu item override for the mute boolean menu, and this time it will render a single color bitmap
106114
themeBuilder.menuItemOverride(menuMute)
107115
.withImageXbmp(iconSize, muteOffIcon40Bits, muteOnIcon40Bits)
108116
.onRow(3).multiCol(3, 3)
109117
.apply();
110118

111119
/**
112120
* here is how we override drawing for items only when a submenu is active, you can also define at the item level.
121+
* Note that unlike above, this affects all title items in that sub menu. We could do the same for all action or
122+
* even regular items within a submenu.
113123
*/
114124
color_t specialPalette[] { RGB(255, 255, 255), RGB(255, 0, 0), RGB(0, 0, 0), RGB(0, 0, 255) };
115125
themeBuilder.submenuPropertiesTitleOverride(menuStatus)
@@ -118,6 +128,7 @@ void setup() {
118128
.withBorder(MenuBorder(2))
119129
.apply();
120130

131+
// whenever adjusting themes, we should always apply them
121132
themeBuilder.apply();
122133

123134
setTitlePressedCallback([](int) {

examples/esp/esp32SimHub/appTheme.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,20 @@ const uint8_t engineBitmap0[] PROGMEM = {
115115
};
116116

117117
void setupTheme() {
118+
/**
119+
* In the event that we want to modify how menu items are drawn, the easiest way is to use TcThemeBuilder.
120+
* Here we use it to modify the drawing of certain menu items, we want three of the main menu items to render
121+
* using icons, to do so we call `menuItemOverride` on the builder, and it returns a "properties builder" that is
122+
* pre-prepared to adjust the menu item.
123+
*
124+
* See https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/themes/rendering-with-themes-icons-grids/
125+
*/
118126
color_t coolBlueTitlePalette[] = {RGB(0,0,0), RGB(20,132,255), RGB(192,192,192), RGB(64, 64, 64)};
119127
color_t coolBlueItemPalette[] = {RGB(255, 255, 255), RGB(0,64,135), RGB(20,133,255), RGB(31,100,178)};
120128
TcThemeBuilder themeBuilder(renderer);
121129

122130
themeBuilder.withSelectedColors(RGB(31, 88, 100), RGB(255, 255, 255))
131+
.dimensionsFromRenderer()
123132
.withRenderingSettings(tcgfx::BaseGraphicalRenderer::TITLE_FIRST_ROW, true)
124133
.enablingTcUnicode()
125134
.withItemPadding(MenuPadding(2))

0 commit comments

Comments
 (0)