FastFX  1.1.0
LED Strip Animation and Effects Framework for Arduino
FFXColor Class Reference

#include <FFXColor.h>

Public Types

enum  FFXColorMode { singleCRGB =0, singleCHSV =1, palette16 =2, palette256 =3 }
 

Public Member Functions

 FFXColor ()
 
 FFXColor (const FFXColor &src)
 
FFXColorMode getColorMode ()
 
String getColorModeName ()
 
void setColorMode (FFXColorMode const newMode)
 
uint8_t getPaletteRange ()
 
uint8_t setPaletteRange (uint8_t newRange)
 
uint8_t getShiftDelta ()
 
uint8_t setShiftDelta (uint8_t newDelta)
 
uint8_t getStepDelta ()
 
uint8_t setStepDelta (uint8_t newDelta)
 
uint8_t scaleIndex (uint8_t index)
 
CRGB peekCRGB (uint8_t index)
 
CRGB peekCRGB ()
 
CRGB getCRGB (uint8_t index)
 
CRGB getCRGB ()
 
void setCRGB (CRGB const &newCRGB)
 
CHSV peekCHSV ()
 
CHSV getCHSV ()
 
void setCHSV (CHSV newHSV)
 
CRGBPalette16 & getPalette ()
 
void setPalette (CRGBPalette16 const newPalette, uint8_t range)
 
void setPalette (CRGBPalette16 const newPalette)
 
uint8_t relativePaletteIndex (uint8_t index)
 
uint8_t relativePaletteIndex ()
 
uint8_t getIndex ()
 
uint8_t getPaletteIndex ()
 
void setPaletteIndex (uint8_t newIndex)
 
uint8_t getPaletteOffset ()
 
void resetStep ()
 
void resetShift ()
 
void reset ()
 
boolean isUpdated ()
 
void setUpdated (boolean newValue)
 
void step (uint8_t steps)
 
void step ()
 
void shift (uint8_t steps)
 
void shift ()
 

Public Attributes

String mode_name [4] = { "singleCRGB", "singleCHSV", "palette16", "palette256" }
 

Protected Attributes

FFXColorMode currColorMode = FFXColorMode::singleCRGB
 
CRGB currCRGB = CRGB::Black
 
CHSV currHSV = CHSV(0,255,255)
 
CRGBPalette16 currPalette
 
uint8_t pRange = 16
 
uint8_t currPindex = 0
 
uint8_t currPoffset = 0
 
uint8_t stepDelta = 1
 
uint8_t shiftDelta = 0
 
bool changed = false
 

Detailed Description

FFXColor - Provides a common interface for dealing with color, color changes, and palettes in effects.

The FFXBase parent class for all effects has a member named currColor which is available to all descendant classes for getting color values. The FXColor class supports 4 modes - 2 single color modes and 2 palette modes for effects that use multiple colors.

Each effect simply needs to call the getCRGB function to return the currently selected color. This class provides 2 methods for stepping through palette colors and shifting the palette for "rotating/shifting" palette effects. This class operates differently depending on the mode selected (use setColorMode() to change the mode) as follows:

mode singleCRGB - always return the same color, specified by setCRGB mode singleCHSV - always return the same color (CHSV) as specified by setCHSV mode palette16 - Returns colors from a 16 entry palette (set with setPalette() ) step() - steps forward 1 entry in the palette. So, if I have a 16 entry palette - each time step() is called, the next entry will be returned by getCRGB(). Once the last entry is returned, the next call to step() starts over at the first entry. shift() - will shift each entry forward n steps where n is the value of shiftDelta (defaults to 1). Each palette entry returned using a 0-255 index, so as shift() is called, each entry moves closer to the next entry in the palette. Once we've shifted forward 16 times, the entire palette has shifted forward 1 step. setRange() - This will allow the palette16 to work the same with fewer than 16 entries.

resetStep() - sets the step position back to the first entry in the palette. resetShift() - Shifts the entire palette back to its original position.

mode palette256 - Works almost the same way as palette16, however calls to step() only move forward 1 position. Shift will still shift the palette forward each time it is called as well. This can be used to rotate a palette through a fixed "window" without needing to track the index ranges. For example - I can display entries 1-100 in a loop and call shift after each one. This will continually rotate the entire palette through those first 100 entries.

Member Enumeration Documentation

◆ FFXColorMode

Enumerator
singleCRGB 
singleCHSV 
palette16 
palette256 

Constructor & Destructor Documentation

◆ FFXColor() [1/2]

