Update led workers

pull/576/head
connor rigby 2018-07-10 14:48:16 -07:00 committed by Connor Rigby
parent 93c324d151
commit 40a2c4b00c
16 changed files with 91 additions and 211 deletions

View File

@ -5,7 +5,4 @@ known_formatted_files =
|> Enum.map(&String.trim(&1)) |> Enum.map(&String.trim(&1))
|> List.delete("") |> List.delete("")
[ [inputs: ["mix.exs", ".formatter.exs"] ++ known_formatted_files]
inputs: ["mix.exs", ".formatter.exs"] ++ known_formatted_files,
line_length: 80
]

View File

@ -20,6 +20,8 @@ config :farmbot, ecto_repos: [Farmbot.Repo, Farmbot.System.ConfigStorage]
# Configure your our init system. # Configure your our init system.
config :farmbot, :init, [ config :farmbot, :init, [
Farmbot.Target.Leds.AleHandler,
# Autodetects if a Arduino is plugged in and configures accordingly. # Autodetects if a Arduino is plugged in and configures accordingly.
Farmbot.Firmware.UartHandler.AutoDetector, Farmbot.Firmware.UartHandler.AutoDetector,
@ -44,8 +46,6 @@ config :farmbot, :init, [
# Debug stuff # Debug stuff
Farmbot.System.Debug, Farmbot.System.Debug,
Farmbot.Target.Uevent.Supervisor, Farmbot.Target.Uevent.Supervisor,
Farmbot.Target.Leds.AleHandler
] ]
config :farmbot, :transport, [ config :farmbot, :transport, [

View File

@ -20,6 +20,8 @@ config :farmbot, ecto_repos: [Farmbot.Repo, Farmbot.System.ConfigStorage]
# Configure your our init system. # Configure your our init system.
config :farmbot, :init, [ config :farmbot, :init, [
Farmbot.Target.Leds.AleHandler,
# Autodetects if a Arduino is plugged in and configures accordingly. # Autodetects if a Arduino is plugged in and configures accordingly.
Farmbot.Firmware.UartHandler.AutoDetector, Farmbot.Firmware.UartHandler.AutoDetector,
@ -42,8 +44,6 @@ config :farmbot, :init, [
# Helps with hot plugging of serial devices. # Helps with hot plugging of serial devices.
Farmbot.Target.Uevent.Supervisor, Farmbot.Target.Uevent.Supervisor,
Farmbot.Target.Leds.AleHandler
] ]
config :farmbot, :transport, [ config :farmbot, :transport, [

View File

@ -72,8 +72,7 @@ defmodule Farmbot.Asset.FarmEvent do
|> elem(1) |> elem(1)
|> DateTime.to_unix(:second) |> DateTime.to_unix(:second)
end_time_seconds = end_time_seconds = DateTime.from_iso8601(fe.end_time) |> elem(1) |> DateTime.to_unix(:second)
DateTime.from_iso8601(fe.end_time) |> elem(1) |> DateTime.to_unix(:second)
repeat = fe.repeat repeat = fe.repeat
repeat_frequency_seconds = time_unit_to_seconds(fe.time_unit) repeat_frequency_seconds = time_unit_to_seconds(fe.time_unit)

View File

@ -1,31 +1,24 @@
defmodule Farmbot.BotState.LedWorker do defmodule Farmbot.BotState.LedWorker do
@moduledoc "Flashes leds based on connection status." @moduledoc "Flashes leds based on connection status."
use GenServer use GenServer
alias Farmbot.System.Registry, as: FBR
def start_link(args \\ []) do def start_link(args \\ []) do
GenServer.start_link(__MODULE__, args, name: __MODULE__) GenServer.start_link(__MODULE__, args, name: __MODULE__)
end end
def init([]) do def init([]) do
Farmbot.System.Registry.subscribe(self()) FBR.subscribe(self())
Farmbot.Leds.blue(:off) Farmbot.Leds.blue(:off)
{:ok, %{}} {:ok, %{}}
end end
def handle_info( def handle_info({FBR, {:bot_state, %{informational_settings: %{connected: true}}}}, state) do
:bot_state,
%{informational_settings: %{connected: true}},
state
) do
Farmbot.Leds.blue(:solid) Farmbot.Leds.blue(:solid)
{:noreply, state} {:noreply, state}
end end
def handle_info( def handle_info({FBR, {:bot_state, %{informational_settings: %{connected: false}}}}, state) do
:bot_state,
%{informational_settings: %{connected: false}},
state
) do
Farmbot.Leds.blue(:off) Farmbot.Leds.blue(:off)
{:noreply, state} {:noreply, state}
end end

View File

@ -166,10 +166,7 @@ defmodule Farmbot.FarmEvent.Manager do
schedule_events(late_executables, now) schedule_events(late_executables, now)
end end
exit( exit({:success, %{new | events: Map.new(all_events, fn event -> {event.id, event} end)}})
{:success,
%{new | events: Map.new(all_events, fn event -> {event.id, event} end)}}
)
end end
defp do_checkup(list, time, late_events \\ [], state) defp do_checkup(list, time, late_events \\ [], state)
@ -184,8 +181,7 @@ defmodule Farmbot.FarmEvent.Manager do
# update state. # update state.
new_state = %{ new_state = %{
state state
| last_time_index: | last_time_index: Map.put(state.last_time_index, farm_event.id, last_time)
Map.put(state.last_time_index, farm_event.id, last_time)
} }
case new_late_executable do case new_late_executable do
@ -267,9 +263,7 @@ defmodule Farmbot.FarmEvent.Manager do
event, event,
_now _now
) do ) do
maybe_farm_event_log( maybe_farm_event_log("regimen #{event.name} (#{event.id}) should already be scheduled.")
"regimen #{event.name} (#{event.id}) should already be scheduled."
)
{nil, last_time} {nil, last_time}
end end
@ -282,9 +276,9 @@ defmodule Farmbot.FarmEvent.Manager do
_ _
) do ) do
maybe_farm_event_log( maybe_farm_event_log(
"regimen #{event.name} (#{event.id}) is not scheduled yet. (#{ "regimen #{event.name} (#{event.id}) is not scheduled yet. (#{inspect(schedule_time)}) (#{
inspect(schedule_time) inspect(Timex.now())
}) (#{inspect(Timex.now())})" })"
) )
{nil, last_time} {nil, last_time}
@ -323,8 +317,7 @@ defmodule Farmbot.FarmEvent.Manager do
event, event,
now now
) do ) do
{run?, next_time} = {run?, next_time} = should_run_sequence?(farm_event.calendar, last_time, now)
should_run_sequence?(farm_event.calendar, last_time, now)
case run? do case run? do
true -> {event, next_time} true -> {event, next_time}
@ -359,9 +352,7 @@ defmodule Farmbot.FarmEvent.Manager do
event, event,
_now _now
) do ) do
maybe_farm_event_log( maybe_farm_event_log("sequence #{event.name} (#{event.id}) is not scheduled yet.")
"sequence #{event.name} (#{event.id}) is not scheduled yet."
)
{nil, last_time} {nil, last_time}
end end
@ -384,9 +375,7 @@ defmodule Farmbot.FarmEvent.Manager do
# if there is no last time, check if time is passed now within 60 seconds. # if there is no last time, check if time is passed now within 60 seconds.
defp should_run_sequence?([first_time | _], nil, now) do defp should_run_sequence?([first_time | _], nil, now) do
maybe_farm_event_log( maybe_farm_event_log("Checking sequence event that hasn't run before #{first_time}")
"Checking sequence event that hasn't run before #{first_time}"
)
# convert the first_time to a DateTime # convert the first_time to a DateTime
dt = Timex.parse!(first_time, "{ISO:Extended}") dt = Timex.parse!(first_time, "{ISO:Extended}")

