ThingPulse / esp8266-oled-ssd1306

Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
https://thingpulse.com
Other
2.01k stars 638 forks source link

Displayed content is shifted after some time #371

Closed Elmi77 closed 2 years ago

Elmi77 commented 2 years ago

I'm using a display at an ESP32 board and in general it works fine. Unfortunately, after several hours/some days, the displayed contents are shifted, means they are no longer aligned at the top.

This is what it looks like normaly and what is expected:

https://i.ibb.co/hyBLtmv/IMG-20220706-102158-DRO-1.jpg

And this is what happens when it goes wrong:

https://i.ibb.co/nkVZT2M/IMG-20220706-095712-DRO-1.jpg

I already tried to workaround this problem by calling init(), resetDisplay() or by turning it off and on again (displayOff()/displayOn()), but that does not help. Once the display is in this state, only a power cycle helps.

I also tried a different ESP32-board and other displays, but this all did not help.

I can't see a special condition which lets me reproduce this problem, the time after what it happens, seems to be random.

My call do clear() is always at the same position, does not depend on any condition, is always followed by the same drawing calls (also without any condition) and is always followed by a call to display(), so I do not see a reason why my regular calls should cause this.

So...is this a known problem? Or is there a way to securely reset/reinitialise the display to get rid of this problem?

Used version is 4.2.1 but it also happened with previous versions.

rob040 commented 2 years ago

You did not mention which display type and interface you use...

But such things may happen when the I2C signals are corrupted occasionally.

dobraMorda commented 2 years ago

I got the same problem. After couple time, content of the screen is shifted. I tested screen on lower speed, checked hardware and everything is okay. I think the problem is in buffer, because when the content is shifted I can change screens (with anime transistion), and content of screen changes properly but it has shifting similar like on pictures at @Elmi77.

Tbscml commented 2 years ago

I am witnessing exactly the same issue. Using a different microcontroller and SPI at 8mhz. The content shift is persistent for a few iterations. After ~2 consecutive shifts the content shifts back to the "normal state".

marcelstoer commented 2 years ago

@Elmi77 @dobraMorda @Tbscml I wonder how this could be a software issue with this library. Can I ask you to try other 4.x versions (4.0, 4.1, etc. see https://github.com/ThingPulse/esp8266-oled-ssd1306/releases) to understand if the behavior changes?

Tbscml commented 2 years ago

@marcelstoer I'm not able to test different release version right now, but i found very similar issues using other libraries: https://github.com/adafruit/Adafruit_SSD1306/issues/139 https://github.com/MarlinFirmware/Marlin/issues/14431

I'd suppose that the problem is not within the library, as data corruption would be cleared by the next frame.

Elmi77 commented 2 years ago

I already have checked hardware and wiring and limited I2C clock to 100 kHz, it does not change anything.

As the shifted layout is NOT corrected after some refreshes here, my original question again: how can I do/force a complete reinitialisation of the display in order to let it "start from scratch"?

dobraMorda commented 2 years ago

@marcelstoer I found bug in my own code - sometimes I2C crashes because two threads used the same I2C bus, and it was without control - and now my display works well. So sorry for my first thinking about bug in library. @Tbscml @Elmi77 I think you should check your code where u using the same I2C to read multiple sensors and how it works.

marcelstoer commented 2 years ago

Thanks @dobraMorda, kind of confirms my suspicion.

helzayat commented 1 year ago

I had the same problem with the Adafruit library and switched to this library hoping to fix it. However the problem continued. So it seems it's not related to the library. I am using an ESP-01 and assigning GPIOs 0 and 3 (RX) to I2C, only the SSD1306 is connected to I2C. Maybe this hardware is unable to maintain I2C timing correctly? My solution has been to re-init the display every couple of minutes - so far this is working.