Writing a string to an oled display without clearing the entire buffer

Hello,

I'm tring to make my code as efficient as possible by getting around repetitive task so I decided to pre add all additional icons and then only refresh the data over it without clearing the unnecessary data.

I am using the adafruit libraries Adafruit_GFX.h

Adafruit_SSD1306.h

so I tried to erase the characters in a particular position with spaces for example if I know the string is 3 chars max I'd write 3 spaces " " but it didn't work and figured out that the library only sets pixels in buffer instead of writes them (putting only '1' when needed and not '1' or '0')

here's what I've tried with no luck also if someone has a proper link(Arduino reference like) to the functions of the adafruit gxf library I'd be happy:

display.setCursor(80, 24); display.setTextSize(2); display.print(" "); display.setCursor(80, 24); display.print(Throttle); display.print("%"); display.setTextSize(1);

display.display();

You need to print the text with foreground AND background specified, then a "space" will blank out characters previously printed. Example:

display.setTextColor(WHITE,BLACK); // Set text to plot foreground and background colours

Documentation on the GFX library is here.

bodmer: You need to print the text with foreground AND background specified, then a "space" will blank out characters previously printed. Example:

display.setTextColor(WHITE,BLACK); // Set text to plot foreground and background colours

Documentation on the GFX library is here.

Thanks that fixed the problem!