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(BLACK);
gfx->setCursor(10, 10);
gfx->setTextColor(RED);
gfx->println("Hello World!");
U8g2 proivided 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(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 from latest unifont_jp-14.0.02:
u8g2/tools/font/bdfconv/./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
u8g2/tools/font/bdfconv/bdfconv -v -f 1 -b 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 -b 1 -M common.txt unifont_jp-14.0.02.bdf -o u8g2_font_unifont_t_chinese4.c -n u8g2_font_unifont_t_chinese4
u8g2/tools/font/bdfconv/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,110592-110959,127488-127743,131072-173791" 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 3-bit SPI + RGB combo interface, i.e. require more than 3 + 24 pins. Most dev board do not have enough GPIO to support this. Arduino_GFX will eventually support this combo interface but will be in very low priority. A huge monthly sponsor may make it happen
3 LVGL demo provide in examples folder:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。