Font size issues with TFT

Hi Guys,

Most of my projects that use a ILI9341 colour TFT screen uses the default font and text size commands to display information on the screen. Where information is always changing I’ve used the command

 tft.setTextColor(ILI9341_GREEN, ILI9341_BLACK);

to override the previous text and prevent overprinting. This works fine, and where data such as temperature is displayed the text changes as expected.

However I’ve been messing about with the fonts supplied with the Adafruit GFX library as I want to display information for temperature or humidity from a DH22 sensor in a less blocky font than that when the default font size is set high.

#include <Fonts/FreeMonoBoldOblique12pt7b.h>

For example.

However the text always gets overprinted as it seems to be ignoring the black background setting, so over time you end up with a large green rectangle as each update adds to the previous pixels…

Can anyone offer a quick and easy way to resolve this so that each time the screen is updated text isn’t overprinted.

There are three ways of dealing with this.

  1. write the previous text in the background colour
  2. use getTextBounds() with the previous text. and fillRect() to draw a background
  3. use fillRect() to draw a sensible size background.

Just write a single helper function. And use it.

Yes, you will notice a minimal flicker. But if you only update when the text changes it is not a problem.

Adafruit_GFX text methods work fairly well. A hardware library could make them faster. Or handle text completely differently.