acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
U8g2FontPrintUTF8.ino (4785B)
1 /******************************************************************************* 2 * Start of Arduino_GFX setting 3 * 4 * Arduino_GFX try to find the settings depends on selected board in Arduino IDE 5 * Or you can define the display dev kit not in the board list 6 * Defalult pin list for non display dev kit: 7 * Arduino Nano, Micro and more: CS: 9, DC: 8, RST: 7, BL: 6, SCK: 13, MOSI: 11, MISO: 12 8 * ESP32 various dev board : CS: 5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil 9 * ESP32-C3 various dev board : CS: 7, DC: 2, RST: 1, BL: 3, SCK: 4, MOSI: 6, MISO: nil 10 * ESP32-S2 various dev board : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil 11 * ESP32-S3 various dev board : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil 12 * ESP8266 various dev board : CS: 15, DC: 4, RST: 2, BL: 5, SCK: 14, MOSI: 13, MISO: 12 13 * Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16 14 * RTL8720 BW16 old patch core : CS: 18, DC: 17, RST: 2, BL: 23, SCK: 19, MOSI: 21, MISO: 20 15 * RTL8720_BW16 Official core : CS: 9, DC: 8, RST: 6, BL: 3, SCK: 10, MOSI: 12, MISO: 11 16 * RTL8722 dev board : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12 17 * RTL8722_mini dev board : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI: 9, MISO: 10 18 * Seeeduino XIAO dev board : CS: 3, DC: 2, RST: 1, BL: 0, SCK: 8, MOSI: 10, MISO: 9 19 * Teensy 4.1 dev board : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12 20 ******************************************************************************/ 21 #include <U8g2lib.h> 22 #include <Arduino_GFX_Library.h> 23 24 #define GFX_BL DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin 25 26 /* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */ 27 #if defined(DISPLAY_DEV_KIT) 28 Arduino_GFX *gfx = create_default_Arduino_GFX(); 29 #else /* !defined(DISPLAY_DEV_KIT) */ 30 31 /* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */ 32 Arduino_DataBus *bus = create_default_Arduino_DataBus(); 33 34 /* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */ 35 Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 0 /* rotation */, false /* IPS */); 36 37 #endif /* !defined(DISPLAY_DEV_KIT) */ 38 /******************************************************************************* 39 * End of Arduino_GFX setting 40 ******************************************************************************/ 41 42 /* more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git */ 43 44 void setup(void) 45 { 46 gfx->begin(); 47 gfx->fillScreen(BLACK); 48 gfx->setUTF8Print(true); // enable UTF8 support for the Arduino print() function 49 50 #ifdef GFX_BL 51 pinMode(GFX_BL, OUTPUT); 52 digitalWrite(GFX_BL, HIGH); 53 #endif 54 55 int16_t x1, y1; 56 uint16_t w, h; 57 58 /* U8g2 font list: https://github.com/olikraus/u8g2/wiki/fntlistall */ 59 /* U8g2 Unifont list: https://github.com/olikraus/u8g2/wiki/fntgrpunifont */ 60 gfx->setFont(u8g2_font_unifont_tr); 61 gfx->setTextColor(RED); 62 gfx->setCursor(1, 16); 63 gfx->getTextBounds("Hello World!", 1, 16, &x1, &y1, &w, &h); 64 gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RED); 65 gfx->println("Hello World!"); 66 67 gfx->setFont(u8g2_font_unifont_t_polish); 68 gfx->setTextColor(YELLOW); 69 gfx->setCursor(1, 36); 70 gfx->getTextBounds("Witaj świecie!", 1, 36, &x1, &y1, &w, &h); 71 gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RED); 72 gfx->println("Witaj świecie!"); 73 74 gfx->setFont(u8g2_font_unifont_t_vietnamese1); 75 gfx->setTextColor(GREEN); 76 gfx->setCursor(1, 56); 77 gfx->getTextBounds("Chào thế giới!", 1, 56, &x1, &y1, &w, &h); 78 gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RED); 79 gfx->println("Chào thế giới!"); 80 81 #ifdef U8G2_USE_LARGE_FONTS 82 gfx->setFont(u8g2_font_unifont_t_chinese2); 83 gfx->setTextColor(CYAN); 84 gfx->setCursor(1, 76); 85 gfx->getTextBounds("世界你好!", 1, 76, &x1, &y1, &w, &h); 86 gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RED); 87 gfx->println("世界你好!"); 88 89 gfx->setFont(u8g2_font_unifont_t_japanese1); 90 gfx->setTextColor(BLUE); 91 gfx->setCursor(1, 96); 92 gfx->getTextBounds("こんにちは世界!", 1, 96, &x1, &y1, &w, &h); 93 gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RED); 94 gfx->println("こんにちは世界!"); 95 96 gfx->setFont(u8g2_font_unifont_t_korean1); 97 gfx->setTextColor(MAGENTA); 98 gfx->setCursor(1, 116); 99 gfx->getTextBounds("안녕하세요, 세계입니다!", 1, 116, &x1, &y1, &w, &h); 100 gfx->drawRect(x1 - 1, y1 - 1, w + 2, h + 2, RED); 101 gfx->println("안녕하세요, 세계입니다!"); 102 #endif // U8G2_USE_LARGE_FONTS 103 } 104 105 void loop() 106 { 107 }