TFT_eSPI must be included before Adafruit_GFX for Free Fonts to function #1629
Replies: 2 comments 1 reply
-
The TFT_eSPI library is not intended to work in tandem with Adafruit_GFX as both incorporate the same Free Fonts files. Putting TFT_eSPI first is important in this case so it loads the required files before the Adafruit library loads and claims sole access. |
Beta Was this translation helpful? Give feedback.
-
Hi Bodmer, ChatGPT made me discover this post, intersting. I expected that tft_eSPI.h would not be "compatible" with a later call on adafruit. I really prefer your library to Lady Ada's, but I sometimes have trouble migrating sketches, both for font usage as for TFT_WIDTH/HEIGHT and other definitions. FYI, the LLM also pointed out (I didn't verify) that your library didn't provide the followng functions : drawFastVLine(), drawFastHLine(), drawRoundRect(), fillRoundRect()] weirdly referring to this discussion as source of information. No big deal for me anyway. I tried this path, and loading both libraries works, but when I replace teh adafruit object by a tft_espi object, it looks like many functions are missing (such ass setfont). Would you be so kind as recommending the best "path" for the migration ? |
Beta Was this translation helpful? Give feedback.
-
I have been making use of both the Adafruit_LEDBackpack library, for 7 segment display functionality, as well as TFT_eSPI for a TFT LCD display. Everything was proceeding well, until I tried to use the Free Font capability of the TFT library. I would then get compile errors like:
I could get past the compile errors by manually including the specific font files. For example, like:
#include <Fonts/FreeSerifBold9pt7b.h>
However, I would get garbage displayed on the LCD.
I finally tracked down the issue being the inclusion of the Adafruit_LEDBackpack library before the include of the TFT_eSPI library. Specifically, it is the inclusion of the Adafruit_GFX library before the TFT_eSPI library. Adafruit_GFX is included by Adafruit_LEDBackpack.
Once I reversed the order, the compile is clean, and the Free Fonts are displayed correctly.
Bad:
Good:
I don't know that this is a bug somewhere, on one side or the other, or just the way things work. But documenting it in case other folk encounter.
Allan.
Beta Was this translation helpful? Give feedback.
All reactions