View Source Delux.Effects (delux v0.1.3)
Functions for creating a variety of LED patterns
Link to this section Summary
Functions
Blink an indicator
Create a transient two color sequence
Cycle between colors
All LEDs off
Set an indicator to the specified color
Create a program from an arbitrary function
Link to this section Types
@type options() :: []
Option effects (none yet)
Link to this section Functions
@spec blink(Delux.RGB.color(), number(), options()) :: Delux.Program.t()
Blink an indicator
This returns a pattern that blinks the specified color at a 50% duty cycle. The pattern starts on and then goes off.
@spec blip(Delux.RGB.color(), Delux.RGB.color(), options()) :: Delux.Program.t()
Create a transient two color sequence
The first color is shown for 20 ms. 10 ms in, the second color is shown for 20 ms. The Effects is a quick flash of light that can be used to show feedback to a button. Total duration of the Effects is 40 ms.
@spec cycle([Delux.RGB.color()], number(), options()) :: Delux.Program.t()
Cycle between colors
Colors are shown with equal duration determined from the specified frequency.
@spec off() :: Delux.Program.t()
All LEDs off
@spec on(Delux.RGB.color(), options()) :: Delux.Program.t()
Set an indicator to the specified color
@spec waveform( (Delux.Pattern.milliseconds() -> Delux.RGB.color()), Delux.Pattern.milliseconds(), keyword() ) :: Delux.Program.t()
Create a program from an arbitrary function
Pass in a function that takes times in milliseconds and returns colors. The returned pattern piecewise linearly interpolates the waveform.
Here's an example of a 0.5 Hz blue sine wave:
Effects.waveform(fn t -> {0, 0, 0.5 + 0.5 *:math.cos(:math.pi() * t / 1000)} end, 2000)
When trying this, keep in mind that if the LEDs in the indicator don't support varying levels of brightness, it won't look like a sine wave.
Options
:time_step
- the number of milliseconds between each sample. Defaults to 100 ms.