Menu

SSD1306.hpp

Janick Bergeron
Attachments

C++ SSD1306 RGB Device Driver

Derived from original work by Limor Fried/Ladyada for Adafruit Industries.

class BeagleBone::SSD1306: public rgb_driver

This class is a specialization of the abstract RGB driver class for the SSD1306.

The SSD1306 OLED controller is used in Adafruit's OLED graphic displays displays. These simple monochrome displays are inexpensive, very bright and can be connected directly to the header expansion connectors of the BeagleBone without requiring any level shifters (see picture at the top of this page).

To make the class visible:

#include "bonelib/SSD1306.hpp"

SSD1306::SSD1306(gpio sclk, gpio din, gpio dc, gpio cs, gpio rst, unsigned char height = 32)

Create an instance of the class, with the SCLK, DATA, D/C, CS and RST inputs connected to the specified GPIO pins. By default, the height of the display is assumed to be 32. If the 128x64 version is used, specify the height as "64".

void SSD1306::begin()

Initialize the device.

void SSD1306::command(uint8_t c)

Send the specified command to the device.

void SSD1306::data(uint8_t c)

Send the specified data to the device.

Limitations

None.

Example

BeagleBone::SSD1306 drv(BeagleBone::gpio::P8(46),  // CLK
                        BeagleBone::gpio::P8(44),  // DIN
                        BeagleBone::gpio::P8(42),  // D/C
                        BeagleBone::gpio::P8(40),  // CS
                        BeagleBone::gpio::P8(38)); // RST
drv.begin();
drv.clear();
drv.refresh();
// Draw a vertical line across the display
for (int x = 0; x < drv.get_width(); x++) {
  drv.drawPixel(x, 5, BeagleBone::RGB::black);
}
drv.refresh();

Related

Wiki: C++ User Documentation
Wiki: gpio.hpp
Wiki: rgb_driver.hpp

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.