How to Display Unicode Fonts on TFT Display using TFT_eSPI Arduino Library?

The TFT_eSPI library is an open-source library for Arduino that allows you to display images, draw shapes, and write text on a TFT display using a simple and intuitive API. It is designed to be used with the ESP8266 and ESP32 microcontrollers, but it should work with any Arduino board with an SPI interface. The library supports many TFT displays, including those with an ILI9341, ILI9488, ST7735, S6D02A1, and ILI9481 controller.

You must follow these steps to display Unicode fonts on an ESP32 TFT display using the Arduino IDE.


Step 1: Install the Arduino TFT library:

Go to Sketch > Include Library > Manage Libraries in the Arduino IDE. Search for "TFT" and install the Arduino TFT_eSPI library by Bodmer.


Step 2: Install the Arduino Unicode library:


Go to Sketch> Include Library > Manage Libraries in the Arduino IDE. Search for "Unicode" and install the Arduino Unicode library.


Step 3: Connect your TFT display to the ESP32 using the appropriate pins

              TFT Display        ESP32

              GND ------------- GND

              VCC ------------- 3.3V

              CLK ------------- SCK (GPIO18)

              MOSI ------------ MOSI (GPIO23)

              MISO ------------ MISO (GPIO19)

              CS   ------------ CS (GPIO5)

              RES  ------------ RST (GPIO16)

              DC   ------------ DC (GPIO17)

Step 4: Include the necessary libraries in your Sketch:


#include <TFT.h>
#include <Unicode.h>code-box

Step 5: Initialize the TFT display and Unicode library in your setup() function:


TFT TFTscreen = TFT(CS_PIN, DC_PIN, RST_PIN);
Unicode_UTF8_enable(true);
TFTscreen.begin();

Step 6: To display a Unicode character on the TFT display, you can use the print () function of the TFT library and pass in the Unicode value of nature as an argument. For example, to display the Unicode character "Ω" (ohm symbol), you can use the following code:


TFTscreen.print((char)937);code-box


Step 7: You can also use the Unicode library to display Unicode strings. For example, to display the string "Hello, World!" in Japanese, you can use the following code:


TFTscreen.print(UTF8_to_Unicode("こんにちは、世界!"));code-box

The complete example Arduino code to display Unicode Fonts on Esp32 TFT Display

This is an example code. You should change the pin configuration. The Sketch that demonstrates how to display the string "Hello, World!" in Japanese on a TFT display using the Arduino IDE:

#include <TFT.h> // include the TFT library
#include <Unicode.h> // include the Unicode library
#define CS_PIN 5 // define the pin for the chip select
#define DC_PIN 17 // define the pin for the data/command signal
#define RST_PIN 16 // define the pin for the reset signal
TFT TFTscreen = TFT(CS_PIN, DC_PIN, RST_PIN); // create a TFT object
void setup() {
  Unicode_UTF8_enable(true); // enable UTF8 support in the Unicode library
  TFTscreen.begin(); // initialize the TFT display
  TFTscreen.print(UTF8_to_Unicode("こんにちは、世界!")); // print the string "Hello, World!" in Japanese.
}
void loop() {
  // nothing to do in the loop
}code-box

This Sketch first includes the TFT and Unicode libraries, then defines the pins for the chip select, data/command, and reset signals. It then creates a TFT object and initializes the TFT display in the setup() function. In the loop() function, it uses the print() part of the TFT library to display the string "Hello, World!" in Japanese.

1/Post a Comment/Comments

  1. thanks for the information,now i know about to display unicode fonts on TFT

    ReplyDelete

Post a Comment