Page 1 of 1

I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue Jan 17, 2017 3:53 am
by bitbank
I wrote a little C library for talking to those inexpensive 0.96" OLED displays through the I2C bus. It provides simple functions for drawing text in 2 sizes and for drawing pixels. It's a static library that can get your display up and running in a couple of minutes. Please let me know if you find it useful.

https://gitlab.com/bitbank/oled_96.git

https://goo.gl/photos/iTVsk7b8daTjoMq28

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue Jan 17, 2017 10:46 am
by joan
How do you access the source code? It may be a cookie problem (I disable all cookies by default) but I'm not familiar with gitlab and nothing I click produces anything useful.

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue Jan 17, 2017 12:07 pm
by bitbank
joan wrote:How do you access the source code? It may be a cookie problem (I disable all cookies by default) but I'm not familiar with gitlab and nothing I click produces anything useful.
I switched the project type to "public" and it appears to clone correctly for me. Do you get an authentication error when you type the following?

git clone https://gitlab.com/bitbank/oled_96.git

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue Jan 17, 2017 12:11 pm
by joan
It asks for a username and a password - neither of which I have.

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue Jan 17, 2017 12:41 pm
by evilskaap
I can confirm that it asks for a username and password.

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue Jan 17, 2017 12:46 pm
by bitbank
I find GitLab difficult to navigate as far as setting options/features, so I pushed it to Github. You can find it here:

https://github.com/bitbank2/oled_96

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue Jan 17, 2017 2:19 pm
by joan
Thanks, that makes the code visible.

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Wed Jan 18, 2017 2:20 am
by bitbank
@joan - glad you are able to see it.

Part 2 of my plan is to control the SSD1306 through a FTDI FT232H (USB to multiprotocol adapter connected to a Linux or Mac computer). I'll #ifdef that code into the same project and it will link with FTDI's D2XX library.

https://www.adafruit.com/product/2264

I created a sample app which calls the library functions. It gets the current IP address of your machine and displays it along with the current time and date until you press ENTER.

https://github.com/bitbank2/oled_example

https://goo.gl/photos/bvWgxKJjmrN7bSKT8

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Sun Jan 22, 2017 8:48 pm
by tenochtitlanuk
Perhaps off-topic on a Pi forum, but relevant....

I've been trying to use the Adafruit ft232h breakout from a fully up-to-date Linux Mint installation on a desktop.
It steadfastly refuses to be seen as a usb or tty device.
The installation followed Adafruit's instructions, and the Adafruit_FTDI and ftdi1 installs both worked.
At present Adafruit have been unable to help. Web searches suggest using modprobe to remove two modules- but breakout board is still 'invisible'.
Have you got yours working on a Lnux machine? Did you have any problems.

I've yet to try it directly from one of my Pis, and am a bit disheartened. In the past I've used USB bords like the Bitwacker with no problems...

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Mon Jan 23, 2017 10:30 am
by bitbank
tenochtitlanuk wrote:Perhaps off-topic on a Pi forum, but relevant....

I've been trying to use the Adafruit ft232h breakout from a fully up-to-date Linux Mint installation on a desktop.
It steadfastly refuses to be seen as a usb or tty device.
The installation followed Adafruit's instructions, and the Adafruit_FTDI and ftdi1 installs both worked.
At present Adafruit have been unable to help. Web searches suggest using modprobe to remove two modules- but breakout board is still 'invisible'.
Have you got yours working on a Lnux machine? Did you have any problems.

I've yet to try it directly from one of my Pis, and am a bit disheartened. In the past I've used USB bords like the Bitwacker with no problems...
I got mine working on a Dell XPS 13 running Ubuntu. I just tested bit banging so far. The I2C support is disappointing because it's not really "built-in", but requires a whole bunch of additional software. I will be testing it when I have some time and report by here when I have some results.

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Mon Jan 23, 2017 8:23 pm
by tenochtitlanuk
Mea culpa. I eventually tried what should have been obvious and tried another lead. Had been misled by the green power LED into thinking it was connected. Mint & Python now see it with no trouble! Thanks for taking the trouble to comment...

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue Nov 28, 2017 9:46 pm
by bitbank
It's been a while since I made changes to this code. Today I added support for the inverted and 180-degree flipped modes (new init parameters in my library).

