OLED is a library to manage the monochrome OLED screen based on chip SSD1306 using SPI comunication.
Graphic primitives
- Points
- Lines
- Rects
- Circles
- Polygons
- Filled Rects
- Filled Circles
- Filled Polygons
Other elements
- Binarized images (JPEG, PNG)
1. edit your mix.exs
def deps do
[
{:oled, "~> 0.1.0"}
]
end2. create a display module
defmodule OledApp.MyDisplay do
use OLED.Display, app: :oled_app
end3. add the configuration
config :oled_app, OledApp.MyDisplay,
device: "spidev0.0",
driver: :ssd1306,
width: 128,
height: 64,
rst_pin: 25,
dc_pin: 244. add your application's supervision tree
defmodule OledApp.Application do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
# Add this line
OledApp.MyDisplay
]
opts = [strategy: :one_for_one, name: OledApp.Supervisor]
Supervisor.start_link(children, opts)
end
end5. use it
# Draw something
OledApp.MyDisplay.rect(0, 0, 127, 63)
OledApp.MyDisplay.line(0, 0, 127, 63)
OledApp.MyDisplay.line(0, 63, 127, 0)
# Display it!
OledApp.MyDisplay.display()