Skip to content

Commit b72d58f

Browse files
author
dave
committed
#242 fixes for outside Arduino use, in particular for ESP32 IDF
1 parent 4acb77b commit b72d58f

File tree

8 files changed

+31
-11
lines changed

8 files changed

+31
-11
lines changed

examples/esp/esp32s2Saola/esp32s2Saola.emf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,7 @@
539539
"menuDefinitions": []
540540
},
541541
"packageNamespace": "",
542-
"appIsModular": false,
543-
"listOfEmbeddedForms": []
542+
"appIsModular": false
544543
},
545544
"stringLists": []
546545
}

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"authors": "tcmenu"
2727
}
2828
],
29-
"version": "4.4.0",
29+
"version": "4.4.1",
3030
"license": "Apache-2.0",
3131
"frameworks": "arduino, mbed",
3232
"platforms": "*"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
name=tcMenu
7-
version=4.4.0
7+
version=4.4.1
88
maintainer=www.thecoderscorner.com
99
author=davetcc
1010
category=Other

src/BaseRenderers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class MenuRenderer {
241241
/**
242242
* Gets the buffer size of the buffer
243243
*/
244-
uint8_t getBufferSize() {return bufferSize;}
244+
uint8_t getBufferSize() const {return bufferSize;}
245245

246246
/** Returns if this is a no display type renderer or a base renderer type. */
247247
RendererType getRendererType() { return rendererType; }

src/graphics/BaseGraphicalRenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ uint8_t BaseGraphicalRenderer::setActiveItem(MenuItem *item) {
4949
auto ret = BaseMenuRenderer::setActiveItem(item);
5050

5151
// if we're drawing a list, clear out the drawing location, lists handled differently
52-
if(menuMgr.getCurrentMenu()->getMenuType() == MENUTYPE_RUNTIME_LIST) {
52+
if(menuMgr.getCurrentMenu() && menuMgr.getCurrentMenu()->getMenuType() == MENUTYPE_RUNTIME_LIST) {
5353
drawingLocation = CachedDrawingLocation();
5454
return 0;
5555
}
@@ -85,7 +85,6 @@ uint8_t BaseGraphicalRenderer::setActiveItem(MenuItem *item) {
8585
serlogF2(SER_TCMENU_DEBUG, "Screen Row moved ", startRow);
8686
}
8787
drawingLocation = CachedDrawingLocation(startY, startRow);
88-
8988
return ret;
9089
}
9190

@@ -369,6 +368,7 @@ void BaseGraphicalRenderer::recalculateDisplayOrder(MenuItem *root, bool safeMod
369368
if(areRowsOutOfOrder() && !safeMode) {
370369
recalculateDisplayOrder(root, true);
371370
}
371+
serlogF(SER_TCMENU_INFO, "Calculated Display Order");
372372
}
373373

374374

src/graphics/DeviceDrawableHelper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ namespace tcgfx {
140140
*/
141141
explicit DeviceDrawableHelper(DeviceDrawable* root);
142142

143+
void setDrawable(DeviceDrawable* dr) {
144+
this-> drawable = dr;
145+
this->rootDrawable = dr;
146+
}
147+
143148

144149
void reConfigure(color_t *palette, uint8_t paletteSize, const Coord &startPosition, const Coord &size);
145150

src/graphics/GraphicsDeviceRenderer.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ namespace tcgfx {
2525

2626
GraphicsDeviceRenderer::GraphicsDeviceRenderer(int bufferSize, const char *appTitle, DeviceDrawable *drawable)
2727
: BaseGraphicalRenderer(bufferSize, 1, 1, false, appTitle), rootDrawable(drawable), helper(drawable) {
28-
const Coord &coord = rootDrawable->getDisplayDimensions();
29-
width = coord.x;
30-
height = coord.y;
28+
if (rootDrawable) {
29+
const Coord &coord = rootDrawable->getDisplayDimensions();
30+
width = coord.x;
31+
height = coord.y;
32+
}
3133
}
3234

3335
void GraphicsDeviceRenderer::drawingCommand(BaseGraphicalRenderer::RenderDrawingCommand command) {
@@ -513,5 +515,11 @@ namespace tcgfx {
513515
return (cardLayoutPane->isSubMenuCardLayout(rootItem)) ? LAYOUT_CARD_SIDEWAYS : LAYOUT_VERTICAL_DEFAULT;
514516
}
515517

516-
518+
void GraphicsDeviceRenderer::setDrawable(DeviceDrawable *drawable) {
519+
this->rootDrawable = drawable;
520+
this->helper.setDrawable(drawable);
521+
const Coord &coord = rootDrawable->getDisplayDimensions();
522+
width = coord.x;
523+
height = coord.y;
524+
}
517525
} // namespace tcgfx

src/graphics/GraphicsDeviceRenderer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ namespace tcgfx {
148148
void setCardLayoutStatusForSubMenu(MenuItem* root, bool onOrOff);
149149

150150
LayoutMode getLayoutMode(MenuItem* rootItem) override;
151+
152+
/**
153+
* this is for cases where the display driver and drawable are allocated during setup instead of at start up
154+
* time, and therefore need to be configured in creation order.
155+
* @param drawable the drawable instance to associate
156+
*/
157+
void setDrawable(DeviceDrawable* drawable);
158+
151159
protected:
152160
/**
153161
* Overrides the default implementation to allow for card based layouts, if this is not enabled for the submenu

0 commit comments

Comments
 (0)