The Effect Base Class - AlbertGBarber/PixelSpork GitHub Wiki

See the Documentation Guide for help understanding each page section.

Description:

The effect base class is not an effect itself, but acts as an parent class for all effects and utilities. You probably won't ever need to interact with the class unless you are creating your own effect.

Overall, the class contains some settings and functions that are common to all effects. I created the class because I wanted to be able to group effects together to manage and update them more easily (see Effect Sets). This meant I needed to be able to create an array of effects, which isn't possible in C/C++ unless all your array members have the same type. The easiest way to to do this was to give all the effects a parent class, EffectBasePS.

I did this very early on in the library's creation, and unfortunately, I didn't end up using it as much as I hoped. Originally I envisioned that there would be a lot of crossover between effect settings, so I could stick the common settings in the Effect Base, and eventually build some type of common setting changer function. With such a function, you could wire up a button and hopefully change any common effect setting, no matter what effect was active. However, in the end, most effects are quite different from each other, and I was loath to add settings to the Effect Base because they become common to all effects, even if the effect doesn't have/use them. At the same time, I didn't want to dismantle the Effect Base parent setup because I was using it in Effect Sets, which is useful.

Eventually I want to write a add-on library that can handle the button-to-any-effect pipeline, probably by writing a specific button function for each effect, while having the user build a switch statement to call the function when an effect is active.

Notes:

When accessing an effect via its Effect Base parent (ie you have a pointer to the effect as the EffectBasePS type) you can only access settings that are in the Effect Base.

For example, if I have a Fireworks effect, I can access its rate property because rate is part of Effect Base, but I cannot access its palette, because Effect Base doesn't have a palette.

Example Calls:

The class acts as a parent to all effects. It cannot be created individually and has no constructor.

Settings:

  • SegmentSetPS* segSet -- The Segment Set the effect will draw on. See common vars segSet entry for more details.

  • uint16_t* rate and uint16_t rateOrig-- The effect update rate (ms). Is a pointer, allowing you to bind it to an external variable. By default it's bound to, rateOrig. See common vars rate entry for more.

  • bool active (default true) -- If false, the utility/effect will be disabled (updates() will be ignored). Currently only used for utility classes. See common vars active entry for more details.

  • bool showNow (default true) -- Controls if the effect "draws" during each update cycle by calling FastLED.show(). See common vars showNow entry for more details.

Class Functions:

  • virtual void update();
    

    A virtual update function, when called, will call the inherited effect's update().

  • virtual ~EffectBasePS();
    

    A virtual class destructor, when called, will call the inherited effect's destructor.