Skip to content

Commit

Permalink
Fix error propagation on display initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
luisgabrielroldan committed Mar 6, 2020
1 parent 4771f44 commit 5f889e7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/oled/display/impl/ssd_1306.ex
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ defmodule OLED.Display.Impl.SSD1306 do
|> command([@ssd1306_displayon])
end

def display(%__MODULE__{} = state, opts \\ []) do
def display(state, opts \\ [])

def display(%__MODULE__{} = state, opts) do
%{buffer: buffer, width: width} = state
opts = Keyword.merge(@display_opts, opts)

Expand All @@ -130,6 +132,9 @@ defmodule OLED.Display.Impl.SSD1306 do
display_frame(state, buffer, opts)
end

def display(error, _opts),
do: error

defp translate_buffer(buffer, width, :horizontal) do
for <<page::binary-size(width) <- buffer>> do
for(<<b::1 <- page>>, do: b)
Expand Down Expand Up @@ -179,6 +184,9 @@ defmodule OLED.Display.Impl.SSD1306 do
%{state | buffer: buffer}
end

def clear_buffer(error, _pixel_state),
do: error

def get_dimensions(%__MODULE__{width: width, height: height}),
do: {:ok, width, height}

Expand Down

0 comments on commit 5f889e7

Please sign in to comment.