[solved] Mega (ESP32 onboard) ILI9486 BG Color not working? Can't overwrite Text

Hello

I am not able to overwrite existing text with other text. I get sooner or later complete filled squares.I have to blank it manualy to get it working. This is pumping up my Code, it is a Display with a lot of changing text. Thank you.

Working:

        tft.setFont(&Serif_plain_14);
        tft.setTextColor(BLACK, BLACK);
        tft.setCursor(94, timeline-26); tft.print(secs);
        secs = secsnow;
        tft.setTextColor(DARKGREEN, BLACK);
        tft.setCursor(94, timeline-26);
        tft.print(secs);

Not working:

        tft.setFont(&Serif_plain_14);
        secs = secsnow;
        tft.setTextColor(DARKGREEN, BLACK);
        tft.setCursor(94, timeline-26);
        tft.print(secs);

The "system" 5x7 font can be drawn with background or transparently.
e.g. setTextColor(GREEN, RED) setTextColor(GREEN)

FreeFonts are always transparent. This is clearly explained in the Adafruit_GFX docs.

Look at the Font_simple.ino example.
This shows how to draw the background separately.
Yes, it is a lot of faffing about.

David.

Thank you for this clear statement. As I know allways the old values, I can delete them before with tft.print();

But it seems unstable and cause spontan reboots. Maybe I should try with fillRECT(); would this be faster? Thank you.

Please be more accurate with your thread title. (the Author can always edit it)

Post a link to the actual display.
Post a link to the ESP32 board.

There are several ways to solve the background problem. e.g. print the old text pixels in background colour or just use fillRect() to paint the whole rectangle.

fillRect() is generally quicker and requires less brain-ache.
print() might be quicker for very fine fonts because there is more background pixels than letter pixels.

You should not get reboots on an ESP32 unless you are doing something very wrong.
The ESP8266 requires regular kicking i.e. with yield()

Bodmer's TFT_eSPI library supports parallel ILI9486.
Bodmer has much better text handling.
Bodmer's library is faster than MCUFRIEND_kbv on ESP32 but does not support as many controllers.

David.

OK, here we go, inspired from Font_simple.ino, working for me with these Fonts:

Fonts:

#include "Serif_plain_20.h"
#include "Serif_plain_24.h"
#include "Serif_plain_28.h"
#include "Serif_plain_40.h"
#include "Serif_plain_14.h"

Call it:

showmsgXY(94, timeline-26, &Serif_plain_14, 14, String(secs), GREEN, BLACK);

Funktion:

void showmsgXY(int x, int y, const GFXfont *f, int sz, String msg, unsigned long FG, unsigned long BG){
    tft.setFont(f);
    tft.setCursor(x, y);
    tft.setTextColor(FG);
    tft.fillRect(x, y, (sz/1.6)*msg.length()+2, 4-sz, BG);
    tft.print(msg);
}

Thank you, please keep up the excellent work. PS: The reboots where caused by declaring an array at wrong place...

This topic was automatically closed after 120 days. New replies are no longer allowed.