drawBitmap how to refresh text?

Hello with the Adafruit_GFX.h library how do I update the text within the Bitmap?
Below is just a test code when playing around with this library.
If I increase the canvas size and change print to println I will get multiple lines of "I Like Cake, 1 ,2 ,3 until the canvas runs out, but how do I make it so it just 'refreshes' the existing text..

void loop(void) {
delay(1000);
canvas.print("I like cake " + String(i));
tft.drawBitmap(0, 10, canvas.getBuffer(), 128, 8, HX8357_WHITE, HX8357_BLACK);
i = i + 1;
}

Thanks

you need to use the setCursor() function to position where your text will be printed. You may need to also include setTextColor(fg, bg) so it properly erases the background when updating.

You will also run into a problem if you print "I like cake 100" followed by "I like cake 99" since the string is shorter. Look at the getTextBounds() function to figure out how much space your text will be consuming

Thanks I was able to use setCursor() and setTextColor(fg,bg), and was able to use getTextBounds() to have the canvas/bitmap size scale to the text size. Now text updates fine with no flicker!

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