128x64 - 096-i2c-OLED-display-with-arduino-SSD13 - Logo Flickering

I have 128x64 0.96" I2C OLED display SSD1306 and I was using this library GitHub - adafruit/Adafruit_SSD1306: Arduino library for SSD1306 monochrome 128x64 and 128x32 OLEDs

So, I wanted to draw custom logo but the thing is, everything works fine when it's hooked up and program is flashed via USB, then the logo is rendered normally, but when I unplug my Arduino and plug it back on USB or on separate power source, I see my logo for few sec, then it flicker once or twice before it enter the loop.

I am rendering logo in setup function, but it looks like, when I plug my Arduino sometimes I see first content from my previous loop, and then it gets updated from setup method, why is that?

I have also modified Adafruit_SSD1306.cpp to remove default adafruit logo.

Nothing else, and I'm running out of ideas what I did wrong?

I don't know if this helps or not, but I noticed that flickering is more frequent if I change this part:

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

Think about it. The Logo is initialised in SRAM buffer when the program runs. As soon as you draw anything, the Logo is overwritten.

If you want to display the logo during program execution, put the data into a bitmap in Flash. Then you can make the appropriate call to display it whenever you want.


Wait, but why is not acting the same when it's constantly attached on USB and when I upload new sketch and when it is (re)started again?

It's not the issue logo being overwritten, but why it's overwritten then multiple times?

Anyway, maybe I don't understand it correctly. Can you please give more details how to put these data into flash?

What I did is more less this:

Just to be clear, I'm not trying to have logo visible all the time, just for the first few seconds, so basically to use it as splash screen, and then to clear screen and continue doing something else in loop, that's why I put it in setup method.

Think about it.

Look up crts.o in Wikipedia. (C RunTime Startup)