Hey all I have been trying to figure out how to go about clear the screen but even using:
display.clearDisplay();
Does not clear the screen.
This is the type of OLED I have:
Here my full code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
String content = "";
char character;
void setup() {
Serial.begin(115200);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
display.display();
}
void sayOnScreeen(String saying) {
display.clearDisplay();
display.clearDisplay();
//display.display();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println(saying);
display.display();
}
void loop() {
while(Serial.available()) {
character = Serial.read();
content.concat(character);
}
if (content != "") {
sayOnScreeen(content);
}
}
Every time I send a word via the serial it just appends it to the last word that was sent instead of clearing the screen and then write that word. Every time I send something via the serial I want it to clear the screen and then display what was sent.
Any ideas? Did I miss some code somewhere or am I not using the correct command(s)?