ssd1306 v0.1.1 SSD1306.Device
An individual SSD1306 device.
Each device needs it's configuration specified in your application's configuration.
Example configuration:
config :ssd1306,
devices: [
%{bus: "i2c-1", address: 0x3D, name: :display0, width: 128, height: 32}
]
Note that bus
and address
are required, width
and height
are optional
and default to 128
and 64
respectively.
name
is also optional and allows you to specify an arbitrary name to
register this device as in ssd1306
's process registry. You can then use
this name when using the public functions in this module to refer to a
specific device. If not provided then a tuple of the bus name and address
will be used, for example the device above would be named {"i2c-1", 0x3D}
if
the name
value had not been set.
Link to this section Summary
Functions
Turn off all pixels of the attached device.
Turn on all pixels of the attached device.
Returns a specification to start this module under a supervisor.
Send the contents of buffer
to the device for display.
Send arbitrary commands to the device.
Link to this section Types
Link to this section Functions
Turn off all pixels of the attached device.
Turn on all pixels of the attached device.
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
display(device_name, buffer)
display(device_name(), buffer()) :: :ok | {:error, term()}
Send the contents of buffer
to the device for display.
Send arbitrary commands to the device.
This is useful for any advanced usage that doesn't involve just sending a buffer to the display.
The function
argument is a function which will be called from within the
device process with the PID of the I2C connection as it's only argument. Be
aware that if this function takes a while to execute the device will be unable
to respond to other messages.
The commands are listed in the [SSD1306.Commands] module, and information about them can be found in the SSD1306 Datasheet.
Example
To invert the display.
iex> alias SSD1306.{Device, Commands}
...> Device.commands({"i2c-1", 0x3D}, fn pid -> Commands.invert_display!(pid) end)
:ok