oled v0.3.1 OLED.Display behaviour View Source

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:

  • :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

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 display buffer.

Get display dimensions

Draw an horizontal line (speed optimized).

Draw a vertical line (speed optimized).

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

Clear the buffer.

Link to this callback

clear(pixel_state)

View Source
clear(pixel_state :: OLED.Display.Server.pixel_state()) :: :ok

Clear the buffer putting all the pixels on certain state.

Link to this callback

display()

View Source
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
display_frame(
  data :: binary(),
  opts :: OLED.Display.Server.display_frame_opts()
) :: :ok

Transfer a data frame to the display buffer.

Link to this callback

get_dimensions()

View Source
get_dimensions() ::
  {:ok, width :: integer(), height :: integer()} | {:error, term()}

Get display dimensions

Link to this callback

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

View Source
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
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
line_v(
  x :: integer(),
  y :: integer(),
  height :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Draw a vertical line (speed optimized).

Link to this callback

put_pixel(x, y, opts)

View Source
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
rect(
  x :: integer(),
  y :: integer(),
  width :: integer(),
  height :: integer(),
  opts :: OLED.Display.Server.pixel_opts()
) :: :ok

Draw a rect