This commit is contained in:
2026-02-12 01:27:25 -08:00
parent b5c81d79f0
commit e9678dd1ea
322 changed files with 297928 additions and 93 deletions

View File

@@ -0,0 +1,88 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C2/3 various dev board: CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-C5 various dev board : CS: 23, DC: 24, RST: 25, BL: 26, SCK: 10, MOSI: 8, MISO: nil
* ESP32-C6 various dev board : CS: 18, DC: 22, RST: 23, BL: 15, SCK: 21, MOSI: 19, MISO: nil
* ESP32-H2 various dev board : CS: 0, DC: 12, RST: 8, BL: 22, SCK: 10, MOSI: 25, MISO: nil
* ESP32-P4 various dev board : CS: 26, DC: 27, RST: 25, BL: 24, SCK: 36, MOSI: 32, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
/* more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git */
void setup(void)
{
#ifdef DEV_DEVICE_INIT
DEV_DEVICE_INIT();
#endif
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX U8g2 Font Hello World example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(RGB565_BLACK);
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->setCursor(10, 40);
/* U8g2 font list: https://github.com/olikraus/u8g2/wiki/fntlistall */
gfx->setFont(u8g2_font_maniac_tr);
gfx->setTextColor(RGB565_RED);
gfx->println("Hello World!");
delay(5000); // 5 seconds
}
void loop()
{
gfx->setCursor(random(gfx->width()), random(gfx->height()));
gfx->setTextColor(random(0xffff));
gfx->println("Hello World!");
delay(1000); // 1 second
}

View File

@@ -0,0 +1,124 @@
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C2/3 various dev board: CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-C5 various dev board : CS: 23, DC: 24, RST: 25, BL: 26, SCK: 10, MOSI: 8, MISO: nil
* ESP32-C6 various dev board : CS: 18, DC: 22, RST: 23, BL: 15, SCK: 21, MOSI: 19, MISO: nil
* ESP32-H2 various dev board : CS: 0, DC: 12, RST: 8, BL: 22, SCK: 10, MOSI: 25, MISO: nil
* ESP32-P4 various dev board : CS: 26, DC: 27, RST: 25, BL: 24, SCK: 36, MOSI: 32, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
/* more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git */
void setup(void)
{
#ifdef DEV_DEVICE_INIT
DEV_DEVICE_INIT();
#endif
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX U8g2 Font Print UTF8 example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(RGB565_BLACK);
gfx->setUTF8Print(true); // enable UTF8 support for the Arduino print() function
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
int16_t x1, y1;
uint16_t w, h;
/* U8g2 font list: https://github.com/olikraus/u8g2/wiki/fntlistall */
/* U8g2 Unifont list: https://github.com/olikraus/u8g2/wiki/fntgrpunifont */
gfx->setFont(u8g2_font_unifont_tr);
gfx->setTextColor(RGB565_RED);
gfx->setCursor(1, 16);
gfx->getTextBounds("Hello World!", 1, 16, &x1, &y1, &w, &h);
gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RGB565_RED);
gfx->println("Hello World!");
gfx->setFont(u8g2_font_unifont_t_polish);
gfx->setTextColor(RGB565_YELLOW);
gfx->setCursor(1, 36);
gfx->getTextBounds("Witaj świecie!", 1, 36, &x1, &y1, &w, &h);
gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RGB565_RED);
gfx->println("Witaj świecie!");
gfx->setFont(u8g2_font_unifont_t_vietnamese1);
gfx->setTextColor(RGB565_LIME);
gfx->setCursor(1, 56);
gfx->getTextBounds("Chào thế giới!", 1, 56, &x1, &y1, &w, &h);
gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RGB565_RED);
gfx->println("Chào thế giới!");
#ifdef U8G2_USE_LARGE_FONTS
gfx->setFont(u8g2_font_unifont_t_chinese2);
gfx->setTextColor(RGB565_CYAN);
gfx->setCursor(1, 76);
gfx->getTextBounds("世界你好!", 1, 76, &x1, &y1, &w, &h);
gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RGB565_RED);
gfx->println("世界你好!");
gfx->setFont(u8g2_font_unifont_t_japanese1);
gfx->setTextColor(RGB565_BLUE);
gfx->setCursor(1, 96);
gfx->getTextBounds("こんにちは世界!", 1, 96, &x1, &y1, &w, &h);
gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RGB565_RED);
gfx->println("こんにちは世界!");
gfx->setFont(u8g2_font_unifont_t_korean1);
gfx->setTextColor(RGB565_MAGENTA);
gfx->setCursor(1, 116);
gfx->getTextBounds("안녕하세요, 세계입니다!", 1, 116, &x1, &y1, &w, &h);
gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RGB565_RED);
gfx->println("안녕하세요, 세계입니다!");
#endif // U8G2_USE_LARGE_FONTS
}
void loop()
{
}

