@@ -114,8 +114,14 @@ Once you feel good about the indicators and slots, it's time to configure
114114
115115## Configuration
116116
117- After adding ` delux ` to your mix dependencies, add ` Delux ` to a supervision
118- tree of your choice. The childspec looks like:
117+ After adding ` delux ` to your mix dependencies, you can either add ` Delux ` to a
118+ supervision tree of your choice or add a ` :delux ` configuration to your
119+ application environment (` config.exs ` ). The tradeoff is that having ` Delux `
120+ start itself by specifying an application config can be really convenient, but
121+ adding ` Delux ` to your supervision tree allows runtime configuration and more
122+ control over failure recovery.
123+
124+ Starting with the supervision tree approach, here's an example childspec:
119125
120126``` elixir
121127 {Delux ,
@@ -126,22 +132,30 @@ tree of your choice. The childspec looks like:
126132 }}
127133```
128134
129- The above configuration shows two indicators. The first is called ` :default `
130- and is an RGB indicator. The second is a lone red LED that's used as
131- ` :indicator2 ` . As mentioned before, if you only have one indicator, call it
132- ` :default ` .
135+ The above configuration shows two indicators. The first is called ` :default ` and
136+ is an RGB indicator. The second is a lone red LED that's used as ` :indicator2 ` .
137+ As mentioned before, if you only have one indicator, call it ` :default ` .
138+
139+ Other options include setting the list of slots and giving the ` Delux ` GenServer
140+ a name. If you don't give the ` Delux ` GenServer a name, it will register itself
141+ as a singleton and you won't have to pass the server name or pid to any of the
142+ API calls.
143+
144+ If you'd like Delux to start itself automatically, add the configuration to your
145+ ` config.exs ` or a file that it includes. Here's an example:
133146
134- Other options include setting the list of slots and giving the ` Delux `
135- GenServer a name. If you don't give the ` Delux ` GenServer a name, it will
136- register itself as a singleton and you won't have to pass the server name or
137- pid to any of the API calls.
147+ ``` elixir
148+ config :delux ,
149+ indicators: %{
150+ default: %{red: " led0:red" , green: " led0:green" , blue: " led0:blue" },
151+ indicator2: %{red: " led1" }
152+ }}
153+ ```
138154
139155## Use
140156
141- For sake of example, lets start the ` Delux ` GenServer the manual way by calling
142- ` start_link/1 ` directly. The usual way in your programs would be to add the
143- childspec to the supervision tree as shown earlier. Modify the LED names to
144- whatever you have.
157+ For sake of example, let's start the ` Delux ` GenServer the manual way by calling
158+ ` start_link/1 ` directly. Modify the LED names to whatever you have.
145159
146160``` elixir
147161iex> Delux .start_link (indicators: %{
@@ -150,8 +164,8 @@ iex> Delux.start_link(indicators: %{
150164 })
151165```
152166
153- After you have a ` Delux ` GenServer and running, call ` Delux.render/1 ` to turn
154- on the default indicator in the default slot:
167+ After you have a ` Delux ` GenServer and running, call ` Delux.render/1 ` to turn on
168+ the default indicator in the default slot:
155169
156170``` elixir
157171iex> Delux .render (Delux .Effects .on (:white ))
0 commit comments