Fix symbol matching in signal_symbol.
Remove match for undefined symbol.
This commit is contained in:
parent
4fcba648fe
commit
ba50a839d2
1 changed files with 4 additions and 8 deletions
|
@ -22,7 +22,7 @@ defmodule Morse.Worker do
|
||||||
code = secret_code()
|
code = secret_code()
|
||||||
code_length = length(code)
|
code_length = length(code)
|
||||||
|
|
||||||
update_progress(0, code_length)
|
update_progress(0, 100)
|
||||||
|
|
||||||
{:ok, gpio} = GPIO.open(relay_pin(), :output)
|
{:ok, gpio} = GPIO.open(relay_pin(), :output)
|
||||||
GPIO.write(gpio, @off)
|
GPIO.write(gpio, @off)
|
||||||
|
@ -35,29 +35,25 @@ defmodule Morse.Worker do
|
||||||
update_progress(100, 100)
|
update_progress(100, 100)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp signal_symbol(gpio, {'.', _index}, _length) do
|
defp signal_symbol(gpio, {?., _index}, _length) do
|
||||||
GPIO.write(gpio, @on)
|
GPIO.write(gpio, @on)
|
||||||
Process.sleep(@sleep_short)
|
Process.sleep(@sleep_short)
|
||||||
GPIO.write(gpio, @off)
|
GPIO.write(gpio, @off)
|
||||||
Process.sleep(@sleep_delay)
|
Process.sleep(@sleep_delay)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp signal_symbol(gpio, {'-', _index}, _length) do
|
defp signal_symbol(gpio, {?-, _index}, _length) do
|
||||||
GPIO.write(gpio, @on)
|
GPIO.write(gpio, @on)
|
||||||
Process.sleep(@sleep_long)
|
Process.sleep(@sleep_long)
|
||||||
GPIO.write(gpio, @off)
|
GPIO.write(gpio, @off)
|
||||||
Process.sleep(@sleep_delay)
|
Process.sleep(@sleep_delay)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp signal_symbol(_gpio, {' ', index}, length) do
|
defp signal_symbol(_gpio, {? , index}, length) do
|
||||||
Process.sleep(@sleep_pause)
|
Process.sleep(@sleep_pause)
|
||||||
update_progress(index, length)
|
update_progress(index, length)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp signal_symbol(_gpio, {symbol, _index}, _length) do
|
|
||||||
{:error, "Undefined symbol: " <> <<symbol :: utf8>>}
|
|
||||||
end
|
|
||||||
|
|
||||||
defp update_progress(index, length) do
|
defp update_progress(index, length) do
|
||||||
Morse.Server.update_progress(index / length * 100)
|
Morse.Server.update_progress(index / length * 100)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue