View Source Delux.Effects (delux v0.1.3)

Functions for creating a variety of LED patterns

Link to this section Summary

Types

Option effects (none yet)

Functions

Create a transient two color sequence

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

Link to this function

blink(c, frequency, options \\ [])

View Source
@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.

Link to this function

blip(c1, c2, options \\ [])

View Source

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.

Link to this function

cycle(colors, frequency, options \\ [])

View Source
@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

Set an indicator to the specified color

Link to this function

waveform(fun, period, options \\ [])

View Source

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.