View Source Delux.Pattern (delux v0.1.0)

Utility functions for handling element sequences for one LED

Link to this section Summary

Types

Value, duration for one component

Integer durations in milliseconds

t()

A sequence of elements

Functions

PWM a sequence of elements

Reduce the number of transitions in a sequence

Convert a pattern to iodata

Link to this section Types

@type element() :: {Delux.RGB.component(), milliseconds()}

Value, duration for one component

Values are 0 to 1 and durations are in milliseconds.

@type milliseconds() :: non_neg_integer()

Integer durations in milliseconds

@type t() :: [element()]

A sequence of elements

These get processed into the pattern string that's sent to Linux.

Link to this section Functions

@spec pwm(t(), 0..100) :: t()

PWM a sequence of elements

The resulting sequence will only be fully on or fully off. See caveats in Program.adjust_brightness_pwm/2.

IMPORTANT: This function is VERY incomplete right now. It requires much more thought to work around flickering issues at low PWM rates.

@spec simplify(t()) :: t()

Reduce the number of transitions in a sequence

This reduces the length of the pattern and in some cases makes it use less of the CPU to run. It's useful for programmatically generated patterns that can take inputs that generate lots of repeating sequences.

Link to this function

to_iodata(pattern, max_b)

View Source
@spec to_iodata(t(), non_neg_integer()) :: iolist()

Convert a pattern to iodata