Skip to content

Commit 8b1ff46

Browse files
committed
More examples tested and built with web IDE
1 parent d8fe0a4 commit 8b1ff46

4 files changed

Lines changed: 76 additions & 79 deletions

File tree

examples/staticMenu/dynamicMenuItems/generated/dynamicMenuItems_menu.cpp

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

11-
// Generated for Arduino 32bit ARM by TcMenu 4.5.0 on 2025-11-01T12:26:00.356314700Z.
11+
// Generated for Arduino 32bit ARM by TcMenu 4.5.9-SNAPSHOT on 2026-07-12T13:10:38.363967Z.
1212

1313
#include <tcMenu.h>
1414
#include "dynamicMenuItems_menu.h"
@@ -19,7 +19,7 @@
1919
// Global variable declarations
2020
const ConnectorLocalInfo applicationInfo = { "Dynamic Menus", "5f22995e-8da2-49c4-9ec8-d055901003af" };
2121
IoAbstractionRef ioexp_io23017 = ioFrom23017(0x20, ACTIVE_LOW_OPEN, 10);
22-
Adafruit_ST7735 gfx(1, 0, -1);
22+
Adafruit_ST7735 gfx(&SPI, 1, 0, -1);
2323
AdafruitDrawable gfxDrawable(&gfx, 40);
2424
GraphicsDeviceRenderer renderer(30, applicationInfo.name, &gfxDrawable);
2525
MatrixKeyboardManager keyboard;
@@ -81,23 +81,23 @@ BooleanMenuItem menuMainPower(&minfoMainPower, false, &menuOven, INFO_LOCATION_P
8181

8282
void setupMenu() {
8383
// First we set up eeprom and authentication (if needed).
84-
setSizeBasedEEPROMStorageEnabled(false);
84+
setEepromStorageMode(TC_STORE_ROM_LEGACY);
8585
// Code generated by plugins and new operators.
86-
gfx.initR(INITR_BLACKTAB);
87-
gfx.setRotation(1);
88-
renderer.setUpdatesPerSecond(5);
89-
switches.init(internalDigitalIo(), SWITCHES_POLL_KEYS_ONLY, true);
90-
menuMgr.initForEncoder(&renderer, &menuMainPower, 6, 5, 9, FULL_CYCLE);
91-
keyboardLayout.setRowPin(0, 11);
92-
keyboardLayout.setRowPin(1, 10);
93-
keyboardLayout.setRowPin(2, 9);
94-
keyboardLayout.setRowPin(3, 8);
95-
keyboardLayout.setColPin(0, 15);
96-
keyboardLayout.setColPin(1, 14);
97-
keyboardLayout.setColPin(2, 13);
98-
keyboardLayout.setColPin(3, 12);
99-
keyboard.initialise(ioexp_io23017, &keyboardLayout, &tcMenuKeyListener, true);
100-
keyboard.setRepeatKeyMillis(850, 350);
101-
installCoolBlueTraditionalTheme(renderer, MenuFontDef(&OpenSansRegular8pt, 0), MenuFontDef(&OpenSansCyrillicLatin12, 0), true, BaseGraphicalRenderer::TITLE_FIRST_ROW, true);
86+
gfx.initR(INITR_BLACKTAB);
87+
gfx.setRotation(1);
88+
renderer.setUpdatesPerSecond(5);
89+
switches.init(internalDigitalIo(), SWITCHES_POLL_KEYS_ONLY, true);
90+
menuMgr.initForEncoder(&renderer, &menuMainPower, 6, 5, 9, FULL_CYCLE);
91+
keyboardLayout.setRowPin(0, 11);
92+
keyboardLayout.setRowPin(1, 10);
93+
keyboardLayout.setRowPin(2, 9);
94+
keyboardLayout.setRowPin(3, 8);
95+
keyboardLayout.setColPin(0, 15);
96+
keyboardLayout.setColPin(1, 14);
97+
keyboardLayout.setColPin(2, 13);
98+
keyboardLayout.setColPin(3, 12);
99+
keyboard.initialise(ioexp_io23017, &keyboardLayout, &tcMenuKeyListener, true);
100+
keyboard.setRepeatKeyMillis(850, 350);
101+
installCoolBlueTraditionalTheme(renderer, MenuFontDef(&OpenSansRegular8pt, 0), MenuFontDef(&OpenSansCyrillicLatin12, 0), true, BaseGraphicalRenderer::TITLE_FIRST_ROW, true);
102102
}
103103

examples/staticMenu/dynamicMenuItems/generated/dynamicMenuItems_menu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
// variables we declare that you may need to access
2626
extern const PROGMEM ConnectorLocalInfo applicationInfo;
2727
extern Adafruit_ST7735 gfx;
28-
extern AdafruitDrawable gfxDrawable;
2928
extern GraphicsDeviceRenderer renderer;
3029
extern MatrixKeyboardManager keyboard;
3130
extern MenuEditingKeyListener tcMenuKeyListener;

examples/staticMenu/dynamicMenuItems/generated/tcMenuAdaFruitGfx.cpp

Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919

2020
using namespace tcgfx;
2121

22-
23-
#if DISPLAY_HAS_MEMBUFFER == true
24-
#define refreshDisplayIfNeeded(gr, needUpd) {if(needUpd) reinterpret_cast<Adafruit_ST7735*>(gr)->display();}
25-
#else
26-
#define refreshDisplayIfNeeded(g, n)
27-
#endif
28-
2922
#ifndef COOKIE_CUT_MEMBUFFER_SIZE
3023
#ifdef __AVR__
3124
#define COOKIE_CUT_MEMBUFFER_SIZE 16
@@ -37,9 +30,10 @@ using namespace tcgfx;
3730
uint16_t memBuffer[COOKIE_CUT_MEMBUFFER_SIZE];
3831

3932
void AdafruitDrawable::transaction(bool isStarting, bool redrawNeeded) {
40-
if(!isStarting) refreshDisplayIfNeeded(graphics, redrawNeeded);
33+
4134
}
4235

36+
4337
void AdafruitDrawable::internalDrawText(const Coord &where, const void *font, int mag, const char *sz) {
4438
graphics->setTextWrap(false);
4539
int baseline=0;
@@ -50,6 +44,59 @@ void AdafruitDrawable::internalDrawText(const Coord &where, const void *font, in
5044
graphics->print(sz);
5145
}
5246

47+
Coord AdafruitDrawable::internalTextExtents(const void *f, int mag, const char *text, int *baseline) {
48+
if(mag == 0) mag = 1; // never allow 0 magnification
49+
50+
graphics->setFont(static_cast<const GFXfont *>(f));
51+
graphics->setTextSize(mag);
52+
auto* font = (GFXfont *) f;
53+
int16_t x1, y1;
54+
uint16_t w, h;
55+
graphics->getTextBounds((char*)text, 3, font?30:2, &x1, &y1, &w, &h);
56+
57+
if(font == nullptr) {
58+
// for the default font, the starting offset is 0, and we calculate the height.
59+
if(baseline) *baseline = 0;
60+
return Coord(w, h);
61+
}
62+
else {
63+
computeBaselineIfNeeded(font);
64+
if(baseline) *baseline = (computedBaseline * mag);
65+
return Coord(int(w), (computedHeight * mag));
66+
}
67+
}
68+
69+
void AdafruitDrawable::computeBaselineIfNeeded(const GFXfont* font) {
70+
// we cache the last baseline, if the font is unchanged, don't calculate again
71+
if(computedFont == font && computedBaseline > 0) return;
72+
73+
// we need to work out the biggest glyph and maximum extent beyond the baseline, we use 4 chars 'Agj(' for this
74+
const char sz[] = "Agj(";
75+
int height = 0;
76+
int bl = 0;
77+
const char* current = sz;
78+
auto fontLast = pgm_read_word(&font->last);
79+
auto fontFirst = pgm_read_word(&font->first);
80+
while(*current && (*current < fontLast)) {
81+
size_t glIdx = *current - fontFirst;
82+
auto allGlyphs = (GFXglyph*)pgm_read_ptr(&font->glyph);
83+
int glyphHeight = int(pgm_read_byte(&allGlyphs[glIdx].height));
84+
if (glyphHeight > height) height = glyphHeight;
85+
auto yOffset = int8_t(pgm_read_byte(&allGlyphs[glIdx].yOffset));
86+
bl += glyphHeight + yOffset;
87+
current++;
88+
}
89+
computedFont = font;
90+
computedBaseline = bl / 4;
91+
computedHeight = height;
92+
}
93+
94+
UnicodeFontHandler *AdafruitDrawable::createFontHandler() {
95+
return new UnicodeFontHandler(newAdafruitTextPipeline(graphics), ENCMODE_UTF8);
96+
}
97+
98+
99+
53100
void AdafruitDrawable::drawBitmap(const Coord &where, const DrawableIcon *icon, bool selected) {
54101
if(icon->getIconType() == DrawableIcon::ICON_XBITMAP) {
55102
graphics->fillRect(where.x, where.y, icon->getDimensions().x, icon->getDimensions().y, backgroundColor);
@@ -142,61 +189,10 @@ void AdafruitDrawable::drawPolygon(const Coord points[], int numPoints, bool fil
142189
}
143190
}
144191

145-
void AdafruitDrawable::computeBaselineIfNeeded(const GFXfont* font) {
146-
// we cache the last baseline, if the font is unchanged, don't calculate again
147-
if(computedFont == font && computedBaseline > 0) return;
148-
149-
// we need to work out the biggest glyph and maximum extent beyond the baseline, we use 4 chars 'Agj(' for this
150-
const char sz[] = "Agj(";
151-
int height = 0;
152-
int bl = 0;
153-
const char* current = sz;
154-
auto fontLast = pgm_read_word(&font->last);
155-
auto fontFirst = pgm_read_word(&font->first);
156-
while(*current && (*current < fontLast)) {
157-
size_t glIdx = *current - fontFirst;
158-
auto allGlyphs = (GFXglyph*)pgm_read_ptr(&font->glyph);
159-
int glyphHeight = int(pgm_read_byte(&allGlyphs[glIdx].height));
160-
if (glyphHeight > height) height = glyphHeight;
161-
auto yOffset = int8_t(pgm_read_byte(&allGlyphs[glIdx].yOffset));
162-
bl += glyphHeight + yOffset;
163-
current++;
164-
}
165-
computedFont = font;
166-
computedBaseline = bl / 4;
167-
computedHeight = height;
168-
}
169-
170-
Coord AdafruitDrawable::internalTextExtents(const void *f, int mag, const char *text, int *baseline) {
171-
if(mag == 0) mag = 1; // never allow 0 magnification
172-
173-
graphics->setFont(static_cast<const GFXfont *>(f));
174-
graphics->setTextSize(mag);
175-
auto* font = (GFXfont *) f;
176-
int16_t x1, y1;
177-
uint16_t w, h;
178-
graphics->getTextBounds((char*)text, 3, font?30:2, &x1, &y1, &w, &h);
179-
180-
if(font == nullptr) {
181-
// for the default font, the starting offset is 0, and we calculate the height.
182-
if(baseline) *baseline = 0;
183-
return Coord(w, h);
184-
}
185-
else {
186-
computeBaselineIfNeeded(font);
187-
if(baseline) *baseline = (computedBaseline * mag);
188-
return Coord(int(w), (computedHeight * mag));
189-
}
190-
}
191-
192192
void AdafruitDrawable::drawPixel(uint16_t x, uint16_t y) {
193193
graphics->writePixel(x, y, drawColor);
194194
}
195195

196-
UnicodeFontHandler *AdafruitDrawable::createFontHandler() {
197-
return new UnicodeFontHandler(newAdafruitTextPipeline(graphics), ENCMODE_UTF8);
198-
}
199-
200196
//
201197
// helper functions
202198
//

examples/staticMenu/dynamicMenuItems/generated/tcMenuAdaFruitGfx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#define DISPLAY_HAS_MEMBUFFER false
3535

36+
3637
using namespace tcgfx;
3738

3839
// some colour displays don't create this value
@@ -159,6 +160,7 @@ class AdafruitDrawable : public DeviceDrawable {
159160
const GFXfont* computedFont = nullptr;
160161
int16_t computedBaseline = 0;
161162
int16_t computedHeight = 0;
163+
162164
protected:
163165
int spriteHeight = 0;
164166
public:

0 commit comments

Comments
 (0)