You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: TODO.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Even though this library is published, there are things I still want to do befor
16
16
-[x] Document the driver options (v0.7)
17
17
-[x] Update the cheatsheet with coordinator info (v0.7)
18
18
-[x] Resolve all important `doctor` issues (v0.7)
19
-
-[ ] Add a livebook with coordinator examples (v0.7) <-- WIP
19
+
-[ ] Add a livebook with coordinator examples (v0.8) <-- WIP
20
20
-[ ] Update documentation with the Supervision tree (v0.8)
21
21
-[ ] hardware setup (analogy with a bus letting 24 passangers off the bus at every led-bus-stop). Create a comprehensive write-up (v0.8)
22
22
-[ ] Testing
@@ -45,7 +45,8 @@ Even though this library is published, there are things I still want to do befor
45
45
-[x] Rename the job property `pattern` to `schedule` in the DSL created config (v0.7)
46
46
-[x] The refactoring made the debug_logging property unnecessary. It's unclear on what to do with it. (v0.7)
47
47
-[x] Rename `docs` to `pages`. Some people find it confusing to have a `docs` and a `doc` (created by `ex_doc`) (v0.7)
48
-
-[ ] Make sure that all the job options are correctly honored (adjust documentation if necessary) (v0.7)
48
+
-[ ] We should be able to replace the `Animation.Manager` config splitting with the `Enum.group_by` function (v0.8)
49
+
-[ ] Make sure that all the job options are correctly honored (adjust documentation if necessary) (v0.8)
49
50
-[ ] Rethink whether we really want to create a `Fledex.Config.Data` module or we should store the information in a GenServer. The issue with the GenServer is that we need to start a server. But maybe that's not soo bad. (v0.9)
50
51
-[x] Change the `start_links` to take just one arg (the parameters) and an `opts` passed as opts to GenServer. Through this we define the name and therefore can move the `via_tuple` outside of the modules.
51
52
-[ ] Missing functionality
@@ -54,13 +55,13 @@ Even though this library is published, there are things I still want to do befor
54
55
-[x] Allow color modules to not carry more information than just a pre-defined set (v0.7)
55
56
-[x] convert the rgb to other color spaces (in the various color name modules). Considering the previous point we might not need to do this, because it should now be optional (v0.7) <-- reduced the generated color functions, and what gets exposed
56
57
-[x] we start things through the Supervisor, but we don't shut things down through it (v0.7)
57
-
-[ ] Put some more effort into the coordinator to make it work well (v0.7)
58
58
-[x] Rework the `:job` implementation (v0.7):
59
59
-[x] The Job should (at least appear) to be connected to the LedStrip
60
60
-[x] Replace it with a different library (maybe `SchedEx`? https://hexdocs.pm/sched_ex/readme.html) (v0.7)
61
61
-[x] Investigate various libraries and how they fit into Fledex. I looked at various different libraries (`erlcron`, `sched_ex`, `exq_scheduler`, `ecron`, ...), but none really fulfils the needs :-( `SchedEx` is the one that is simple and comes closest. Therefore the plan is to take it (it's MIT license), modify it, and integrate it into Fledex
62
62
-[x] It's not possible to inject a context to the job, because you either have to provide an `{M, F, [Args]}` or a `(-> any())` function. The former is not possible, since we don't have amodule (but just an anonymous function) and the latter is not possible, because we can't pass in any argument :-(. We would need to extend Quantum to accept an {F, [Args]}
63
63
-[x] Switch to a released version of `:fledex_scheduler` (v0.7)
64
+
-[ ] Put some more effort into the coordinator to make it work well (v0.8)
64
65
-[ ] Enable Telemetry? (v0.8)
65
66
-[ ] Switch also the `fledex_scheduler` stats to telemetry (v0.8)
66
67
-[ ] Add support for WS2811/12/13/14/15 LED strips controlled through phase modulation. (v0.8)
Copy file name to clipboardExpand all lines: livebooks/2_fledex_first_steps.livemd
+30-25Lines changed: 30 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,11 +56,12 @@ Now we are ready to send some data to the led_strip. Before we send some color i
56
56
For now we use a hex code to define colors. You can learn more about colors and how to define them in [chapter 3b](3b_fledex_everything_about_colors.livemd).
@@ -189,12 +194,12 @@ Take note, that our functions create sequences of different length.
189
194
190
195
Now we can try it out with one of the first functions. Let's call our `red/1` function. We spawn it in a separate process. The reason for that you'll see in a second.
191
196
192
-
> #### Note {: .info}
197
+
> #### Note
193
198
>
194
199
> You might have to scroll up to see the animation
195
200
196
201
```elixir
197
-
LedStrip.define_namespace(:john, :red)
202
+
LedStrip.define_namespace(server, :red)
198
203
199
204
spawn(fn->
200
205
Helpers.red(:red)
@@ -203,14 +208,14 @@ end)
203
208
204
209
Similarly you can do the same with the `blue/1` function. Where it gets interesting is, when you start first the red function and then start the blue function while the red function is still running.
205
210
206
-
> #### Note {: .info}
211
+
> #### Note
207
212
>
208
213
> Don't forget to use a differnt namespace name compared to the above function, otherwise
209
214
> one function would constantly overwrite what the other function has defined. We want them
210
215
> to live in parallel and get merged.
211
216
212
217
```elixir
213
-
LedStrip.define_namespace(:john, :blue)
218
+
LedStrip.define_namespace(server, :blue)
214
219
215
220
spawn(fn->
216
221
Helpers.blue(:blue)
@@ -226,7 +231,7 @@ While both functions are running, they will
226
231
Now we can use the above functions with our trip. We can run the functions by spawning a new thread. This allows to also see what happens if another thread works in parallel. Here we create a rainbow effect that will be send with a changing offset so that the rainbow rotates through the LEDs
Here we create a gradient between red and blue. Also this one we let rotate through. Note, depending on whether you started the rainbow above or not, you might see different results. Try this section with and without running the Rainbow section.
238
243
239
244
```elixir
240
-
LedStrip.define_namespace(:john, :gradient)
245
+
LedStrip.define_namespace(server, :gradient)
241
246
spawn(fn->Helpers.gradient(:gradient) end)
242
247
```
243
248
244
249
We can drop the namespaces to see what happens
245
250
246
251
```elixir
247
-
LedStrip.drop_namespace(:john, :gradient)
252
+
LedStrip.drop_namespace(server, :gradient)
248
253
```
249
254
250
255
As we can see our animation stops to be visible and our calls to `set_leds` will fail (but we swallow those errors).
@@ -256,9 +261,9 @@ As we can see our animation stops to be visible and our calls to `set_leds` will
256
261
This test is running a couple of different ligth definitions in parallel.
Copy file name to clipboardExpand all lines: livebooks/3_fledex_animations.livemd
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,12 @@ alias Fledex.Driver.Impl.Kino
28
28
aliasFledex.Color.Correction
29
29
aliasFledex.Supervisor.AnimationSystem
30
30
31
+
# to use our color aliases (like :red) we need to configure them
32
+
useFledex.Config
33
+
34
+
# now we start our animation system
31
35
AnimationSystem.start_link()
36
+
32
37
```
33
38
34
39
## Helper functions
@@ -68,6 +73,7 @@ We call our led strip `:john`. In this example we will only use the simple kino
68
73
We then define an animation configuration that consists of a map with the key being the name of the animation and the value being the configuration of that animation. Each animation configuration needs to specify the `:type` as `:animation`, because (as we will see later) other types exist, and a `:def_func` that defines our animation (potentially with an additional `:send_config_func` as shown here. We'll look at this in more detail in a later section).
Copy file name to clipboardExpand all lines: livebooks/3b_fledex_everything_about_colors.livemd
+14-9Lines changed: 14 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,6 @@ Mix.install([
12
12
])
13
13
```
14
14
15
-
## Setup
16
-
17
15
## Colors and different drivers
18
16
19
17
Different drivers have different color characteristics. Therefore you might have to adjust the colors when migrating from one output to another. Some drivers allow some color correction to try to adjust for those issues (see also the 'Color Correction' section.
@@ -34,7 +32,7 @@ We don't specify anything and thereby go with the default color set of `:wiki`,
34
32
useFledex
35
33
```
36
34
37
-
Fledex has an extensive set of predefined colors from [Wikipedia](https://en.wikipedia.org/wiki/List_of_colors:_A%E2%80%93F), [CSS](https://drafts.csswg.org/css-color/#named-colors), [SVG](https://www.w3.org/TR/SVG11/types.html#ColorKeywords), and [RAL](https://en.wikipedia.org/wiki/List_of_RAL_colours).Apart from the last list (which is not so commonly used), they are all combined together to a single Names module. You can retrieve those names by calling:
35
+
Fledex has an extensive set of predefined colors from [Wikipedia](https://en.wikipedia.org/wiki/List_of_colors:_A%E2%80%93F), [CSS](https://drafts.csswg.org/css-color/#named-colors), [SVG](https://www.w3.org/TR/SVG11/types.html#ColorKeywords), and [RAL](https://en.wikipedia.org/wiki/List_of_RAL_colours).Apart from the last list (which is not so commonly used), they are all combined together to a single Names module. You can retrieve those names by calling:
Here a list of all the defined colors (extra colors can still be used, but need to be called explicitly, like the RAL colors through `Fledex.Color.Names.RAL`):
55
53
56
54
```elixir
57
-
colors =Enum.map(Fledex.Color.Names.names() |>Enum.sort(), fn name ->
@@ -108,9 +112,10 @@ Before we look at the Fledex features regarding color correction we first need t
108
112
> the colors, making the whites appear white, the blacks appear black, and making sure that
109
113
> everything is even.
110
114
111
-
The color correction consists of two parts. First to compensate the physical mis-coloring of the LEDs. The basic colors on the classical 5050 LED chip are not shown in the same intensity. So we need to compensate this.
115
+
The color correction consists of two parts:
112
116
113
-
The second color coorection we might want to perform is to bring the color into the correct "temperature" (named due to the [black body radiator](https://en.wikipedia.org/wiki/Black-body_radiation)) with a relatively continuous spectrum, or approach the light of a gaseous light source with more discrete spectral band (see [gas discharge lamp](https://en.wikipedia.org/wiki/Gas-discharge_lamp)).
117
+
1. First to compensate the physical mis-coloring of the LEDs. The basic colors on the classical 5050 LED chip are not shown in the same intensity. So we need to compensate this.
118
+
2. The second color correction we might want to perform is to bring the color into the correct "temperature" (named due to the [black body radiator](https://en.wikipedia.org/wiki/Black-body_radiation)) with a relatively continuous spectrum, or approach the light of a gaseous light source with more discrete spectral band (see [gas discharge lamp](https://en.wikipedia.org/wiki/Gas-discharge_lamp)).
114
119
115
120
Color correction is provided in Fledex through the modules under `Fledex.Color.Correction`.
Copy file name to clipboardExpand all lines: livebooks/4_fledex_clock_example.livemd
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,6 @@ alias Fledex.Leds
18
18
aliasFledex.LedStrip
19
19
aliasFledex.Supervisor.AnimationSystem
20
20
21
-
AnimationSystem.start_link()
22
-
23
21
:ok
24
22
```
25
23
@@ -32,7 +30,14 @@ But before we get there, we first initiate our led strip.
32
30
33
31
## Preparational steps
34
32
35
-
First we register a strip (we name it `:clock`) with our `Fledex.Animation.Manager` and we use the default settings for the `Kino` driver.
33
+
First we need to define our config and start our AnimationSystem
34
+
35
+
```elixir
36
+
useFledex.Config
37
+
AnimationSystem.start_link()
38
+
```
39
+
40
+
Then we register a strip (we name it `:clock`) with our `Fledex.Animation.Manager` and we use the default settings for the `Kino` driver.
36
41
37
42
Then we modify the led strip to update with a very low frequency. Our clock only updates every second and therefore it's unnecessary that we update it more often than that. To avoid any issues due to some runtime delays, we update it twice every second. Thereby the second indicator will never jump an led.
0 commit comments