Skip to content

Commit 2e8c6a2

Browse files
pojirofhunleth
authored andcommitted
Don't call set_initial_value/2 for inputs
This fixes this warning: ``` 17:06:05.889 [warning] Ignoring write to input GPIO XX ```
1 parent 8db915a commit 2e8c6a2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/circuits_sim/gpio/backend.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ defmodule CircuitsSim.GPIO.Backend do
3434
handle = %Handle{gpio_spec: identifiers.location},
3535
:ok <- GPIOServer.set_direction(identifiers.location, direction),
3636
:ok <- set_pull_mode(identifiers.location, options[:pull_mode]),
37-
:ok <- set_initial_value(identifiers.location, options[:initial_value]) do
37+
:ok <- set_initial_value(direction, identifiers.location, options[:initial_value]) do
3838
{:ok, handle}
3939
end
4040
end
4141

4242
defp set_pull_mode(_gpio_spec, :not_set), do: :ok
4343
defp set_pull_mode(gpio_spec, pull_mode), do: GPIOServer.set_pull_mode(gpio_spec, pull_mode)
4444

45-
defp set_initial_value(_gpio_spec, :not_set), do: :ok
46-
defp set_initial_value(gpio_spec, value), do: GPIOServer.write(gpio_spec, value)
45+
defp set_initial_value(:output, gpio_spec, value), do: GPIOServer.write(gpio_spec, value)
46+
defp set_initial_value(:input, _gpio_spec, _value), do: :ok
4747

4848
@doc """
4949
Return information about this backend

0 commit comments

Comments
 (0)