View Source OLED.Display behaviour (oled v0.3.6)

Defines a display module

When used, the displaly expects an :app as option. The :app should be the app that has the configuration.

Example:

defmodule MyApp.MyDisplay do
  use OLED.Display, app: :my_app
end

Could be configured with:

config :my_app, MyApp.MyDisplay,
  width: 128,
  height: 64,
  driver: :ssd1306,
  type: :spi,
  device: "spidev0.0",
  rst_pin: 25,
  dc_pin: 24

configuration

Configuration:

  • :driver - For now only :ssd1306 is available

  • :type - Type of connection: (i.e.: :spi, :i2c)

  • :width - Display width

  • :height - Display height

  • :rst_pin - GPIO for RESET pin

  • :dc_pin - GPIO for DC pin

Link to this section Summary

Callbacks

Draw a circle

Clear the buffer.

Clear the buffer putting all the pixels on certain state.

Transfer the display buffer to the screen. You MUST call display() after drawing commands to make them visible on screen.

Transfer a data frame to the screen. The data frame format is equal to the display buffer that gets altered via the drawing commands.

Transfer a raw data frame to the screen.

Get the current buffer which is the internal data structure that is changed by the draw methods and sent to the screen with display/0.

Get display dimensions

Draw an horizontal line (speed optimized).

Draw a vertical line (speed optimized).

Override the current buffer which is the internal data structure that is sent to the screen with display/0.

Put a pixel on the buffer. The pixel can be on or off and be drawed in xor mode (if the pixel is already on is turned off).

Link to this section Callbacks

@callback circle(
  x0 :: integer(),
  y0 :: integer(),
  r :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Draw a circle

Origin (x0, y0) with radius r.

@callback clear() :: :ok

Clear the buffer.

@callback clear(pixel_state :: OLED.Display.Server.pixel_state()) :: :ok

Clear the buffer putting all the pixels on certain state.

@callback display() :: :ok

Transfer the display buffer to the screen. You MUST call display() after drawing commands to make them visible on screen.

Link to this callback

display_frame(data, opts)

View Source
@callback display_frame(
  data :: binary(),
  opts :: OLED.Display.Server.display_frame_opts()
) :: :ok

Transfer a data frame to the screen. The data frame format is equal to the display buffer that gets altered via the drawing commands.

Calling this function transfers the data frame directly to the screen and does not alter the display buffer.

Link to this callback

display_raw_frame(data, opts)

View Source
@callback display_raw_frame(
  data :: binary(),
  opts :: OLED.Display.Server.display_frame_opts()
) :: :ok

Transfer a raw data frame to the screen.

A raw data frame is in a different format than the display buffer. To transform a display buffer to a raw data frame, OLED.Display.Impl.SSD1306.translate_buffer/3 can be used.

Link to this callback

fill_rect(x, y, width, height, opts)

View Source
@callback fill_rect(
  x :: integer(),
  y :: integer(),
  width :: integer(),
  height :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Draw a filled rect

@callback get_buffer() :: {:ok, binary()}

Get the current buffer which is the internal data structure that is changed by the draw methods and sent to the screen with display/0.

@callback get_dimensions() ::
  {:ok, width :: integer(), height :: integer()} | {:error, term()}

Get display dimensions

Link to this callback

line(x1, y1, x2, y2, opts)

View Source
@callback line(
  x1 :: integer(),
  y1 :: integer(),
  x2 :: integer(),
  y2 :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Draw a line.

Link to this callback

line_h(x, y, width, opts)

View Source
@callback line_h(
  x :: integer(),
  y :: integer(),
  width :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Draw an horizontal line (speed optimized).

Link to this callback

line_v(x, y, height, opts)

View Source
@callback line_v(
  x :: integer(),
  y :: integer(),
  height :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Draw a vertical line (speed optimized).

@callback put_buffer(data :: binary()) :: :ok | {:error, term()}

Override the current buffer which is the internal data structure that is sent to the screen with display/0.

A possible use-case is to draw some content, get the buffer via get_buffer/0 and set it again at a later time to save calls to the draw functions.

@callback put_pixel(
  x :: integer(),
  y :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Put a pixel on the buffer. The pixel can be on or off and be drawed in xor mode (if the pixel is already on is turned off).

Link to this callback

rect(x, y, width, height, opts)

View Source
@callback rect(
  x :: integer(),
  y :: integer(),
  width :: integer(),
  height :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Draw a rect