View File

@@ -0,0 +1,88 @@
/*******************************************************************************
* U8g2 Chinese font example
* Please note this font is 1,024,137 in size and cannot fit in many platform.
* This font is generated by U8g2 tools:
* 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_h_chinese.h -n u8g2_font_unifont_h_chinese
******************************************************************************/
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C2/3 various dev board: CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-C5 various dev board : CS: 23, DC: 24, RST: 25, BL: 26, SCK: 10, MOSI: 8, MISO: nil
* ESP32-C6 various dev board : CS: 18, DC: 22, RST: 23, BL: 15, SCK: 21, MOSI: 19, MISO: nil
* ESP32-H2 various dev board : CS: 0, DC: 12, RST: 8, BL: 22, SCK: 10, MOSI: 25, MISO: nil
* ESP32-P4 various dev board : CS: 26, DC: 27, RST: 25, BL: 24, SCK: 36, MOSI: 32, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
/* more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git */
void setup(void)
{
#ifdef DEV_DEVICE_INIT
DEV_DEVICE_INIT();
#endif
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX U8g2 Font UTF8 Chinese example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(RGB565_BLACK);
gfx->setUTF8Print(true); // enable UTF8 support for the Arduino print() function
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->setFont(u8g2_font_unifont_h_chinese);
gfx->setTextColor(RGB565_WHITE);
gfx->setCursor(0, 16);
gfx->println("Arduino 是一個開源嵌入式硬體平台,用來供用戶製作可互動式的嵌入式專案。此外 Arduino 作為一個開源硬體和開源軟件的公司同時兼有專案和用戶社群。該公司負責設計和製造Arduino電路板及相關附件。這些產品按照GNU寬通用公共許可證LGPL或GNU通用公共許可證GPL[1]許可的開源硬體和軟件分發的Arduino 允許任何人製造 Arduino 板和軟件分發。 Arduino 板可以以預裝的形式商業銷售也可以作為DIY套件購買。");
gfx->println("Arduino 专案始于2003年作为意大利伊夫雷亚地区伊夫雷亚互动设计研究所的学生专案目的是为新手和专业人员提供一种低成本且简单的方法以建立使用感测器与环境相互作用的装置执行器。适用于初学者爱好者的此类装置的常见范例包括感测器、简单机械人、恒温器和运动检测器。");
}
void loop()
{
}

View File

@@ -0,0 +1,108 @@
/*******************************************************************************
* U8g2 CJK(Chinese, Japanese and Korean) font example
* Please note this font is 1,704,862 in size and cannot fit in many platform.
* This font is generated by U8g2 tools:
* u8g2/tools/font/bdfconv/bdfconv -v -f 1 -b 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_h_cjk.h -n u8g2_font_unifont_h_cjk
******************************************************************************/
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C2/3 various dev board: CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-C5 various dev board : CS: 23, DC: 24, RST: 25, BL: 26, SCK: 10, MOSI: 8, MISO: nil
* ESP32-C6 various dev board : CS: 18, DC: 22, RST: 23, BL: 15, SCK: 21, MOSI: 19, MISO: nil
* ESP32-H2 various dev board : CS: 0, DC: 12, RST: 8, BL: 22, SCK: 10, MOSI: 25, MISO: nil
* ESP32-P4 various dev board : CS: 26, DC: 27, RST: 25, BL: 24, SCK: 36, MOSI: 32, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
/* more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git */
void setup(void)
{
#ifdef DEV_DEVICE_INIT
DEV_DEVICE_INIT();
#endif
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX U8g2 Font UTF8 FullCJK example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(RGB565_BLACK);
gfx->setUTF8Print(true); // enable UTF8 support for the Arduino print() function
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
/* select one font below and uncomment, chill7 and cubic11 are smaller size but lack of Korea characters */
// gfx->setFont(u8g2_font_chill7_h_cjk);
// gfx->setFont(u8g2_font_cubic11_h_cjk);
gfx->setFont(u8g2_font_quan7_h_cjk);
// gfx->setFont(u8g2_font_unifont_h_cjk);
gfx->setCursor(0, 14);
gfx->setTextColor(RGB565_RED);
gfx->println("世界你好,今天的天氣真好啊!");
gfx->println();
gfx->setTextColor(RGB565_YELLOW);
gfx->println("世界你好,今天的天气真好啊!");
gfx->println();
gfx->setTextColor(RGB565_LIME);
gfx->println("こんにちは世界、今日はいいお天気ですね!");
gfx->println();
gfx->setTextColor(RGB565_BLUE);
gfx->println("안녕하세요 세계, 오늘 날씨가 너무 좋습니다!");
gfx->println();
gfx->setTextColor(RGB565_MAGENTA);
gfx->println("Hello world, the weather is so nice today!");
}
void loop()
{
}

