From ba50a839d263e0a14e9dca51c3d5c7859923f538 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sat, 17 Aug 2019 17:31:29 +0200 Subject: [PATCH] Fix symbol matching in signal_symbol. Remove match for undefined symbol. --- morse/lib/morse/worker.ex | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/morse/lib/morse/worker.ex b/morse/lib/morse/worker.ex index 85ef711..7821c48 100644 --- a/morse/lib/morse/worker.ex +++ b/morse/lib/morse/worker.ex @@ -22,7 +22,7 @@ defmodule Morse.Worker do code = secret_code() code_length = length(code) - update_progress(0, code_length) + update_progress(0, 100) {:ok, gpio} = GPIO.open(relay_pin(), :output) GPIO.write(gpio, @off) @@ -35,29 +35,25 @@ defmodule Morse.Worker do update_progress(100, 100) end - defp signal_symbol(gpio, {'.', _index}, _length) do + defp signal_symbol(gpio, {?., _index}, _length) do GPIO.write(gpio, @on) Process.sleep(@sleep_short) GPIO.write(gpio, @off) Process.sleep(@sleep_delay) end - defp signal_symbol(gpio, {'-', _index}, _length) do + defp signal_symbol(gpio, {?-, _index}, _length) do GPIO.write(gpio, @on) Process.sleep(@sleep_long) GPIO.write(gpio, @off) Process.sleep(@sleep_delay) end - defp signal_symbol(_gpio, {' ', index}, length) do + defp signal_symbol(_gpio, {? , index}, length) do Process.sleep(@sleep_pause) update_progress(index, length) end - defp signal_symbol(_gpio, {symbol, _index}, _length) do - {:error, "Undefined symbol: " <> <>} - end - defp update_progress(index, length) do Morse.Server.update_progress(index / length * 100) end