Skip to content

Commit f4068a7

Browse files
author
dave
committed
Prepare for 3.0 docs and small fix
1 parent 427228a commit f4068a7

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed

examples/esp/esp32s3TftEncoder/esp32s3TftEncoder.emf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
},
178178
{
179179
"name": "DOUBLE_BUFFER_ROWS",
180-
"latestValue": "2",
180+
"latestValue": "20",
181181
"subsystem": "DISPLAY"
182182
},
183183
{
@@ -232,12 +232,12 @@
232232
},
233233
{
234234
"name": "ITEM_FONT",
235-
"latestValue": "num:,2",
235+
"latestValue": "ada:OpenSansCyrillicLatin12,0",
236236
"subsystem": "THEME"
237237
},
238238
{
239239
"name": "TITLE_FONT",
240-
"latestValue": "num:,2",
240+
"latestValue": "ada:OpenSansCyrillicLatin12,0",
241241
"subsystem": "THEME"
242242
},
243243
{
@@ -250,6 +250,11 @@
250250
"latestValue": "TITLE_FIRST_ROW",
251251
"subsystem": "THEME"
252252
},
253+
{
254+
"name": "USE_TC_UNICODE",
255+
"latestValue": "true",
256+
"subsystem": "THEME"
257+
},
253258
{
254259
"name": "USE_SLIDER_ANALOG",
255260
"latestValue": "true",

examples/esp/esp32s3TftEncoder/esp32s3TftEncoder.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// PLEASE CHOOSE ANOTHER EXAMPLE
2+
// This is more of a test harness for developer testing than an example
13
// Getting started: https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/tcmenu-overview-quick-start/
24

35
#include "esp32s3TftEncoder_menu.h"

examples/esp/esp32s3TftEncoder/esp32s3TftEncoder.ino.backup

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/esp/esp32s3TftEncoder/esp32s3TftEncoder_menu.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
#include <tcMenu.h>
1212
#include "esp32s3TftEncoder_menu.h"
1313
#include "ThemeCoolBlueTraditional.h"
14+
#include <Fonts/OpenSansCyrillicLatin12.h>
1415

1516
// Global variable declarations
1617
const ConnectorLocalInfo applicationInfo = { "ESP32 S3 Tiny", "c035e186-32cc-45e4-ac28-773f57e108ee" };
1718

1819
TFT_eSPI gfx;
19-
TfteSpiDrawable gfxDrawable(&gfx, 2);
20+
TfteSpiDrawable gfxDrawable(&gfx, 20);
2021
GraphicsDeviceRenderer renderer(30, applicationInfo.name, &gfxDrawable);
2122

2223
// Global Menu Item declarations
@@ -56,6 +57,7 @@ void setupMenu() {
5657
menuMgr.initForEncoder(&renderer, &menuPercent, 3, 4, 5);
5758
renderer.setTitleMode(BaseGraphicalRenderer::TITLE_FIRST_ROW);
5859
renderer.setUseSliderForAnalog(true);
59-
installCoolBlueTraditionalTheme(renderer, MenuFontDef(nullptr, 2), MenuFontDef(nullptr, 2), true);
60+
renderer.enableTcUnicode();
61+
installCoolBlueTraditionalTheme(renderer, MenuFontDef(&OpenSansCyrillicLatin12, 0), MenuFontDef(&OpenSansCyrillicLatin12, 0), true);
6062
}
6163

examples/esp/esp32s3TftEncoder/esp32s3TftEncoder_menu.h

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

1414
#include <Arduino.h>
1515
#include <tcMenu.h>
16+
#include <tcUnicodeHelper.h>
1617
#include "tcMenuTfteSpi.h"
1718
#include <graphics/MenuTouchScreenEncoder.h>
1819
#include <RuntimeMenuItem.h>
@@ -25,6 +26,7 @@ extern const PROGMEM ConnectorLocalInfo applicationInfo;
2526
extern TFT_eSPI gfx;
2627
extern TfteSpiDrawable gfxDrawable;
2728
extern GraphicsDeviceRenderer renderer;
29+
extern const UnicodeFont OpenSansCyrillicLatin12[];
2830

2931
// Any externals needed by IO expanders, EEPROMs etc
3032

examples/esp/esp32s3TftEncoder/tcMenuTfteSpi.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
* This library requires the AdaGfx library along with a suitable driver.
1313
*/
1414

15-
1615
#include "tcMenuTfteSpi.h"
16+
#include "tcUnicodeHelper.h"
1717
#include <TFT_eSPI.h>
1818

1919
TfteSpiDrawable::TfteSpiDrawable(TFT_eSPI *tft, int spriteHeight) : tft(tft), spriteWithConfig(nullptr), spriteHeight(spriteHeight) {}
@@ -30,7 +30,7 @@ DeviceDrawable *TfteSpiDrawable::getSubDeviceFor(const Coord &where, const Coord
3030
else return nullptr;
3131
}
3232

33-
void TfteSpiDrawable::drawText(const Coord &where, const void *font, int mag, const char *text) {
33+
void TfteSpiDrawable::internalDrawText(const Coord &where, const void *font, int mag, const char *text) {
3434
fontPtrToNum(font, mag);
3535
tft->setTextColor(drawColor, drawColor); // transparent background
3636
tft->drawString(text, where.x, where.y);
@@ -88,12 +88,16 @@ void TfteSpiDrawable::transaction(bool isStarting, bool redrawNeeded) {
8888
if(isStarting) tft->setTextDatum(TL_DATUM);
8989
}
9090

91-
Coord TfteSpiDrawable::textExtents(const void *font, int mag, const char *text, int *baseline) {
91+
Coord TfteSpiDrawable::internalTextExtents(const void *font, int mag, const char *text, int *baseline) {
9292
if(baseline) *baseline = 0;
9393
fontPtrToNum(font, mag);
9494
return Coord(tft->textWidth(text), tft->fontHeight());
9595
}
9696

97+
void TfteSpiDrawable::drawPixel(uint16_t x, uint16_t y) {
98+
tft->drawPixel(x, y, drawColor);
99+
}
100+
97101
void TfteSpiDrawable::fontPtrToNum(const void* font, int mag) {
98102
if(font == nullptr) {
99103
tft->setTextFont((uint8_t) mag);
@@ -103,6 +107,10 @@ void TfteSpiDrawable::fontPtrToNum(const void* font, int mag) {
103107
}
104108
}
105109

110+
UnicodeFontHandler *TfteSpiDrawable::createFontHandler() {
111+
return fontHandler = new UnicodeFontHandler(tft, tccore::ENCMODE_UTF8);
112+
}
113+
106114
//
107115
// Sprite object
108116
//
@@ -115,7 +123,9 @@ bool TftSpriteAndConfig::initSprite(const Coord &spriteWhere, const Coord &sprit
115123
// if the area is too big, or the sprite is in use, don't proceed.
116124
if(spriteSize.x > size.x || spriteSize.y > size.y) return false;
117125

118-
this->fontHandler = root->getUnicodeHandler(false);
126+
if(root->isTcUnicodeEnabled() && fontHandler == nullptr) {
127+
fontHandler = new UnicodeFontHandler(&sprite, tccore::ENCMODE_UTF8);
128+
}
119129

120130
// create the sprite if needed
121131
if(!sprite.created()) {

examples/esp/esp32s3TftEncoder/tcMenuTfteSpi.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TfteSpiDrawable : public DeviceDrawable {
3434

3535
DeviceDrawable *getSubDeviceFor(const Coord &where, const Coord& size, const color_t *palette, int paletteSize) override;
3636

37-
void drawText(const Coord &where, const void *font, int mag, const char *text) override;
37+
void internalDrawText(const Coord &where, const void *font, int mag, const char *text) override;
3838

3939
void drawBitmap(const Coord &where, const DrawableIcon *icon, bool selected) override;
4040

@@ -46,11 +46,15 @@ class TfteSpiDrawable : public DeviceDrawable {
4646

4747
void drawPolygon(const Coord *points, int numPoints, bool filled) override;
4848

49+
void drawPixel(uint16_t x, uint16_t y) override;
50+
4951
void transaction(bool isStarting, bool redrawNeeded) override;
5052

51-
Coord textExtents(const void *font, int mag, const char *text, int *baseline) override;
53+
Coord internalTextExtents(const void *font, int mag, const char *text, int *baseline) override;
5254
Coord getDisplayDimensions() override { return Coord(tft->width(), tft->height());}
5355
TFT_eSPI* getTFT() { return tft; }
56+
protected:
57+
UnicodeFontHandler* createFontHandler() override;
5458
private:
5559
void fontPtrToNum(const void* font, int mag);
5660
};

0 commit comments

Comments
 (0)