Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions lib/delux/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
[] -> []
Expand All @@ -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