FFXColor::FFXColor ( )

◆ FFXColor() [2/2]

FFXColor::FFXColor ( const FFXColor src)

Member Function Documentation

◆ getCHSV()

CHSV FFXColor::getCHSV ( )
inline

◆ getColorMode()

FFXColorMode FFXColor::getColorMode ( )
inline

◆ getColorModeName()

String FFXColor::getColorModeName ( )
inline

◆ getCRGB() [1/2]

CRGB FFXColor::getCRGB ( )
inline

◆ getCRGB() [2/2]

CRGB FFXColor::getCRGB ( uint8_t  index)

◆ getIndex()

uint8_t FFXColor::getIndex ( )
inline

◆ getPalette()

CRGBPalette16& FFXColor::getPalette ( )
inline

◆ getPaletteIndex()

uint8_t FFXColor::getPaletteIndex ( )
inline

◆ getPaletteOffset()

uint8_t FFXColor::getPaletteOffset ( )
inline

◆ getPaletteRange()

uint8_t FFXColor::getPaletteRange ( )
inline

◆ getShiftDelta()

uint8_t FFXColor::getShiftDelta ( )
inline

◆ getStepDelta()

uint8_t FFXColor::getStepDelta ( )
inline

◆ isUpdated()

boolean FFXColor::isUpdated ( )
inline

◆ peekCHSV()

CHSV FFXColor::peekCHSV ( )
inline

◆ peekCRGB() [1/2]

CRGB FFXColor::peekCRGB ( )
inline

◆ peekCRGB() [2/2]

CRGB FFXColor::peekCRGB ( uint8_t  index)

◆ relativePaletteIndex() [1/2]

uint8_t FFXColor::relativePaletteIndex ( )
inline

◆ relativePaletteIndex() [2/2]

uint8_t FFXColor::relativePaletteIndex ( uint8_t  index)

◆ reset()

void FFXColor::reset ( )
inline

◆ resetShift()

void FFXColor::resetShift ( )
inline

◆ resetStep()

void FFXColor::resetStep ( )
inline

◆ scaleIndex()

uint8_t FFXColor::scaleIndex ( uint8_t  index)

◆ setCHSV()

void FFXColor::setCHSV ( CHSV  newHSV)
inline

◆ setColorMode()

void FFXColor::setColorMode ( FFXColorMode const  newMode)

◆ setCRGB()

void FFXColor::setCRGB ( CRGB const &  newCRGB)
inline

◆ setPalette() [1/2]

void FFXColor::setPalette ( CRGBPalette16 const  newPalette)
inline

◆ setPalette() [2/2]

void FFXColor::setPalette ( CRGBPalette16 const  newPalette,
uint8_t  range 
)

◆ setPaletteIndex()

void FFXColor::setPaletteIndex ( uint8_t  newIndex)
inline

◆ setPaletteRange()

uint8_t FFXColor::setPaletteRange ( uint8_t  newRange)
inline

◆ setShiftDelta()

uint8_t FFXColor::setShiftDelta ( uint8_t  newDelta)
inline

◆ setStepDelta()

uint8_t FFXColor::setStepDelta ( uint8_t  newDelta)
inline

◆ setUpdated()

void FFXColor::setUpdated ( boolean  newValue)
inline

◆ shift() [1/2]

void FFXColor::shift ( )
inline

◆ shift() [2/2]

void FFXColor::shift ( uint8_t  steps)

◆ step() [1/2]

void FFXColor::step ( )
inline

◆ step() [2/2]

void FFXColor::step ( uint8_t  steps)

Member Data Documentation

◆ changed

bool FFXColor::changed = false
protected

◆ currColorMode

FFXColorMode FFXColor::currColorMode = FFXColorMode::singleCRGB
protected

◆ currCRGB

CRGB FFXColor::currCRGB = CRGB::Black
protected

◆ currHSV

CHSV FFXColor::currHSV = CHSV(0,255,255)
protected

◆ currPalette

CRGBPalette16 FFXColor::currPalette
protected

◆ currPindex

uint8_t FFXColor::currPindex = 0
protected

◆ currPoffset

uint8_t FFXColor::currPoffset = 0
protected

◆ mode_name

String FFXColor::mode_name[4] = { "singleCRGB", "singleCHSV", "palette16", "palette256" }

◆ pRange

uint8_t FFXColor::pRange = 16
protected

◆ shiftDelta

uint8_t FFXColor::shiftDelta = 0
protected

◆ stepDelta

uint8_t FFXColor::stepDelta = 1
protected