View File

@@ -0,0 +1,173 @@
/*******************************************************************************
* U8g2 latest unifont-14.0.02 all glyphs example
* Please note this font is 2,250,360 in size and cannot fit in many platform.
* This font is generated by U8g2 tools:
* 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
* Hello world in multiple languages
* https://codegolf.stackexchange.com/questions/146544/hello-world-in-multiple-languages
******************************************************************************/
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C2/3 various dev board: CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-C5 various dev board : CS: 23, DC: 24, RST: 25, BL: 26, SCK: 10, MOSI: 8, MISO: nil
* ESP32-C6 various dev board : CS: 18, DC: 22, RST: 23, BL: 15, SCK: 21, MOSI: 19, MISO: nil
* ESP32-H2 various dev board : CS: 0, DC: 12, RST: 8, BL: 22, SCK: 10, MOSI: 25, MISO: nil
* ESP32-P4 various dev board : CS: 26, DC: 27, RST: 25, BL: 24, SCK: 36, MOSI: 32, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
/* more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git */
String helloWorldStrings[] = {
"Hello Wêreld!", // Afrikaans
"Përshendetje Botë!", // Albanian
"ሰላም ልዑል!", // Amharic
"مرحبا بالعالم!", // Arabic
"Բարեւ աշխարհ!", // Armenian
"Kaixo Mundua!", // Basque
"Прывітанне Сусвет!", // Belarussian
"ওহে বিশ্ব!", // Bengali
"Здравей свят!", // Bulgarian
"Hola món!", // Catalan
"Moni Dziko Lapansi!", // Chichewa
"世界你好!", // Chinese
"Pozdrav svijete!", // Croatian
"Ahoj světe!", // Czech
"Hej Verden!", // Danish
"Hallo Wereld!", // Dutch
"Hello World!", // English
"Tere maailm!", // Estonian
"Hei maailma!", // Finnish
"Bonjour monde!", // French
"Hallo wrâld!", // Frisian
"გამარჯობა მსოფლიო!", // Georgian
"Hallo Welt!", // German
"Γειά σου Κόσμε!", // Greek
"Sannu Duniya!", // Hausa
"שלום עולם!", // Hebrew
"नमस्ते दुनिया!", // Hindi
"Helló Világ!", // Hungarian
"Halló heimur!", // Icelandic
"Ndewo Ụwa!", // Igbo
"Halo Dunia!", // Indonesian
"Ciao mondo!", // Italian
"こんにちは世界!", // Japanese
"Сәлем Әлем!", // Kazakh
"សួស្តី​ពិភពលោក!", // Khmer
"Салам дүйнө!", // Kyrgyz
"ສະ​ບາຍ​ດີ​ຊາວ​ໂລກ!", // Lao
"Sveika pasaule!", // Latvian
"Labas pasauli!", // Lithuanian
"Moien Welt!", // Luxemburgish
"Здраво свету!", // Macedonian
"Hai dunia!", // Malay
"ഹലോ വേൾഡ്!", // Malayalam
"Сайн уу дэлхий!", // Mongolian
"မင်္ဂလာပါကမ္ဘာလောက!", // Myanmar
"नमस्कार संसार!", // Nepali
"Hei Verden!", // Norwegian
"سلام نړی!", // Pashto
"سلام دنیا!", // Persian
"Witaj świecie!", // Polish
"Olá Mundo!", // Portuguese
"ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ!", // Punjabi
"Salut Lume!", // Romanian
"Привет мир!", // Russian
"Hàlo a Shaoghail!", // Scots Gaelic
"Здраво Свете!", // Serbian
"Lefatše Lumela!", // Sesotho
"හෙලෝ වර්ල්ඩ්!", // Sinhala
"Pozdravljen svet!", // Slovenian
"¡Hola Mundo!", // Spanish, Leading '¡' optional
"Halo Dunya!", // Sundanese
"Salamu Dunia!", // Swahili
"Hej världen!", // Swedish
"Салом Ҷаҳон!", // Tajik
"สวัสดีชาวโลก!", // Thai
"Selam Dünya!", // Turkish
"Привіт Світ!", // Ukrainian
"Salom Dunyo!", // Uzbek
"Chào thế giới!", // Vietnamese
"Helo Byd!", // Welsh
"Molo Lizwe!", // Xhosa
"העלא וועלט!", // Yiddish
"Mo ki O Ile Aiye!", // Yoruba
"Sawubona Mhlaba!" // Zulu
};
void setup(void)
{
#ifdef DEV_DEVICE_INIT
DEV_DEVICE_INIT();
#endif
Serial.begin(115200);
// Serial.setDebugOutput(true);
// while(!Serial);
Serial.println("Arduino_GFX U8g2 Font UTF8 Full Unifont example");
// Init Display
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(RGB565_BLACK);
gfx->setUTF8Print(true); // enable UTF8 support for the Arduino print() function
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
gfx->setCursor(0, 14);
gfx->setFont(u8g2_font_unifont_h_utf8);
gfx->println("Hello world in multiple languages");
delay(2000); // 2 seconds
}
void loop()
{
gfx->setCursor(random(gfx->width() / 4), random(gfx->height() - 32) + 16);
gfx->setTextColor(random(0xffff), random(0xffff));
gfx->setTextSize(random(2) + 2 /* x scale */, random(2) + 2 /* y scale */);
gfx->println(helloWorldStrings[random(74)]);
delay(500); // 0.5 second
}

