ElixirALE.GPIO likes it's pin directions to end with "put".

This commit is contained in:
James Harton 2020-01-21 15:20:21 +13:00
parent 1c1ee39fea
commit 54a98adbb5
2 changed files with 2 additions and 1 deletions

View file

@ -28,6 +28,7 @@ defmodule Wafer.Driver.ElixirALE.GPIO do
def acquire(opts) when is_list(opts) do def acquire(opts) when is_list(opts) do
with {:ok, pin} when is_pin_number(pin) <- Keyword.fetch(opts, :pin), with {:ok, pin} when is_pin_number(pin) <- Keyword.fetch(opts, :pin),
direction when direction in [:in, :out] <- Keyword.get(opts, :direction, :out), direction when direction in [:in, :out] <- Keyword.get(opts, :direction, :out),
direction <- String.to_atom("#{direction}put"),
{:ok, pid} <- Wrapper.start_link(pin, direction, Keyword.drop(opts, ~w[pin direction]a)) do {:ok, pid} <- Wrapper.start_link(pin, direction, Keyword.drop(opts, ~w[pin direction]a)) do
{:ok, %__MODULE__{pid: pid, pin: pin, direction: direction}} {:ok, %__MODULE__{pid: pid, pin: pin, direction: direction}}
else else

View file

@ -13,7 +13,7 @@ defmodule WaferDriverElixirALE.GPIOTest do
Wrapper Wrapper
|> expect(:start_link, 1, fn pin, direction, opts -> |> expect(:start_link, 1, fn pin, direction, opts ->
assert pin == 1 assert pin == 1
assert direction == :out assert direction == :output
assert opts == [] assert opts == []
{:ok, self()} {:ok, self()}
end) end)