SSD1306

SSD1306 is an Elixir driver for SSD1306 devices like the Adafruit Monochrome 1.3” OLED display connected via I2C. It should be possible to modify this library to use the SPI interface also, because all the commands are the same, but I’m only using them via I2C. Patches welcome.

We make use of Elixir ALE, so all the caveats about installing that also apply here.

Usage

Add your devices to your config like so:

use Config

config :ssd1306,
  devices: [
    %{bus: "i2c-1", address: 0x3d, reset_pin: 17}
  ]

And start your application. Your devices will be reset, initialised with defaults and a blank buffer will be sent to them. Note that this library assumes that you have the reset pin of the device connected to a GPIO pin on the local device.

Sending images

You need to generate buffers (Erlang binaries) of widthheight 8 bytes long. We do validate that the buffer is of the correct size, but there’s no way to validate that it is of the correct geometry.

How you generate buffers is up to you, but I suggest Vivid.

Installation

If available in Hex, the package can be installed by adding SSD1306 to your list of dependencies in mix.exs:

def deps do
  [
    {:SSD1306, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/SSD1306.