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.02k stars 640 forks source link

SH1106 flickers while updating but SSD1306 works fine #208

Closed antonioag95 closed 6 years ago

antonioag95 commented 6 years ago

I'm writing some code which gets temperature and humidity every 2 seconds from DHT22 and then it prints values on the display. I've been coding using SSD1306 and everything was fine, now I wanted to upgrade my screen to the bigger one and I got that issue. Do you know how to solve it? Thanks!

Here you can see what I'm talking about: https://youtu.be/zMpA_k8ndM8

laurentopia commented 6 years ago

It's a code issue, without seeing it I'd guess that you're calling .display() right after .clear(). The way this lib works is it writes to a frame buffer then dumps it to the display. So instead, call .display() at the very end of your display code so it would be like this: .clear() // clears the frame buffer .doStuff() .display() // push the frame buffer to the OLED

antonioag95 commented 6 years ago

I got it! It was a code issue but not the one mentioned by @laurentopia . It seems that calling .setContrast(255) causes that annoying bug ONLY when using SH1106, that's why the same code on SSD1306 was fine! I removed those lines and now my display is not flickering anymore. I'm leaving the issue open in case @squix78 wants to explain why this is happening, otherwise just tell me and I'll close it.