From b6f3779ce0b1b4b5588291cd27cb0a9cfc56f4d4 Mon Sep 17 00:00:00 2001 From: Liv Cella Date: Fri, 15 Dec 2023 16:46:32 -0700 Subject: [PATCH 1/2] Add option to configure pins --- lib/delux/application.ex | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 From fcd5477ec3079eee625c7899874f5c3335268507 Mon Sep 17 00:00:00 2001 From: Liv Cella Date: Tue, 9 Jan 2024 12:10:56 -0700 Subject: [PATCH 2/2] Adds dt_overlay config instructions to README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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