diff --git a/README.md b/README.md index ad5fd990..21fd6721 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Most tiny displays in hobbyist electronics world support 8-bit SPI, but some req 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 donation may make it happen :P +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 :P ## Ease of use #### Simple Declaration @@ -84,8 +84,9 @@ Below are some figures compare with other 3 Arduino common display libraries. - 8-bit parallel interface (AVRPAR8, ESP32PAR8, ESP32S2PAR8, RPiPicoPAR8, RTLPAR8) - 16-bit parallel interface (ESP32PAR16, ESP32S2PAR8, RPiPicoPAR16) -## Tobe Support data bus (Donation can make it happen) +## Tobe Support data bus (Sponsors can make it happen) - ESP32 I2S 8-bit/16-bit parallel interface +- Arduino ATMega2560 dual 8-bit Port form 16-bit parallel interface - FastLED ## Currently Supported Dev Board @@ -103,7 +104,7 @@ Below are some figures compare with other 3 Arduino common display libraries. - Sony Spresense - WeAct BlackPill V2.0 (BlackPill F411CE) -## Tobe Support Dev Board (Donation can make it happen) +## Tobe Support Dev Board (Sponsors can make it happen) - Arduino ATMega2560 - ESP32-S3 Series @@ -155,7 +156,7 @@ Below are some figures compare with other 3 Arduino common display libraries. - ST7789 240x320 [[demo video](https://youtu.be/ZEvc1LkuVuQ)] - ST7796 320x480 [[demo video](https://youtu.be/hUL-RuG4MAQ)] -## Tobe Support Display (Donation can make it happen) +## Tobe Support Display (Sponsors can make it happen) - FastLED Martix supported by co-operate with Canvas - Mono display supported by co-operate with Canvas - Multi-color e-ink display supported by co-operate with Canvas @@ -166,6 +167,12 @@ Below are some figures compare with other 3 Arduino common display libraries. - Canvas_3bit (1/4 memory space framebuffer) - Canvas_Mono (1/16 memory space framebuffer) +## Feature wishlist (Sponsors can make it happen) +- Print UTF8 Characters +- Print color Emoji Characters +- Load bitmap font files from flash / SD +- Fill Gradient + ## Using source code come from: - http://elm-chan.org/fsw/tjpgd/00index.html - https://github.com/adafruit/Adafruit-GFX-Library.git diff --git a/src/Arduino_GFX.cpp b/src/Arduino_GFX.cpp index 9ace7d30..b556384b 100644 --- a/src/Arduino_GFX.cpp +++ b/src/Arduino_GFX.cpp @@ -1832,6 +1832,14 @@ void Arduino_GFX::drawChar(int16_t x, int16_t y, unsigned char c, } else // 'Classic' built-in font #endif // !defined(ATTINY_CORE) +#if defined(U8G2_FONT_SUPPORT) + if (u8g2Font) + { + u8x8_get_glyph_data(u8x8, encoding, buf, tile); + u8x8_DrawTile(u8x8, xx, y, 1, buf); + } + else // not u8g2Font +#endif // defined(U8G2_FONT_SUPPORT) { block_w = 6 * textsize_x; block_h = 8 * textsize_y; @@ -2038,6 +2046,9 @@ void Arduino_GFX::setRotation(uint8_t r) void Arduino_GFX::setFont(const GFXfont *f) { gfxFont = (GFXfont *)f; +#if defined(U8G2_FONT_SUPPORT) + u8g2Font = NULL; +#endif // defined(U8G2_FONT_SUPPORT) } /**************************************************************************/ @@ -2050,6 +2061,14 @@ void Arduino_GFX::flush() } #endif // !defined(ATTINY_CORE) +#if defined(U8G2_FONT_SUPPORT) +void Arduino_GFX::setFont(const uint8_t *font) +{ + gfxFont = NULL; + u8g2Font = (uint8_t *)font; +} +#endif // defined(U8G2_FONT_SUPPORT) + /**************************************************************************/ /*! @brief Helper to determine size of a character with current font/size. @@ -2119,6 +2138,12 @@ void Arduino_GFX::charBounds(char c, int16_t *x, int16_t *y, } else // not gfxFont #endif // !defined(ATTINY_CORE) +#if defined(U8G2_FONT_SUPPORT) + if (u8g2Font) + { + } + else // not u8g2Font +#endif // defined(U8G2_FONT_SUPPORT) { if (c == '\n') { // Newline? diff --git a/src/Arduino_GFX.h b/src/Arduino_GFX.h index 76818715..11d42ff5 100644 --- a/src/Arduino_GFX.h +++ b/src/Arduino_GFX.h @@ -18,6 +18,11 @@ #define DEGTORAD 0.017453292519943295769236907684886F #endif +#if __has_include() +#include +#define U8G2_FONT_SUPPORT +#endif + // Color definitions #define BLACK 0x0000 ///< 0, 0, 0 #define NAVY 0x000F ///< 0, 0, 123 @@ -189,6 +194,9 @@ class Arduino_GFX : public Print, public Arduino_G #if !defined(ATTINY_CORE) void setFont(const GFXfont *f = NULL); +#if defined(U8G2_FONT_SUPPORT) + void setFont(const uint8_t *font); +#endif // defined(U8G2_FONT_SUPPORT) virtual void flush(void); #endif // !defined(ATTINY_CORE) @@ -375,9 +383,13 @@ class Arduino_GFX : public Print, public Arduino_G wrap, ///< If set, 'wrap' text at right edge of display _cp437; ///< If set, use correct CP437 charset (default is off) #if !defined(ATTINY_CORE) - GFXfont - *gfxFont; ///< Pointer to special font -#endif // !defined(ATTINY_CORE) + GFXfont *gfxFont; ///< Pointer to special font +#endif // !defined(ATTINY_CORE) + +#if defined(U8G2_FONT_SUPPORT) + uint8_t *u8g2Font; +#endif // defined(U8G2_FONT_SUPPORT) + #if defined(LITTLE_FOOT_PRINT) int16_t WIDTH, ///< This is the 'raw' display width - never changes diff --git a/src/Arduino_TFT.cpp b/src/Arduino_TFT.cpp index 94acfc75..b247ab28 100644 --- a/src/Arduino_TFT.cpp +++ b/src/Arduino_TFT.cpp @@ -1065,8 +1065,15 @@ void Arduino_TFT::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color endWrite(); } } - else // 'Classic' built-in font + else // not gfxFont #endif // !defined(ATTINY_CORE) +#if defined(U8G2_FONT_SUPPORT) + if (u8g2Font) + { + Arduino_GFX::drawChar(x, y, c, color, bg); + } + else // not u8g2Font +#endif // defined(U8G2_FONT_SUPPORT) { block_w = 6 * textsize_x; block_h = 8 * textsize_y;