https://github.com/bitbank2/oled_96

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue May 14, 2019 1:28 pm
by bitbank
I've mostly been making updates to the Arduino version of this code, but today I just pushed an update which adds support for all common display sizes (128x64, 128x32, 64x32, 132x64). I also updated the sample code to make it run without modification on Raspbian and other Linux distros (different I2C bus numbers) and added enough comments to make it easier to understand. You can grab the new code from the same Git Repo here:

https://github.com/bitbank2/oled_96

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue May 14, 2019 6:22 pm
by danjperron
Thanks, what about utf-8 and multi-language.

I was stuck with some library and I had to make my own also. I changed one libray that I found and create a table of characters using utf-8.
To minimize the cost in rom size you could specify which character you want.

https://github.com/danjperron/ssd1331_micropython

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Tue May 14, 2019 8:12 pm
by bitbank
danjperron wrote:
Tue May 14, 2019 6:22 pm
Thanks, what about utf-8 and multi-language.

I was stuck with some library and I had to make my own also. I changed one libray that I found and create a table of characters using utf-8.
To minimize the cost in rom size you could specify which character you want.

https://github.com/danjperron/ssd1331_micropython
That sounds like a good idea, but it's beyond what my needs are for this code. I can humbly suggest that you or a like minded developer please make such a change, do a pull request and I'll add it to the library.

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Wed May 15, 2019 12:24 am
by DarkElvenAngel
I wanted to thank you for sharing your library!

I have a few questions how do you customize the font? I would just want to add some custom symbols. Is it best to define a new font or extend one that exists?

As I've never used an OLED until yesterday I was wondering how difficult is it to add support for the SSD1327? Or is this deserving of its own thread?

All in all I really like this code it's simple and doesn't have all the bulk others have, Thanks again for sharing.

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Wed May 15, 2019 6:32 am
by bitbank
DarkElvenAngel wrote:
Wed May 15, 2019 12:24 am
I wanted to thank you for sharing your library!

I have a few questions how do you customize the font? I would just want to add some custom symbols. Is it best to define a new font or extend one that exists?

As I've never used an OLED until yesterday I was wondering how difficult is it to add support for the SSD1327? Or is this deserving of its own thread?

All in all I really like this code it's simple and doesn't have all the bulk others have, Thanks again for sharing.
Fonts are a tricky topic and I just took the easiest route with this code. There are licensing issues and data format issues. I'm sorry, but I don't have a good answer for you. I've seen websites that can dynamically generate a font, but it will probably not come out in the right format to use my existing code. There are other OLED libraries (at least for Arduino) which offer much better font support. Converting the code to run on Linux/RPI is easy since the only functions you need to change are to access the I2C bus.

I haven't used the SSD1327 before, but I was a bit curious about it. I support color OLEDs in my other project:

https://github.com/bitbank2/SPI_LCD

Most LCD/OLED displays have a very similar command set, so I would think it would take very little effort to change my SPI_LCD project to support the SSD1327.

Re: I just 'open sourced' my SSD1306 I2C OLED code

Posted: Wed May 15, 2019 5:23 pm
by DarkElvenAngel
bitbank wrote: Fonts are a tricky topic and I just took the easiest route with this code. There are licensing issues and data format issues. I'm sorry, but I don't have a good answer for you. I've seen websites that can dynamically generate a font, but it will probably not come out in the right format to use my existing code. There are other OLED libraries (at least for Arduino) which offer much better font support. Converting the code to run on Linux/RPI is easy since the only functions you need to change are to access the I2C bus.

I haven't used the SSD1327 before, but I was a bit curious about it. I support color OLEDs in my other project:

https://github.com/bitbank2/SPI_LCD

Most LCD/OLED displays have a very similar command set, so I would think it would take very little effort to change my SPI_LCD project to support the SSD1327.
Thanks for the tips, I was only looking to make symbols in this case not port any fonts per say. Maybe I need a simple way to add a glyph to the frame buffer?

I just bought two different displays and now I'm looking into how to use them in my project both are monochrome and support i2c, I'm hoping to set up something to support both in my project.

I'll take a look at your SPI_LCD and see how it goes thanks