Fledex.Effect.Rotation (fledex v0.7.0)
View SourceThis effect will apply a rotation to the leds
Options
This effect accepts the following options:
:direction: The direction the rotation should go. You should either specify:left(default) or:right.:publish: whether to publish state events (true, the default) or not. For more information see below.:trigger_name: the name of the trigger that results in a step in the rotation. the value intrigger[trigger_name](or 0 if not defined) will then result in an offset of the leds.:divisor: We can slow the animation down by specifying a divisor. It will devide the trigger by this amount (and truncate the result). Thus, if the:divisoris10then it would take 10 steps of the trigger before a single step of the leds would be visible (similar to a 10:1 gear ratio):stretch: The leds can be rotated within themselves or stretched over more leds. For example, you you have a 10 led sequences that you stretch over 20 leds, then the 10 leds will move over the 20 leds. Note the rules of the LedStrip still apply, that leds that are painted to non-physical leds will not be visible.
state information
The rotation effect publishes a couple of state events (except if :publish is set to false). Here a description on what the various events mean:
Lets assume we have the following 20 leds:
1 0
98765432109876543210that are getting stretched over 40 leds:
3 2 1 0
9876543210987654321098765432109876543210lets rotate to the right, we then have the following interesting points:
- we start with the rotation left aligned (as shown above) (
:start) - we move slowly to the right. crossing through the mid-point (
:middle) - we touch with the right side of the leds at the right side of the stretched part (
:touch). We are in the run-out, i.e. leds are moving "out" of the stretched part - the last led has reached the right side of the stretched part (no more rotation is visible). The next step will correspond to the first one where we started. (
:end)
Don't forget that the effect is a rotation, so leds that "drop out on the right will reappear on the left. You might be wondering on what happens if you don't stretch your animation. The same events will be published, but
Summary
Functions
Implementation of the Rotation effect.
Helper function mainy intended for internal use to rotate the sequence of values by an offset.
Functions
@spec do_apply( leds :: [Fledex.Color.Types.colorint()], count :: non_neg_integer(), config :: keyword(), triggers :: map(), context :: map() ) :: {[Fledex.Color.Types.colorint()], non_neg_integer(), map()}
@spec do_apply( [Fledex.Color.Types.colorint()], non_neg_integer(), config :: keyword(), triggers :: map(), context :: map() ) :: {[Fledex.Color.Types.colorint()], non_neg_integer(), map()}
Implementation of the Rotation effect.
This is making use of the Fledex.Effect.Interface.__using__/1 functionalty.
@spec rotate( [Fledex.Color.Types.colorint()], non_neg_integer(), pos_integer(), boolean() ) :: [ Fledex.Color.Types.colorint() ]
Helper function mainy intended for internal use to rotate the sequence of values by an offset.
The rotation can happen with the offset to the left or to the right.