OLED Drivers

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

OLED Drivers

Post by deshipu » Tue Oct 17, 2017 9:23 am

I just published the library of drivers for SSD1306 and SH1106 monochrome OLED displays. There is a driver for SSD1306 displays in MicroPython's repository, but I wasn't satisfied with it. The drivers in this library are minimalist, each version is in a separate self-contained file, so that you only need to copy that one file onto your device (you usually only use one display at a time anyways). They also avoid allocating memory and all sorts of indirection (inheritance, wrapping, etc.) to get around speed penalties. Because of that the code is not as readable, and there is quite a lot of repetition, but I'm willing to accept that. I also added support for some hardware functions of the display, like flipping, scrolling, etc.

The code is at https://bitbucket.org/thesheep/micropython-oled

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: OLED Drivers

Post by devnull » Tue Oct 17, 2017 1:27 pm

I will try this tomorrow, have you tried on the 8266 ?

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: OLED Drivers

Post by deshipu » Tue Oct 17, 2017 2:58 pm

Yes, I mostly tested this on the ESP8266.

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: OLED Drivers

Post by bitninja » Tue Oct 17, 2017 4:07 pm

This is nice. Thanks again for your efforts.

I know I should look at the framebuf source, but do you know if the framebuf handles out-of-range values? What I mean is, if I have a coordinate bug and try to set a pixel out of range... does framebuf quietly ignore such an invalid command?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: OLED Drivers

Post by pythoncoder » Tue Oct 17, 2017 4:23 pm

Peter Hinch
Index to my micropython libraries.

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: OLED Drivers

Post by bitninja » Thu Oct 19, 2017 2:07 am

pythoncoder wrote:
Tue Oct 17, 2017 4:23 pm
It ignores them: https://github.com/micropython/micropyt ... #L286-L299.
Thank you!

I have replaced the standard ssd1306.py with a copy of the OP's I2C version. I did write my own wrapper layer to add some other features but the cost was worth it to me. It still runs faster than the original wrapper I had for the regular driver. Anyway, everything seems to work flawlessly.

I love removing code and getting better performance.

Post Reply