Skip to content

Commit 51643b3

Browse files
committed
examples prepared for release
1 parent 83a1195 commit 51643b3

File tree

8 files changed

+1599
-1405
lines changed

8 files changed

+1599
-1405
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
TcUnicode provides Unicode character support to a wide range of display libraries (Adafruit_GFX, U8G2, TFT_eSPI, and also TcMenu). There is no need to use special versions of the libraries to use TcUnicode, and there is even a UI for creating the fonts.
66

7-
Dave Cherry / TheCodersCorner.com make this framework available for you to use. It takes me significant effort to keep all my libraries current and working on a wide range of boards. Please consider making at least a one off donation via the sponsor button if you find it useful.
7+
Dave Cherry / TheCodersCorner.com made this framework available for you to use. It takes me significant effort to keep all my libraries current and working on a wide range of boards. Please consider making at least a one off donation via the sponsor button if you find it useful.
88

99
In any fork, please ensure all text up to here is left unaltered.
1010

@@ -35,3 +35,10 @@ There is a custom dialog within "TcMenu Designer UI" where you can select the Un
3535

3636
Please raise all questions in the main TcMenu repository discussions.
3737

38+
## Questions and documentation
39+
40+
You can ask questions either in the [discussions section of the tcMenu repo](https://github.com/davetcc/tcMenu/discussions), or using the Arduino forum. We generally answer most questions, but the rules of engagement are: **this is my hobby, I make it available because it helps others**. Don't expect immediate answers, make sure you've recreated the problem in a simple sketch that you can send to me. Please consider making at least a one time donation using the sponsor link if we do help you out.
41+
42+
* [discussions section of the tcMenu repo](https://github.com/davetcc/tcMenu/discussions) of tcmenu git repo
43+
* [Arduino discussion forum](https://forum.arduino.cc/) where questions can be asked, please tag me using `@davetcc`.
44+
* [Legacy discussion forum probably to be made read only soon](https://www.thecoderscorner.com/jforum/).

examples/adaUnicodeShim/adaUnicodeShim.ino

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <SPI.h>
55
#include <Wire.h>
66
#include <Fonts/FreeSans12pt7b.h>
7+
#include <Fonts/RobotoMedium24.h>
78
#include "Fonts/OpenSansCyrillicLatin18.h"
89

910
#define TFT_CS 22 // Chip select control pin
@@ -22,11 +23,16 @@ Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
2223
//
2324
UnicodeFontHandler fontHandler(&tft, ENCMODE_UTF8);
2425

25-
int yTextSize = 0;
26+
int yAdaFontSize = 0;
2627
int yOpenSansSize = 0;
28+
int baselineAda = 0;
29+
int baselineTcUni = 0;
2730
const char helloText[] PROGMEM = "hello world";
2831
const char helloUkraine[] PROGMEM = "Привіт Світ";
2932

33+
const GFXfont* adaFontToUse = &FreeSans12pt7b;
34+
const UnicodeFont* unicodeFontTouse = OpenSansCyrillicLatin18;
35+
3036
void setup() {
3137
// on ESP32 you may need to adjust the SPI settings, un/comment below
3238
SPI.begin(18, 19, 23);
@@ -48,57 +54,60 @@ void setup() {
4854
// Get the size of the Unicode open sans font that we are using, it is returned as a Coord object that has x and y.
4955
// the baseline, indicates the amount of space below the drawing point that's needed.
5056
//
51-
int baseLine = 0;
52-
fontHandler.setFont(OpenSansCyrillicLatin18);
53-
Coord openSansSize = fontHandler.textExtents_P(helloText, &baseLine);
54-
yOpenSansSize = (int)openSansSize.y - baseLine;
57+
fontHandler.setFont(unicodeFontTouse);
58+
Coord openSansSize = fontHandler.textExtents_P(helloText, &baselineTcUni);
59+
yOpenSansSize = (int)openSansSize.y - baselineTcUni;
5560

5661
//
5762
// Now get the size of the Adafruit_GFX font that we are using, same as above basically.
5863
//
59-
fontHandler.setFont(&FreeSans12pt7b);
60-
Coord textSize = fontHandler.textExtents_P(helloText, &baseLine);
61-
yTextSize = (int)textSize.y - baseLine;
64+
fontHandler.setFont(adaFontToUse);
65+
Coord textSize = fontHandler.textExtents_P(helloText, &baselineAda);
66+
yAdaFontSize = (int)textSize.y - baselineAda;
6267

6368
//
6469
// Now we print some text on the first available line, just as with adafruit, the font is drawn with reference to
6570
// the baseline, so we need to add the Y size of the font without the baseline. This is using a regular adafruit
6671
// graphics font.
6772
//
68-
fontHandler.setCursor(0, yTextSize);
69-
fontHandler.setFont(&FreeSans12pt7b);
73+
fontHandler.setCursor(0, yAdaFontSize);
74+
fontHandler.setFont(adaFontToUse);
7075
fontHandler.setDrawColor(ILI9341_WHITE);
7176
fontHandler.print_P(helloText);
7277

7378
//
7479
// Now we print some text just below that that is in unicode, this text is in cyrillic.
7580
//
7681
fontHandler.setCursor(0, 30 + yOpenSansSize);
77-
fontHandler.setFont(OpenSansCyrillicLatin18);
82+
fontHandler.setFont(unicodeFontTouse);
7883
fontHandler.print_P(helloUkraine);
7984

8085
//
8186
// Now we print the X and Y sizes of the adafruit font
8287
//
83-
fontHandler.setCursor(0, yTextSize + 60);
84-
fontHandler.setFont(&FreeSans12pt7b);
88+
fontHandler.setCursor(0, yAdaFontSize + 60);
89+
fontHandler.setFont(adaFontToUse);
8590
fontHandler.print((int)textSize.x);
86-
fontHandler.setCursor(80, yTextSize + 60);
91+
fontHandler.setCursor(80, yAdaFontSize + 60);
8792
fontHandler.print((int)textSize.y);
8893
}
8994

9095
void loop() {
9196
int whereY = 100;
9297
delay(250);
9398
tft.fillRect(0, whereY, tft.width(), 30, ILI9341_BLACK);
99+
tft.fillRect(0, whereY + yAdaFontSize, 70, baselineAda, ILI9341_RED);
94100

95-
tft.setCursor(0, yTextSize + whereY);
96-
fontHandler.setFont(&FreeSans12pt7b);
101+
fontHandler.setCursor(0, yAdaFontSize + whereY);
102+
fontHandler.setFont(adaFontToUse);
97103
fontHandler.setDrawColor(ILI9341_CYAN);
98-
fontHandler.print(millis());
104+
fontHandler.print(millis() / 1000);
105+
fontHandler.print("Agy");
99106

100-
tft.setCursor(80, yOpenSansSize + whereY);
101-
fontHandler.setFont(OpenSansCyrillicLatin18);
107+
tft.fillRect(80, whereY + yOpenSansSize, 200, baselineTcUni, ILI9341_RED);
108+
fontHandler.setCursor(80, yOpenSansSize + whereY);
109+
fontHandler.setFont(unicodeFontTouse);
102110
fontHandler.setDrawColor(ILI9341_GREEN);
103111
fontHandler.print((float)millis() / 1000.0F);
112+
fontHandler.print("Agy");
104113
}

0 commit comments

Comments
 (0)