View File

@ -1,27 +1,24 @@
defmodule Farmbot.Firmware.LedWorker do defmodule Farmbot.Firmware.LedWorker do
@moduledoc "Flashes leds based on e-stop status." @moduledoc "Flashes leds based on e-stop status."
use GenServer use GenServer
alias Farmbot.System.Registry, as: FBR
def start_link(args \\ []) do def start_link(args \\ []) do
GenServer.start_link(__MODULE__, args, name: __MODULE__) GenServer.start_link(__MODULE__, args, name: __MODULE__)
end end
def init([]) do def init([]) do
Farmbot.System.Registry.subscribe(self()) FBR.subscribe(self())
Farmbot.Leds.red(:solid) Farmbot.Leds.red(:solid)
{:ok, %{}} {:ok, %{}}
end end
def handle_info(:bot_state, %{informational_settings: %{locked: true}}, state) do def handle_info({FBR, {:bot_state, %{informational_settings: %{locked: true}}}}, state) do
Farmbot.Leds.yellow(:slow_blink) Farmbot.Leds.yellow(:slow_blink)
{:noreply, state} {:noreply, state}
end end
def handle_info( def handle_info({FBR, {:bot_state, %{informational_settings: %{locked: false}}}}, state) do
:bot_state,
%{informational_settings: %{locked: false}},
state
) do
Farmbot.Leds.yellow(:off) Farmbot.Leds.yellow(:off)
{:noreply, state} {:noreply, state}
end end

