View Source Delux.Pattern (delux v0.4.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

Return a number of ms that should be considered a long time

PWM a sequence of elements

Reduce the number of transitions in a sequence

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 forever_ms() :: 3_600_000

Return a number of ms that should be considered a long time

Linux doesn't support an infinite timeout, so use this value instead.

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