Fledex.Effect.Interface behaviour (fledex v0.5.0)
View SourceThis module defines the interface for an LED effect. Effects can be used in Animations. Examples are:
- Rotation
- Dimming
- Randomize
- Wanishing
- Blinking
- etc.
Summary
Types
Typical states of an effect that should be published
Callbacks
Applies an effect to the list of LEDs.
Types
@type effect_state_t() ::
:static | :start | :progress | :stop_start | :stop | :disabled
Typical states of an effect that should be published
Note: This is not used yet and still very much in flux
An effect can be in different states
:static
: effect is a static effect (and hence can not be used in a sequencer):start
: effect will start with the next iteration (and will move into the :progress state). An effect can skip this state and go directly into the :progress state:progress
: effect is in progress (and will either go into the :stop_start or :stop state):stop_start
: effect is done with one round and will start the next round. THe next state can either be :start or :progress:stop
: effect is done with it's effect and will stop:disabled
: effect is currently disabled (by enabling it goes into the :start state)
This information can be used by some effect sequencer that plays one effect after the next.
Callbacks
@callback apply( leds :: [Fledex.Color.Types.colorint()], count :: non_neg_integer(), config :: keyword(), triggers :: map(), context :: map() ) :: {[Fledex.Color.Types.colorint()], non_neg_integer(), map()}
Applies an effect to the list of LEDs.
Every LED in the list can be modified at will, however, the amount should NOT (but can be as can be seen in the offset effect) be changed. The function takes the following parameters:
- The
leds
is a list of colorints representing the different colors - The
count
is the amount of LEDs in the list (to avoid that we have to traverse it unnecessarily) - The
config
are some settings that can be used to configure the effect - The
triggers
map contains all the triggers can that can be used by the effect. It does contain also the extra parameters passed in in previous calls (see below) - The
context
is a map containing information ofstrip_name
,animation_name
and effectindex
.
The function returns
- a list of LEDs (color integers),
- the new count of the list,
- and a (potentially modified)
triggers
map. This allows to retain some state between applying the filter in consecutive calls.
The most simplest filter is the one that simply returns the passed in parameters:
def apply(leds, count, _config, trigggers, _context) do
{leds, count, triggers}
end