Add LED test

This commit is contained in:
Mikko Ahlroth 2020-03-09 21:41:08 +02:00
parent e5af29f06c
commit 94675c3dcc

View file

@ -9,12 +9,18 @@ defmodule ExSpeedGame.Test do
@impl true
def init(_) do
ExSpeedGame.Game.ButtonInput.acquire(ExSpeedGame.Game.ButtonInput)
{:ok, :ok}
{:ok, ref} = Circuits.GPIO.open(16, :output, initial_value: 0)
{:ok, {ref, false}}
end
@impl true
def handle_info(msg, s) do
def handle_info(msg, {ref, state}) do
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