View File

@@ -0,0 +1,244 @@
/*******************************************************************************
* U8g2 RSS Reader
* This is a simple RSS Reader sample with UTF-8 support
*
* * Raspberry Pi Pico W dependent libraries:
* HttpClient: https://github.com/moononournation/HttpClient.git
*
* Setup steps:
* 1. Fill your own SSID_NAME, SSID_PASSWORD, RSS_HOST, RSS_PORT, RSS_PATH
* 2. Change your LCD parameters in Arduino_GFX setting
******************************************************************************/
/* WiFi settings */
#define SSID_NAME "YourAP"
#define SSID_PASSWORD "PleaseInputYourPasswordHere"
#define RSS_HOST "rss.weather.gov.hk"
#define RSS_PORT 80
#define RSS_PATH "/rss/LocalWeatherForecast_uc.xml"
/*******************************************************************************
* Start of Arduino_GFX setting
*
* Arduino_GFX try to find the settings depends on selected board in Arduino IDE
* Or you can define the display dev kit not in the board list
* Defalult pin list for non display dev kit:
* Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12
* ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
* ESP32-C2/3 various dev board: CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil
* ESP32-C5 various dev board : CS: 23, DC: 24, RST: 25, BL: 26, SCK: 10, MOSI: 8, MISO: nil
* ESP32-C6 various dev board : CS: 18, DC: 22, RST: 23, BL: 15, SCK: 21, MOSI: 19, MISO: nil
* ESP32-H2 various dev board : CS: 0, DC: 12, RST: 8, BL: 22, SCK: 10, MOSI: 25, MISO: nil
* ESP32-P4 various dev board : CS: 26, DC: 27, RST: 25, BL: 24, SCK: 36, MOSI: 32, MISO: nil
* ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
* ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
* ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12
* Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
* RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
* RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11
* RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
* RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10
* Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9
* Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
******************************************************************************/
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
#define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin
/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
#if defined(DISPLAY_DEV_KIT)
Arduino_GFX *gfx = create_default_Arduino_GFX();
#else /* !defined(DISPLAY_DEV_KIT) */
/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
Arduino_DataBus *bus = create_default_Arduino_DataBus();
/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */);
#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
* End of Arduino_GFX setting
******************************************************************************/
#if defined(ESP32)
#include <WiFi.h>
#include <HTTPClient.h>
WiFiClient client;
HTTPClient http;
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
WiFiClient client;
HTTPClient http;
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
#include <WiFi.h>
#include <WiFiClient.h>
#include <HttpClient.h>
WiFiClient client;
HttpClient http(client);
#elif defined(RTL8722DM)
#include <WiFi.h>
#include <WiFiClient.h>
#include <HttpClient.h>
WiFiClient client;
HttpClient http(client);
#endif
void setup(void)
{
#ifdef DEV_DEVICE_INIT
DEV_DEVICE_INIT();
#endif
Serial.begin(115200);
// while (!Serial);
// Serial.setDebugOutput(true);
Serial.println("Arduino_GFX U8g2 Font RSS Reader example");
Serial.println("Init display");
if (!gfx->begin())
{
Serial.println("gfx->begin() failed!");
}
gfx->fillScreen(RGB565_BLACK);
gfx->setUTF8Print(true); // enable UTF8 support for the Arduino print() function
#ifdef GFX_BL
pinMode(GFX_BL, OUTPUT);
digitalWrite(GFX_BL, HIGH);
#endif
Serial.println("Init WiFi");
gfx->println("Init WiFi");
#if defined(ESP32) || defined(ESP8266)
WiFi.mode(WIFI_STA);
WiFi.begin(SSID_NAME, SSID_PASSWORD);
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
WiFi.mode(WIFI_STA);
WiFi.begin(SSID_NAME, SSID_PASSWORD);
#elif defined(RTL8722DM)
WiFi.begin((char *)SSID_NAME, (char *)SSID_PASSWORD);
#endif
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
gfx->print(".");
}
Serial.println(" CONNECTED");
gfx->println(" CONNECTED");
/* U8g2 font list: https://github.com/olikraus/u8g2/wiki/fntlistall */
/* U8g2 Unifont list: https://github.com/olikraus/u8g2/wiki/fntgrpunifont */
gfx->setFont(u8g2_font_unifont_h_chinese4);
gfx->setTextColor(RGB565_WHITE);
}
void loop()
{
if (WiFi.status() == WL_CONNECTED)
{
Serial.printf("[HTTP] begin...\n");
#if defined(ESP32) || defined(ESP8266)
http.begin(client, RSS_HOST, RSS_PORT, RSS_PATH);
int httpCode = http.GET();
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(RTL8722DM)
http.get(RSS_HOST, RSS_PORT, RSS_PATH);
int httpCode = http.responseStatusCode();
http.skipResponseHeaders();
#endif
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
gfx->printf("[HTTP] GET... code: %d\n", httpCode);
// HTTP header has been send and Server response header has been handled
if (httpCode <= 0)
{
#if defined(ESP32) || defined(ESP8266)
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
#endif
}
else
{
if (httpCode != 200)
{
Serial.printf("[HTTP] Not OK!\n");
gfx->printf("[HTTP] Not OK!\n");
delay(5000);
}
else
{
// get lenght of document(is - 1 when Server sends no Content - Length header)
#if defined(ESP32) || defined(ESP8266)
int len = http.getSize();
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(RTL8722DM)
int len = http.contentLength();
#endif
Serial.printf("[HTTP] size: %d\n", len);
gfx->printf("[HTTP] size: %d\n", len);
if (len <= 0)
{
Serial.printf("[HTTP] Unknow content size: %d\n", len);
gfx->printf("[HTTP] Unknow content size: %d\n", len);
}
else
{
// get XML string
String xml = http.readString();
// update hour
int key_idx = xml.indexOf("<item>");
key_idx = xml.indexOf("<title>", key_idx + 6);
int val_start_idx = key_idx + 7;
int val_end_idx = xml.indexOf('<', val_start_idx);
int update_hour = xml.substring(val_start_idx + 35, val_start_idx + 37).toInt();
String title = xml.substring(val_start_idx, val_end_idx);
Serial.println(title);
gfx->fillScreen(RGB565_BLACK);
gfx->setCursor(0, 16);
// gfx->setTextSize(2);
gfx->setTextColor(RGB565_LIME);
gfx->println(title);
gfx->println();
// description
key_idx = xml.indexOf("<description><![CDATA[", val_end_idx);
val_start_idx = key_idx + 22;
val_end_idx = xml.indexOf("]]></description>", val_start_idx);
String description = xml.substring(val_start_idx, val_end_idx);
description.trim();
Serial.println(description);
// gfx->setTextSize(1);
gfx->setTextColor(RGB565_WHITE);
val_start_idx = 0;
while (val_start_idx < description.length())
{
val_end_idx = description.indexOf("<br/>", val_start_idx);
if (val_end_idx < 0)
{
val_end_idx = description.length();
}
String paragraph = description.substring(val_start_idx, val_end_idx);
paragraph.trim();
gfx->println(paragraph);
val_start_idx = val_end_idx + 5;
}
}
}
#if defined(ESP32) || defined(ESP8266)
http.end();
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(RTL8722DM)
http.stop();
#endif
delay(60 * 60 * 1000);
}
}
delay(1000);
}