Port the frontend.
Enable ethernet connection.
This commit is contained in:
parent
08c904ba12
commit
29b952303a
9 changed files with 94 additions and 56 deletions
|
@ -2,6 +2,37 @@ defmodule UiWeb.PageController do
|
|||
use UiWeb, :controller
|
||||
|
||||
def index(conn, _params) do
|
||||
render(conn, "index.html")
|
||||
conn
|
||||
|> send_resp(201, "")
|
||||
end
|
||||
|
||||
def instructions(conn, _params) do
|
||||
conn
|
||||
|> render(:instructions)
|
||||
end
|
||||
|
||||
def morse(conn, _params) do
|
||||
conn
|
||||
|> render(:morse)
|
||||
end
|
||||
|
||||
def start(conn, _params) do
|
||||
now = System.system_time(:second)
|
||||
|
||||
case get_start_time() do
|
||||
start_time when start_time + 35 <= now ->
|
||||
System.put_env("MORSE_START_TIME", Integer.to_string(now))
|
||||
Ui.SignalMorse.signal()
|
||||
text(conn, "Done.")
|
||||
_ ->
|
||||
text(conn, "It is still in progress...")
|
||||
end
|
||||
end
|
||||
|
||||
defp get_start_time() do
|
||||
case System.get_env("MORSE_START_TIME") do
|
||||
nil -> 0
|
||||
start_time -> String.to_integer(start_time)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue