This is a fork of the SSD1306 OLED library by gavinlyonsrepo.
The changes I made are based on this Issue from a Python library for the SSD1306 chip.
Basically what I did was changing were some commands in the init
-method and and changed sometinh that is referred to as "colstart" and "colend" in the issue from the lumo-oled repo. This lets the display display things properly.
I only tested the library with a 128x32 display, which means that I can't guarantee for it to work with displays for other dimensions. Also I noticed that the scrolling functionality might have some issues, and there might be some more problems with features that I haven't tested yet. However, so far it seems to work nicely to fit my purpose.
- Name : SSD1305_OLED_RPI
- Description :
- Library to support the I2C 128X64 OLED Display Module driven by the SSD1305 controller for the Raspberry PI.
- Dynamic install-able system level Raspberry Pi C++ library.
- Inverse color, rotate, sleep, and scroll contrast control.
- Default font is Extended ASCII, scalable font.
- 4 other fonts included.
- Graphics class included.
- Bitmaps supported.
- not all fatures completely tested on this fork though, but we should be fine
- Hardware I2C using bcm2835 library
- Also tested on 128X32 display size. Should work for 96X16 display size.
- Dependency: bcm2835 Library
- Author: Gavin Lyons
- Developed on
- Raspberry PI 3 model b,
- C++ complier g++ (Raspbian 6.3.0-18)
- Raspbian 9.13 stretch OS
- bcm2835 Library 1.68
I did my testing on a Raspberry Pi 400, with a similar compiler and the bcm283 library
-
Make sure I2C bus is enabled on your raspberry PI
-
Install the dependency bcm2835 Library if not installed (at time of writing latest version is 1.68.)
- The bcm2835 library is a dependency and provides I2C bus, delays and GPIO control.
- Install the C libraries of bcm2835, Installation instructions here
-
Download the SSD1305_OLED_RPI library
- Open a Terminal in a folder where you want to download,build & test library
- Run following command to download from github.
curl -sL https://github.com/gavinlyonsrepo/SSD1305_OLED_RPI/archive/1.2.tar.gz | tar xz
- Run "make" to run the makefile in repo base folder to install library, it will be installed to usr/lib and usr/include
cd SSD1305_OLED_RPI-1.2
sudo make
- Next step is to test OLED and installed library with an example. Wire up your OLED. Next enter the examples folder and run the makefile in THAT folder, This makefile builds the examples file using the just installed library. and creates a test exe file in "bin". Be sure to use "sudo" as the bcm2835 requires root permissions by default see here for more details on that The default example file is "hello world", user should see hello world on the OLED by end of this step.
cd examples/
make
sudo bin/test
- There are seven examples files to try out. To decide which one the makefile builds simply edit "SRC" variable at top of the makefile in examples folder. in the "User SRC directory Option Section". Pick an example "SRC" directory path and ONE ONLY. Comment out the rest and repeat: make and run bin/test. Six of the examples are for 128x64 (screen size) OLED , the seventh: named HELLO_WORLD_128_32 is for a 128X32 OLED.
Connections as per manufacturers diagram.
I2C
Hardware I2C. Settings are in the "OLED_I2C_ON" method.
- Address is set to 0x3C(your module could be different).
- Clock rate is to BCM2835_I2C_CLOCK_DIVIDER_626
This can be increased if necessary to BCM2835_I2C_CLOCK_DIVIDER_148 for more faster bus. See bcm2835 for details
fonts
There are Six fonts.
A print class is available to print out most passed data types.
The fonts 1-4 are byte high(at text size 1) scale-able fonts, columns of padding added by SW.
Font 5-6 are large numerical fonts and cannot be scaled(just one size).
It is possible to use ':' and '.' symbol with these fonts, see examples.
Six fonts available :
Font num | Font name | Font size xbyy | Note |
---|---|---|---|
1 | Default | 5x8 | Full Extended ASCII 0x00 - 0xFF |
2 | Thick | 7x8 | ASCII 0x20 - 0x5A ,no lowercase letters |
3 | Seven segment | 4x8 | ASCII 0x20 - 0x7A |
4 | Wide | 8x8 | ASCII 0x20 - 0x5A , no lowercase letters |
5 | Big Nums | 16x32 | ASCII 0x30-0x3A , Numbers + : only |
6 | med Nums | 16x16 | ASCII 0x30-0x3A , Numbers + : only |
bitmaps
Bitmaps can be turned to data here at link use horizontal addressing draw mode. Use OLEDBitmap to draw bitmaps to buffer. You can also write a full screen bitmap direct to screen using OLEDBuffer method, this will use vertical addressing.
Output of example file "CLOCK_DEMO"