 
   use GenServer
   require Logger
+
+  # Calculate this at runtime.
+  defp executable_path do
+    "#{:code.priv_dir(:nerves_neopixel)}/rpi_ws281x"
+  end
 
   def start_link(channel1, channel2 \\ [pin: 0, count: 0]) do
     GenServer.start_link(__MODULE__, [channel1, channel2], [name: __MODULE__])

    {:reply, :ok, s}
  end

  defp ws2811_brg(data) when is_list(data) do
    Enum.reduce(data, <<>>, fn({r, g, b}, acc) ->
      acc <> <<b :: size(8), r :: size(8), g :: size(8), 0x00 :: size(8)>>

    ch2_count = (ch2[:count] || 0)
    |> to_string


    port = Port.open({:spawn_executable, executable_path},
      [{:args, [ch1_pin, ch1_count, ch2_pin, ch2_count]},
        {:packet, 2},
        :use_stdio,
        :exit_status, # make sure that we're notified when the rpi handler process dies
        :binary])
    {:ok, %{
      port: port
