OLED SD1306 display error

Hi.
Can someone please tell me if they have come across this display error on an OLED SSD1306 display? See "jibberish" down the bottom right corner. It "feels" like some sort of overflow.

Here's a section of code that also displays an error down the bottom right corner, once I go to the next screen:

  // Following info displays on screen hint to press buttons to select discharge current
  delay(1000);                           // delay for next screen message below
  display.clearDisplay();
  display.setTextSize(2);
  display.setCursor(2, 0);
  display.print("Select mA");
  display.setCursor(2, 18);
  display.print("Up / down");
  display.setCursor(2, 45);

  //Include Threshold and Vcc in startup display
  display.setTextSize(1);
  display.setCursor(2, 45);
  display.print("Threshold =");
  display.print(dtostrf(LowBatteryLevel, 4, 1, val_0));
  display.println(" V");
  display.setCursor(2, 56);
  display.print("Arduino   = ");
  display.print(dtostrf(Vref, 3, 3, val_1));
  display.println(" V");
  display.display();
} // end void setup

The code uses too much ram, it is overwriting the display buffer.

1 Like

Oh, that makes sense. I'm using and Arduino Nano and I had a similar problem with Serial.print.

Is this based on the "total" text that I'm displaying per page, or total in the whole code (i.e. total characters)?

What do you suggest so I can fix the problem.

First thing to try is using the F() macro when printing text literals. Putting F() around the quoted text tells the compiler to use it directly from program memory instead of putting it into ram.

  display.print(F("Select mA"));

If that doesn't help, the U8g2 library has options to use a page buffer, which uses considerably less memory than a full buffer. If you are using the Adafruit library, the 1024 byte buffer for a 128x64 display is not shown in the dynamic memory total from the compiler, so you have to allow for that much more ram.

2 Likes

@david_2018 , I added the F() around the quoted text as you suggested and it fixed ALL the screen.

Thanks so much - I'd spent hours trying to figure this out. Such a simple fix.

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