View File

@ -10,4 +10,7 @@ defmodule Farmbot.Leds.Handler do
@callback yellow(status) :: any @callback yellow(status) :: any
@callback white1(status) :: any @callback white1(status) :: any
@callback white2(status) :: any @callback white2(status) :: any
@callback white3(status) :: any
@callback white4(status) :: any
@callback white5(status) :: any
end end

View File

@ -5,27 +5,13 @@ defmodule Farmbot.Leds do
@valid_status [:off, :solid, :slow_blink, :fast_blink] @valid_status [:off, :solid, :slow_blink, :fast_blink]
def red(status) when status in @valid_status do def red(status) when status in @valid_status, do: @led_handler.red(status)
@led_handler.red(status) def blue(status) when status in @valid_status, do: @led_handler.blue(status)
end def green(status) when status in @valid_status, do: @led_handler.green(status)
def yellow(status) when status in @valid_status, do: @led_handler.yellow(status)
def blue(status) when status in @valid_status do def white1(status) when status in @valid_status, do: @led_handler.white1(status)
@led_handler.blue(status) def white2(status) when status in @valid_status, do: @led_handler.white2(status)
end def white3(status) when status in @valid_status, do: @led_handler.white3(status)
def white4(status) when status in @valid_status, do: @led_handler.white4(status)
def green(status) when status in @valid_status do def white5(status) when status in @valid_status, do: @led_handler.white5(status)
@led_handler.green(status)
end
def yellow(status) when status in @valid_status do
@led_handler.yellow(status)
end
def white1(status) when status in @valid_status do
@led_handler.white1(status)
end
def white2(status) when status in @valid_status do
@led_handler.white2(status)
end
end end

View File

@ -4,39 +4,25 @@ defmodule Farmbot.Leds.StubHandler do
@behaviour Farmbot.Leds.Handler @behaviour Farmbot.Leds.Handler
def red(status) do def red(status), do: do_debug(:red, status)
do_debug(:red, status) def blue(status), do: do_debug(:blue, status)
end def green(status), do: do_debug(:green, status)
def yellow(status), do: do_debug(:yellow, status)
def blue(status) do def white1(status), do: do_debug(:white, status)
do_debug(:blue, status) def white2(status), do: do_debug(:white, status)
end def white3(status), do: do_debug(:white, status)
def white4(status), do: do_debug(:white, status)
def green(status) do def white5(status), do: do_debug(:white, status)
do_debug(:green, status)
end
def yellow(status) do
do_debug(:yellow, status)
end
def white1(status) do
do_debug(:white, status)
end
def white2(status) do
do_debug(:white, status)
end
defp do_debug(color, status) do defp do_debug(color, status) do
msg = ["LED STATUS: ", msg = [IO.ANSI.reset(), "LED STATUS: ",
apply(IO.ANSI, color, []), apply(IO.ANSI, color, []),
status_in(status), status_in(status),
to_string(color), to_string(color),
" ", " ",
to_string(status), to_string(status),
status_out(status), status_out(status),
IO.ANSI.normal() IO.ANSI.reset()
] ]
IO.puts(msg) IO.puts(msg)
end end

View File

@ -1,48 +1,28 @@
defmodule Farmbot.Repo.LedWorker do defmodule Farmbot.Repo.LedWorker do
@moduledoc "Flashes leds based on sync status." @moduledoc "Flashes leds based on sync status."
use GenServer use GenServer
alias Farmbot.System.Registry, as: FBR
def start_link(args \\ []) do def start_link(args \\ []) do
GenServer.start_link(__MODULE__, args, name: __MODULE__) GenServer.start_link(__MODULE__, args, name: __MODULE__)
end end
def init([]) do def init([]) do
Farmbot.System.Registry.subscribe(self()) FBR.subscribe(self())
{:ok, %{}} {:ok, %{}}
end end
def handle_info( def handle_info({FBR, {:bot_state, %{informational_settings: %{sync_status: :syncing}}}}, state) do
:bot_state,
%{informational_settings: %{sync_status: :sync_now}},
state
) do
Farmbot.Leds.green(:slow_blink)
{:noreply, state}
end
def handle_info(
:bot_state,
%{informational_settings: %{sync_status: :syncing}},
state
) do
Farmbot.Leds.green(:fast_blink) Farmbot.Leds.green(:fast_blink)
{:noreply, state} {:noreply, state}
end end
def handle_info( def handle_info({FBR, {:bot_state, %{informational_settings: %{sync_status: :synced}}}}, state) do
:bot_state,
%{informational_settings: %{sync_status: :synced}},
state
) do
Farmbot.Leds.green(:solid) Farmbot.Leds.green(:solid)
{:noreply, state} {:noreply, state}
end end
def handle_info( def handle_info({FBR, {:bot_state, %{informational_settings: %{sync_status: _}}}}, state) do
:bot_state,
%{informational_settings: %{sync_status: :sync_error}},
state
) do
Farmbot.Leds.green(:slow_blink) Farmbot.Leds.green(:slow_blink)
{:noreply, state} {:noreply, state}
end end

View File

@ -70,8 +70,7 @@ defmodule Farmbot.Repo.Worker do
syncing: true syncing: true
})} })}
else else
{:ok, {:ok, struct(State, %{stability_timer: stability_timer, requires_full: true})}
struct(State, %{stability_timer: stability_timer, requires_full: true})}
end end
end end
@ -100,8 +99,7 @@ defmodule Farmbot.Repo.Worker do
pid = spawn(Farmbot.Repo, :fragment_sync, [verbosity]) pid = spawn(Farmbot.Repo, :fragment_sync, [verbosity])
ref = Process.monitor(pid) ref = Process.monitor(pid)
timer = timer = refresh_or_start_sync_timeout(state.sync_timer, timeout_ms, ref, self())
refresh_or_start_sync_timeout(state.sync_timer, timeout_ms, ref, self())
set_sync_status(:syncing) set_sync_status(:syncing)
@ -124,8 +122,7 @@ defmodule Farmbot.Repo.Worker do
pid = spawn(Farmbot.Repo, :full_sync, [verbosity]) pid = spawn(Farmbot.Repo, :full_sync, [verbosity])
ref = Process.monitor(pid) ref = Process.monitor(pid)
timer = timer = refresh_or_start_sync_timeout(state.sync_timer, timeout_ms, ref, self())
refresh_or_start_sync_timeout(state.sync_timer, timeout_ms, ref, self())
set_sync_status(:syncing) set_sync_status(:syncing)
@ -173,8 +170,7 @@ defmodule Farmbot.Repo.Worker do
%{ %{
state state
| requires_full: true, | requires_full: true,
stability_timer: stability_timer: refresh_or_start_stability_timeout(state.stability_timer, self())
refresh_or_start_stability_timeout(state.stability_timer, self())
}} }}
end end

View File

@ -84,8 +84,7 @@ defmodule Farmbot.Mixfile do
case System.get_env("ERL_EI_INCLUDE_DIR") do case System.get_env("ERL_EI_INCLUDE_DIR") do
nil -> nil ->
%{ %{
"ERL_EI_INCLUDE_DIR" => "ERL_EI_INCLUDE_DIR" => Path.join([:code.root_dir(), "usr", "include"]),
Path.join([:code.root_dir(), "usr", "include"]),
"ERL_EI_LIBDIR" => Path.join([:code.root_dir(), "usr", "lib"]), "ERL_EI_LIBDIR" => Path.join([:code.root_dir(), "usr", "lib"]),
"MIX_TARGET" => @target "MIX_TARGET" => @target
} }
@ -111,8 +110,7 @@ defmodule Farmbot.Mixfile do
{:nerves_leds, "~> 0.8"}, {:nerves_leds, "~> 0.8"},
{:cowboy, "~> 2.0"}, {:cowboy, "~> 2.0"},
{:plug, "~> 1.6"}, {:plug, "~> 1.6"},
{:ranch_proxy_protocol, {:ranch_proxy_protocol, github: "heroku/ranch_proxy_protocol", override: true},
github: "heroku/ranch_proxy_protocol", override: true},
{:cors_plug, "~> 1.5"}, {:cors_plug, "~> 1.5"},
{:rsa, "~> 0.0.1"}, {:rsa, "~> 0.0.1"},
{:joken, "~> 1.5"}, {:joken, "~> 1.5"},
@ -148,8 +146,7 @@ defmodule Farmbot.Mixfile do
{:nerves_firmware, "~> 0.4"}, {:nerves_firmware, "~> 0.4"},
{:nerves_init_gadget, "~> 0.4.0", only: :dev}, {:nerves_init_gadget, "~> 0.4.0", only: :dev},
{:nerves_network, "~> 0.3"}, {:nerves_network, "~> 0.3"},
{:nerves_wpa_supplicant, {:nerves_wpa_supplicant, github: "nerves-project/nerves_wpa_supplicant", override: true},
github: "nerves-project/nerves_wpa_supplicant", override: true},
{:dhcp_server, "~> 0.4.0"}, {:dhcp_server, "~> 0.4.0"},
{:elixir_ale, "~> 1.0"}, {:elixir_ale, "~> 1.0"},
{:mdns, "~> 1.0"} {:mdns, "~> 1.0"}

View File

@ -47,6 +47,7 @@ defmodule Farmbot.Target.Bootstrap.Configurator.CaptivePortal do
wpa_pid = wait_for_wpa() wpa_pid = wait_for_wpa()
Nerves.WpaSupplicant.request(wpa_pid, {:AP_SCAN, 2}) Nerves.WpaSupplicant.request(wpa_pid, {:AP_SCAN, 2})
Farmbot.Leds.blue(:slow_blink)
{:ok, %{dhcp_server: dhcp_server, dnsmasq: dnsmasq}} {:ok, %{dhcp_server: dhcp_server, dnsmasq: dnsmasq}}
end end

View File

@ -8,29 +8,15 @@ defmodule Farmbot.Target.Leds.AleHandler do
# @valid_status [:off, :solid, :slow_blink, :fast_blink] # @valid_status [:off, :solid, :slow_blink, :fast_blink]
@moduledoc false @moduledoc false
def red(status) do def red(status), do: GenServer.call(__MODULE__, {:red, status})
GenServer.call(__MODULE__, {:red, status}) def blue(status), do: GenServer.call(__MODULE__, {:blue, status})
end def green(status), do: GenServer.call(__MODULE__, {:green, status})
def yellow(status), do: GenServer.call(__MODULE__, {:yellow, status})
def blue(status) do def white1(status), do: GenServer.call(__MODULE__, {:white1, status})
GenServer.call(__MODULE__, {:blue, status}) def white2(status), do: GenServer.call(__MODULE__, {:white2, status})
end def white3(status), do: GenServer.call(__MODULE__, {:white3, status})
def white4(status), do: GenServer.call(__MODULE__, {:white4, status})
def green(status) do def white5(status), do: GenServer.call(__MODULE__, {:white5, status})
GenServer.call(__MODULE__, {:green, status})
end
def yellow(status) do
GenServer.call(__MODULE__, {:yellow, status})
end
def white1(status) do
GenServer.call(__MODULE__, {:white1, status})
end
def white2(status) do
GenServer.call(__MODULE__, {:white2, status})
end
use GenServer use GenServer
@ -39,8 +25,10 @@ defmodule Farmbot.Target.Leds.AleHandler do
end end
def init([]) do def init([]) do
leds = [:red, :blue, :green, :yellow, :white1, :white2, :white3, :white4, :white5]
state = state =
Map.new([:red, :blue, :green, :yellow, :white1, :white2], fn color -> Map.new(leds, fn color ->
{:ok, pid} = GPIO.start_link(color_to_pin(color), :output) {:ok, pid} = GPIO.start_link(color_to_pin(color), :output)
:ok = GPIO.write(pid, 0) :ok = GPIO.write(pid, 0)
{color, %{pid: pid, status: :off, blink_timer: nil, state: 0}} {color, %{pid: pid, status: :off, blink_timer: nil, state: 0}}
@ -54,10 +42,7 @@ defmodule Farmbot.Target.Leds.AleHandler do
:ok = cancel_timer(state[color].blink_timer) :ok = cancel_timer(state[color].blink_timer)
{:reply, :ok, {:reply, :ok,
%{ update_color(state, color, %{state[color] | state: 0, blink_timer: nil, status: :off})}
state
| color => %{state[color] | state: 0, blink_timer: nil, status: :off}
}}
end end
def handle_call({color, :solid}, _from, state) do def handle_call({color, :solid}, _from, state) do
@ -65,30 +50,21 @@ defmodule Farmbot.Target.Leds.AleHandler do
:ok = cancel_timer(state[color].blink_timer) :ok = cancel_timer(state[color].blink_timer)
{:reply, :ok, {:reply, :ok,
%{ update_color(state, color, %{state[color] | state: 1, blink_timer: nil, status: :off})}
state
| color => %{state[color] | state: 1, blink_timer: nil, status: :solid}
}}
end end
def handle_call({color, :slow_blink}, _from, state) do def handle_call({color, :slow_blink}, _from, state) do
timer = restart_timer(state[color].blink_timer, color, @slow_blink_speed) timer = restart_timer(state[color].blink_timer, color, @slow_blink_speed)
{:reply, :ok, {:reply, :ok,
%{ update_color(state, color, %{state[color] | blink_timer: timer, status: :slow_blink})}
state
| color => %{state[color] | blink_timer: timer, status: :slow_blink}
}}
end end
def handle_call({color, :fast_blink}, _from, state) do def handle_call({color, :fast_blink}, _from, state) do
timer = restart_timer(state[color].blink_timer, color, @fast_blink_speed) timer = restart_timer(state[color].blink_timer, color, @fast_blink_speed)
{:reply, :ok, {:reply, :ok,
%{ update_color(state, color, %{state[color] | blink_timer: timer, status: :slow_blink})}
state
| color => %{state[color] | blink_timer: timer, status: :fast_blink}
}}
end end
def handle_info({:blink_timer, color}, state) do def handle_info({:blink_timer, color}, state) do
@ -98,32 +74,14 @@ defmodule Farmbot.Target.Leds.AleHandler do
new_state = new_state =
case state[color] do case state[color] do
%{status: :slow_blink} -> %{status: :slow_blink} ->
timer = timer = restart_timer(state[color].blink_timer, color, @slow_blink_speed)
restart_timer(state[color].blink_timer, color, @slow_blink_speed) n = %{state[color] | state: new_led_state, blink_timer: timer, status: :slow_blink}
update_color(state, color, n)
%{
state
| color => %{
state[color]
| state: new_led_state,
blink_timer: timer,
status: :slow_blink
}
}
%{status: :fast_blink} -> %{status: :fast_blink} ->
timer = timer = restart_timer(state[color].blink_timer, color, @fast_blink_speed)
restart_timer(state[color].blink_timer, color, @fast_blink_speed) n = %{state[color] | state: new_led_state, blink_timer: timer, status: :fast_blink}
update_color(state, color, n)
%{
state
| color => %{
state[color]
| state: new_led_state,
blink_timer: timer,
status: :fast_blink
}
}
end end
{:noreply, new_state} {:noreply, new_state}
@ -133,8 +91,11 @@ defmodule Farmbot.Target.Leds.AleHandler do
defp color_to_pin(:yellow), do: 23 defp color_to_pin(:yellow), do: 23
defp color_to_pin(:green), do: 24 defp color_to_pin(:green), do: 24
defp color_to_pin(:blue), do: 25 defp color_to_pin(:blue), do: 25
defp color_to_pin(:white1), do: 12 defp color_to_pin(:white1), do: 27
defp color_to_pin(:white2), do: 13 defp color_to_pin(:white2), do: 6
defp color_to_pin(:white3), do: 21
defp color_to_pin(:white4), do: 12
defp color_to_pin(:white5), do: 13
defp cancel_timer(nil), do: :ok defp cancel_timer(nil), do: :ok
@ -150,12 +111,8 @@ defmodule Farmbot.Target.Leds.AleHandler do
defp invert(0), do: 1 defp invert(0), do: 1
defp invert(1), do: 0 defp invert(1), do: 0
defp update_color(state, color, new_color) do
%{state | color => new_color}
end
end end
{:ok, h} =
Farmbot.Target.Leds.AleHandler.start_link(
[],
name: Farmbot.Target.Leds.AleHandler
)
Farmbot.Target.Leds.AleHandler.yellow(:solid)

View File

@ -31,8 +31,7 @@ defmodule Farmbot.Target.PinBinding.AleHandler do
end end
def init([]) do def init([]) do
{:producer, struct(State, pins: %{}), {:producer, struct(State, pins: %{}), [dispatcher: GenStage.BroadcastDispatcher]}
[dispatcher: GenStage.BroadcastDispatcher]}
end end
def handle_demand(_amnt, state) do def handle_demand(_amnt, state) do