Add LED test
This commit is contained in:
parent
e5af29f06c
commit
94675c3dcc
1 changed files with 9 additions and 3 deletions
12
lib/test.ex
12
lib/test.ex
|
@ -9,12 +9,18 @@ defmodule ExSpeedGame.Test do
|
||||||
@impl true
|
@impl true
|
||||||
def init(_) do
|
def init(_) do
|
||||||
ExSpeedGame.Game.ButtonInput.acquire(ExSpeedGame.Game.ButtonInput)
|
ExSpeedGame.Game.ButtonInput.acquire(ExSpeedGame.Game.ButtonInput)
|
||||||
{:ok, :ok}
|
{:ok, ref} = Circuits.GPIO.open(16, :output, initial_value: 0)
|
||||||
|
{:ok, {ref, false}}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_info(msg, s) do
|
def handle_info(msg, {ref, state}) do
|
||||||
Logger.debug(inspect(msg))
|
Logger.debug(inspect(msg))
|
||||||
{:noreply, s}
|
|
||||||
|
new_state = not state
|
||||||
|
|
||||||
|
Circuits.GPIO.write(ref, if(new_state, do: 1, else: 0))
|
||||||
|
|
||||||
|
{:noreply, {ref, new_state}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue