Overview

SSD1351 is a 16-bits color OLED driver.

SSD1351

You can get OLED displays from belows:

Usage

You can use SPI interface for SSD1351 driver.

Wiring (SPI)

Here is a wiring example for SPI0 of Kameleon Core.

SSD1351 (OLED) Kameleon Core
3V3 3V3
GND GND
DATA 12 (SPI0-MOSI)
CLK 10 (SPI0 CLK)
D/C 8
RST 9
CS 17

Initialization

You can initialize SSD1351 driver using SPI interface as below:

var SSD1351 = require('@niklauslee/ssd1351').SSD1351;
var SPI = require('spi').SPI;

var spi0 = new SPI(0);
var dc = 8;
var rst = 9;
var cs = 17;
var width = 128;
var height = 64;

var ssd1351 = new SSD1351(width, height, spi0, dc, {
  rstPin: rst,
  csPin: cs
});

// graphic context
var gc = ssd1351.getContext();
gc.drawRect(0, 0, width, height);
...

Use BufferedGraphicsContext

You can use BufferedGraphicsContext instead of general callback-based graphics context as below:

// buffered graphic context
var gc = ssd1351.getContext('buffer');
gc.drawRect(0, 0, width, height);
gc.display(); // must call if buffered graphic context
...

Note that BufferedGraphicsContext allocates a lot of memory (32KB for 128x128 resolution). You cannot use memory enough for you other codes.

API

Class: SSD1351

A class for SSD1351 driver communicating with SPI interface.

new SSD1351(width, height, spi, dcPin[, options])

  • width <number> Width of display in pixels.
  • height <number> Height of display in pixels.
  • spi <SPI> An instance of SPI to communicate.
  • dcPin <number> Pin number for DC.
  • options <object> Options for initialization.
    • rstPin <number> Pin number for RST (Reset).
    • csPin <number> Pin number of CS (Chip select).
    • extVcc <boolean> Indicate whether to use external VCC. Default: false.
    • rotation <number> Rotation of screen. One of 0 (0 degree), 1 (90 degree in clockwise), 2 (180 degree in clockwise), and 3 (270 degree in clockwise). Default: 0.

Create an instance of SSD1351 driver for SPI interface.

ssd1351.getContext([type])

  • type: Optional. Type of graphic context. If "buffer" is given, BufferedGraphicContext is returned.
  • Returns: <GraphicContext> An instance of graphic context for SSD1351.

Get a graphic context.

Note that BufferedGraphicContext is much faster, but it consumes memory a lot.

Note that gc.getPixel(x, y) function is supported only if BufferedGraphicsContext.

Examples

  • ex_128x128.js (128x128 resolution)
  • ex_128x96.js (128x96 resolution)
  • ex_buffer_128x128.js (128x128 resolution with buffered graphics context)
  • ex_buffer_128x96.js (128x96 resolution with buffered graphics context)