- Name : SSD1306_OLED_RPI
- Description :
- Library to support the I2C 128X64 OLED Display Module driven by the SSD1306 controller for the Raspberry PI.
- Raspberry Pi C++ library.
- Inverse color, rotate, sleep, scroll and contrast control.
- Default font is Extended ASCII, scalable font.
- 4 other fonts included.
- Graphics class included.
- Bitmaps supported.
- Hardware I2C using bcm2835 library
- Also tested on 128X32 display size. Should work for 96X16 display size.
-
Author: Gavin Lyons
-
Developed on
- Raspberry PI 3 model b,
- C++ complier g++ (Raspbian 6.3.0-18)
- Raspbian 9.13 stretch OS
-
Based on my PIC OLED library and my RPI CH1115 SPI OLED library
Install the C libraries of bcm2835, see: http://www.airspayce.com/mikem/bcm2835/ The bcm2835 is a dependency and provides I2C bus, delays and GPIO control. There are 7 different main.cpp in the examples folder copy the one to run into src folder "Hello world" is in src by default. Make sure to run test file with sudo
To Install and run "hello world" execute following commands:
curl -sL https://github.com/gavinlyonsrepo/SSD1306_OLED_RPI/archive/1.0.tar.gz | tar xz
cd SSD1306_OLED_RPI_1.0
make
sudo ./bin/test
Connections as per manufacturers diagram, I2C bus pull-up resistors are on module. If 3.3V regulator on back of module can be powered from 5V PSU.
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 five 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 is special font large font but it is numbers only and cannot use the print class or be scaled(just one size).
Five fonts available :
Font num | Font name | Font size xbyy | Note |
---|---|---|---|
1 | Default | 5x8 | Full Extended ASCII 0 - 0xFF |
2 | Thick | 7x8 | no lowercase letters , ASCII 0x20 - 0x5A |
3 | Seven segment | 4x8 | ASCII 0x20 - 0x7A |
4 | Wide | 8x8 | no lowercase letters, ASCII 0x20 - 0x5A |
5 | Big Nums | 16x32 | ASCII 0x2E-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.