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
endCould 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:ssd1306is 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.
Draw a filled rect
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 a line.
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).
Draw a rect
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.
@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.
@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.
@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.
Get display dimensions
@callback line( x1 :: integer(), y1 :: integer(), x2 :: integer(), y2 :: integer(), opts :: OLED.Display.Server.pixel_opts() ) :: :ok
Draw a line.
@callback line_h( x :: integer(), y :: integer(), width :: integer(), opts :: OLED.Display.Server.pixel_opts() ) :: :ok
Draw an horizontal line (speed optimized).
@callback line_v( x :: integer(), y :: integer(), height :: integer(), opts :: OLED.Display.Server.pixel_opts() ) :: :ok
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.
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).
@callback rect( x :: integer(), y :: integer(), width :: integer(), height :: integer(), opts :: OLED.Display.Server.pixel_opts() ) :: :ok
Draw a rect