Arduino GFX developing for various color displays and various data bus interfaces - RPiPicoPAR8 Custom Pin definitions
Arduino_GFX is a Arduino graphics library supporting various displays with various data bus interfaces.
This library start rewrite from Adafruit_GFX, LovyanGFX, TFT_eSPI, Ucglib, and more...
#include <Arduino_GFX_Library.h> Arduino_DataBus *bus = new Arduino_HWSPI(16 /* DC */, 5 /* CS */); Arduino_GFX *gfx = new Arduino_ILI9341(bus, 17 /* RST */);
gfx->begin(); gfx->fillScreen(RGB565_BLACK); gfx->setCursor(10, 10); gfx->setTextColor(RGB565_RED); gfx->println("Hello World!");
If you are new on this library, I always recommend try Library Example PDQgraphicstest first. You can find it at Arduino IDE -> File menu -> Examples -> GFX Library for Arduino -> PDQgraphicstest.
After open the example, you can see many tabs. The first is PDQgraphicstest, the main program. Start from the second tab, it is related header files, Arduino_GFX_databus.h, ... etc.
If you are using below listed support dev device, simply select the Arduino_GFX_dev_device.h and uncomment the define of your dev device. E.g. if you are using LilyGo T-Deck:
... // #define JC3248W535 #define LILYGO_T_DECK // #define LILYGO_T_DISPLAY ...
If you are not using supported dev device:
Default DataBus is using Arduino SPI. Other DataBus can modify in Arduino_GFX_databus.h.
Default Display is using ILI9341 LCD. Other Display can modify in Arduino_GFX_display.h.
U8g2 provided various font type and stored in compressed format. So U8g2 font gives more UI design possibilities and still can fit in the MCU limited storage space. Using U8g2 font in Arduino_GFX simply include U8g2lib.h before Arduino_GFX_Library.h:
#include <U8g2lib.h> #include <Arduino_GFX_Library.h>
And then setfont file to use:
gfx->setCursor(10, 20); gfx->setFont(u8g2_font_maniac_tr); gfx->println("Hello World!");
U8g2 font list can be found at: https://github.com/olikraus/u8g2/wiki/fntlistall
Another U8g2 font advantage is the font support Unicode glyphs. Simply enable setUTF8Print:
gfx->begin(); gfx->fillScreen(RGB565_BLACK); gfx->setUTF8Print(true);
And then print UTF8 string as usual:
gfx->setCursor(0, 16); gfx->setFont(u8g2_font_unifont_tr); gfx->println("Hello World!"); gfx->setFont(u8g2_font_unifont_t_polish); gfx->println("Witaj świecie!"); gfx->setFont(u8g2_font_unifont_t_vietnamese1); gfx->println("Chào thế giới!"); gfx->setFont(u8g2_font_unifont_t_chinese2); gfx->println("世界你好!"); gfx->setFont(u8g2_font_unifont_t_japanese1); gfx->println("こんにちは世界!"); gfx->setFont(u8g2_font_unifont_t_korean1); gfx->println("안녕하세요, 세계입니다!");
U8g2 Unifont list can be found at: https://github.com/olikraus/u8g2/wiki/fntgrpunifont
Besides U8g2 generated font, Arduino_GFX also generated some useful font set:
otf2bdf ChillBitmap7x.ttf -p 6 -o ChillBitmap7x.bdf bdfconv -v -f 1 -b 1 -m "0-4294967295" ChillBitmap7x.bdf -o u8g2_font_chill7_h_cjk.h -n u8g2_font_chill7_h_cjk
otf2bdf Cubic_11_1.013_R.ttf -p 9 -o Cubic_11_1.013_R.bdf bdfconv -v -f 1 -b 1 -m "0-4294967295" Cubic_11_1.013_R.bdf -o u8g2_font_cubic11_h_cjk.h -n u8g2_font_cubic11_h_cjk
./bdfconv -v -f 1 -b 1 -m "0-4294967295" quan.bdf -o u8g2_font_quan7_h_cjk.h -n u8g2_font_quan7_h_cjk
bdfconv -v -f 1 -b 1 -m "0-1114111" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_h_utf8.h -n u8g2_font_unifont_h_utf8
bdfconv -v -f 1 -m "32-127,11904-12351,19968-40959,63744-64255,65280-65376" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_chinese.h -n u8g2_font_unifont_t_chinese
bdfconv -v -f 1 -M chinese4.list unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_chinese4.h -n u8g2_font_unifont_t_chinese4
</details> <details> <summary>Performance</summary>bdfconv -v -f 1 -m "32-127,4352-4607,11904-12255,12288-19903,19968-40943,43360-43391,44032-55203,55216-55295,63744-64255,65072-65103,65280-65519" unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_cjk.h -n u8g2_font_unifont_t_cjk
This library is not putting speed at the first priority, but still paid much effort to make the display look smooth.
Below are some figures compare with other 3 Arduino common display libraries.
| Benchmark | Adafruit_GFX | Arduino_GFX | Lovyan_GFX | TFT_eSPI | | ------------------ | ------------- | ------------- | ------------- | ------------- | | Screen fill | 195,782 | 160,094 | 154,341 | 155,938 | | Text | 97,662 | 18,960 | 22,473 | 21,752 | | Pixels | 1,365,211 | 903,549 | 867,702 | 775,781 | | Lines | 1,062,311 | 412,026 | 269,060 | 264,950 | | Horiz/Vert Lines | 17,637 | 14,197 | 13,692 | 13,833 | | Rectangles-filled | 406,817 | 332,696 | 320,761 | 323,908 | | Rectangles | 11,641 | 9,254 | 8,545 | 8,714 | | Triangles-filled | 150,941 | 118,010 | 105,661 | 109,675 | | Triangles | 58,843 | 23,570 | 15,884 | 16,277 | | Circles-filled | 76,739 | 52,170 | 42,787 | 45,827 | | Circles | 118,125 | 40,955 | 25,959 | 25,269 | | Arcs-filled | N/A | 33,381 | 21,546 | N/A | | Arcs | N/A | 66,054 | 47,901 | N/A | | Rounded rects-fill | 408,534 | 338,136 | 318,882 | 323,189 | | Rounded rects | 43,185 | 21,562 | 13,089 | 15,371 |
Arduino_GFX utilizes Arduino Built-in SPI class to support 8-bit SPI for most platforms.
Most tiny displays in hobbyist electronics world support 8-bit SPI, but some require 9-bit SPI. Arduino_GFX should be the first Arduino display library that can use ESP32 SPI to support 9-bit hardware SPI. It is important to support the displays that require 9-bit SPI interface. (e.g. HX8357B, ...)
Larger displays most likely do not support standalone SPI since it is not fast enough to refresh the full screen details. Most of them support 8-bit/16-bit Parallel interface.
Some larger display require RGB + 3-bit SPI combo interface, This interface requies at most 3(9-bit SPI) + 4(CS, CD, WR, RD) + 24(RBG888) = 31 pins. Most dev board do not have enough GPIO to support this. Arduino_GFX is stick to RGB565 color, so RGB666 and RGB888 require some connection hack. E.g. RGB666 connect R5 and R6 together, B5 and B6 together to become RGB565. Then the least GPIO requirement can become 3(9-bit SPI) + 2(CD, WR) + 16(RBG565) = 21 pins. Remember always pull down CS pin and always pull up RD pin.
ESP32LCD8, ESP32LCD16 and ESP32RGBPanel only supported by arduino-esp32 v2.x and no longer support in v3.0.
</details> <details> <summary>Supported Dev Board</summary>ESP32-2432S028
ESP32-2424012 [demo video]
ESP32-3248S035
ESP32-4827A043 [demo video] [LVGL demo video]
ESP32-4827S043 [demo video 1] [demo video 2] [LVGL demo video]
ESP32S3-2.1-TP
LILYGO T-Display-S3 AMOLED 1.64 [demo video][LVGL demo video]
LILYGO T-Watch
Waveshare ESP32-S3 1.46inch Round Display Development Board [demo video]
Waveshare ESP32-S3-Touch-LCD-1.3 with case and prism cube [demo video]
Elecrow ESP Terminal with 3.5" parallel RGB display DLC35010R [demo video]
QM Smart Panlee 7.0 inch serial screen ZX7D00CE01S [demo video]
As you may already aware there are lack of sponsorship in this project. Convert the funding in terms of man power, it is much lower than 1 man hour per month. So don't expect too much on the support. Expecially the features not realted to my planned maker projects ;>
For the same reason, Arduino_GFX only focus on the Arduino IDE support. Any other IDE, e.g. PlatformIO, if you found an issue at that IDE but normal at Arduino IDE, please direct report to that IDE for better support.
Please use Discussions space for new hardware support or new feature request. I will direct close any non-issue issues. And I will consider report the users who insist raising duplicate issue continuously.
If you like Arduino_GFX, you can: