Class Animation¶
Defined in File animation.h
Inheritance Relationships¶
Derived Types¶
public PixelMaestro::BlinkAnimation
(Class BlinkAnimation)public PixelMaestro::CycleAnimation
(Class CycleAnimation)public PixelMaestro::FireAnimation
(Class FireAnimation)public PixelMaestro::LightningAnimation
(Class LightningAnimation)public PixelMaestro::MandelbrotAnimation
(Class MandelbrotAnimation)public PixelMaestro::PlasmaAnimation
(Class PlasmaAnimation)public PixelMaestro::RadialAnimation
(Class RadialAnimation)public PixelMaestro::RandomAnimation
(Class RandomAnimation)public PixelMaestro::SolidAnimation
(Class SolidAnimation)public PixelMaestro::SparkleAnimation
(Class SparkleAnimation)public PixelMaestro::VUAnimation
(Class VUAnimation)public PixelMaestro::WaveAnimation
(Class WaveAnimation)
Class Documentation¶
-
class
Animation
¶ Subclassed by PixelMaestro::BlinkAnimation, PixelMaestro::CycleAnimation, PixelMaestro::FireAnimation, PixelMaestro::LightningAnimation, PixelMaestro::MandelbrotAnimation, PixelMaestro::PlasmaAnimation, PixelMaestro::RadialAnimation, PixelMaestro::RandomAnimation, PixelMaestro::SolidAnimation, PixelMaestro::SparkleAnimation, PixelMaestro::VUAnimation, PixelMaestro::WaveAnimation
Public Types
Public Functions
-
Animation
(Section §ion)¶ Constructor. Initializes the timer and map.
- Parameters
section
: The Section that this animation will render in.
-
~Animation
()¶
-
uint8_t
get_cycle_index
() const¶ Returns the current cycle index.
- Return
Cycle index.
-
bool
get_fade
() const¶ Returns whether the animation is fading.
- Return
True if fading.
-
Animation::Orientation
get_orientation
() const¶ Returns the animation’s orientation.
- Return
Animation’s orientation
-
bool
get_reverse
() const¶ Returns whether the animation is running in reverse.
- Return
True if running in reverse.
-
AnimationTimer *
get_timer
() const¶ Returns the animation’s timer.
- Return
Animation timer.
-
AnimationType
get_type
() const¶ Returns the type of Animation.
- Return
Animation type.
-
virtual void
map
() = 0¶
-
void
rebuild_map
()¶ Regenerates the color-to-pixel map.
-
void
set_cycle_index
(uint8_t index)¶ Sets the cycle index to the specified index.
- Parameters
index
: New cycle index.
-
void
set_fade
(bool fade)¶ Toggles fading the animation.
- Parameters
fade
: If true, fade between cycles.
-
void
set_map_color_index
(uint16_t x, uint16_t y, uint8_t color_index)¶ Assigns the specified Pixel to the specified color.
-
void
set_center
(uint16_t x, uint16_t y)¶ Sets the center of the Animation. Only applies to certain Animations.
- Parameters
x
: Center along the x axis.y
: Center along the y axis.
-
void
set_orientation
(Orientation orientation)¶ Sets the animation’s orientation.
- Parameters
orientation
: New orientation.
-
void
set_reverse
(bool reverse)¶ Sets whether to run the animation in reverse.
- Parameters
reverse
: If true, run in reverse.
-
AnimationTimer &
set_timer
(uint16_t speed, uint16_t delay = 0)¶ Sets the amount of time between animation updates.
- Parameters
speed
: Amount of time (in milliseconds) between animation cycles.delay
: Amount of time (in milliseconds) to wait before starting an animation cycle.
-
bool
update
(const uint32_t ¤t_time)¶ Updates the animation. This checks to see if the animation should update, then calls the derived class’s update method. Finally, it renders the mapped color to each Pixel.
- Return
True if the update was processed.
- Parameters
current_time
: The current runtime.
Protected Functions
-
virtual void
update
() = 0¶
-
void
update_cycle
(uint8_t min, uint8_t max)¶ Incremnets the current animation cycle. If reverse_animation_ is true, this decrements the cycle, moving the animation backwards. If the animation reaches the end of its cycle, it will jump back (or forward) to the start (or end).
- Parameters
min
: The minimum possible value of cycle_index_.max
: The maximum possible value of cycle_index_.
Protected Attributes
-
uint8_t
cycle_index_
= 0¶ The current stage in the animation cycle. Defaults to 0.
-
bool
fade_
= true¶ Whether to fade between cycles. Defaults to true.
-
bool
initialized_
= false¶ False until the Animation has been fully allocated and mapped. Created for set_center().
-
uint8_t **
map_
= nullptr¶ Mapping of color palette indices to Pixels. Note: 255 is reserved for the color black.
-
Orientation
orientation_
= Orientation::Horizontal¶ The orientation of the animation. Defaults to HORIZONTAL.
-
bool
reverse_
= false¶ Whether to animate in reverse. Defaults to false.
-
AnimationTimer *
timer_
= nullptr¶ The Animation’s timer. This is a pointer instead of a local object because we must initialize it after the Animation.
-
AnimationType
type_
= AnimationType::Solid¶ The type of Animation. Gets set in the derived class’ constructor.
-