diff --git a/README.md b/README.md index d91fa0d..22e7c0e 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,23 @@ config :delux, }} ``` +For advanced configurations involving device tree overlays for GPIO-controlled LEDs, you can specify the overlays path and pins in the config.exs as follows: + +``` elixir +config :delux, :dt_overlays, + overlays_path: "/data/gpio-led.dtbo", + pins: [ + {"rgb-red0", 12}, + {"rgb-green0", 16}, + {"rgb-blue0", 21}, + {"rgb-red1", 24}, + {"rgb-green1", 25}, + {"rgb-blue1", 1} + ] +``` + +This configuration is useful for specifying custom GPIO pins for LED indicators allowing for more flexibility in custom hardware setups. This has only been tested on an rpi0 at this time. + ## Use For sake of example, let's start the `Delux` GenServer the manual way by calling diff --git a/lib/delux/application.ex b/lib/delux/application.ex index 84ba8d3..8ba8e2c 100644 --- a/lib/delux/application.ex +++ b/lib/delux/application.ex @@ -8,6 +8,8 @@ defmodule Delux.Application do # Optionally start Delux if configured in the application # environment + apply_dt_overlays() + children = case Application.get_all_env(:delux) do [] -> [] @@ -17,4 +19,13 @@ defmodule Delux.Application do opts = [strategy: :one_for_one, name: Delux.Supervisor] Supervisor.start_link(children, opts) end + + defp apply_dt_overlays() do + config = Application.get_env(:delux, :dt_overlays, []) + + Enum.each(config[:pins] || [], fn {label, pin} -> + args = [config[:overlays_path], "label=#{label}", "gpio=#{pin}"] + System.cmd("dtoverlay", args) + end) + end end