-
-
Notifications
You must be signed in to change notification settings - Fork 264
NeoPixelAnimator object API
Construct an animator with the number of animation channels, using the given timescale for all time values.
The timescale is number of milliseconds per time unit. The following flags are available.
NEO_MILLISECONDS // ~65 seconds max duration, ms updates
NEO_CENTISECONDS // ~10.9 minutes max duration, centisecond updates
NEO_DECISECONDS // ~1.8 hours max duration, decisecond updates
NEO_SECONDS // ~18.2 hours max duration, second updates
NEO_DECASECONDS // ~7.5 days, 10 second updates
The timescale affects not only how often the animation can be called per second; but also how long an animation can be. If you need animations that are called often so they are smooth, then leave it at the default of NEO_MILLISECONDS or at worst NEO_CENTISECONDS. If a change per second or longer is ok and you need animations that run very long, then NEO_SECONDS might be your choice. It is a trade off of fast and smooth versus slow and coarse.
Return true if there is at least one active running animation.
Return true if there is an available animation channel, and set the given indexAvailable variable to the channel index.
- indexAvailable - a pointer to the variable to return the available channel index
- indexStart - the index to start searching at
Start an animation at the given index, set the length in time to duration, and provide a update callback that apply the effect.
- indexAnimation - the animation channel to use. If there is an active animation on that channel, it will be stopped first and then the channel will be reused.
- duration - the length of time the animation will run. The scale is based on the flags passed to the constructor of this manager class.
- animUpdate - the callback function that will be called for every passage of time.
Stop the animation on the given channel.
- indexAnimation - the animation channel to stop.
Without changing any of the parameters of the animation, restart the animation. If the animation was running it will jump to the beginning and then progress from the start.
This provides an easy way to loop an animation if needed.
- indexAnimation - the animation channel to restart.
Return true if the specified animation channel is running.
- indexAnimation - the animation channel to check
Return the duration of the specified animation channel. The time is based on the flags passed to the constructor of this manager class.
- indexAnimation - the animation channel to retrieve from.
Called to change the duration that a single animation takes to execute. If the animation was running it will NOT jump to the beginning.
- indexAnimation - the animation channel to retrieve from.
- newDuration - the length of time the animation will run. The scale is based on the flags passed to the constructor of this manager class.
Called to allow the animations to progress in time. This must be called periodically in the Loop(). Best if called at least once every 10ms but can be called as fast as the loop() runs.
Pause all animations. This will freeze the animations in their current state.
Resume all animations. This will unfreeze the animations from where Pause() was called.
Return if the animations are paused. The Pause() method is called to pause and Resume() is called to resume.
Return the current time scale.
Set the current time scale. All currently running animations will be effected by this change, either slowing them down or speeding them up.
- timeScale - See values explained in the constructor
This struct contains three properties that provide state information to the animation callback.
- float progress - the progress from 0.0 to 1.0 of the animation to apply
- uint16_t index - the channel index of the animation
- AnimationState state - the animation state, which can be one of the following...
AnimationState_Started - this is the first call to update, will only be set once unless the animation is restarted.
AnimationState_Progress - this is one of the many calls between the first and last.
AnimationState_Completed - this is the last call to update, will only be set once unless the animation is restarted.