13FASTLED_NAMESPACE_BEGIN
63 inline uint8_t&
operator[] (uint8_t x) __attribute__((always_inline))
69 inline const uint8_t&
operator[] (uint8_t x)
const __attribute__((always_inline))
76 inline CHSV() __attribute__((always_inline)) = default;
82 inline
CHSV( uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
88 inline CHSV(
const CHSV& rhs) __attribute__((always_inline)) =
default;
98 inline CHSV&
setHSV(uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
147 inline uint8_t&
operator[] (uint8_t x) __attribute__((always_inline))
155 inline const uint8_t&
operator[] (uint8_t x)
const __attribute__((always_inline))
162 inline CRGB() __attribute__((always_inline)) = default;
168 inline
CRGB( uint8_t ir, uint8_t ig, uint8_t ib) __attribute__((always_inline))
169 :
r(ir),
g(ig),
b(ib)
175 inline CRGB( uint32_t colorcode) __attribute__((always_inline))
176 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
183 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
191 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
197 inline CRGB(
const CRGB& rhs) __attribute__((always_inline)) =
default;
200 inline CRGB(
const CHSV& rhs) __attribute__((always_inline))
210 inline CRGB&
operator= (
const uint32_t colorcode) __attribute__((always_inline))
212 r = (colorcode >> 16) & 0xFF;
213 g = (colorcode >> 8) & 0xFF;
214 b = (colorcode >> 0) & 0xFF;
222 inline CRGB&
setRGB (uint8_t nr, uint8_t ng, uint8_t nb) __attribute__((always_inline))
234 inline CRGB&
setHSV (uint8_t hue, uint8_t sat, uint8_t val) __attribute__((always_inline))
243 inline CRGB&
setHue (uint8_t hue) __attribute__((always_inline))
260 r = (colorcode >> 16) & 0xFF;
261 g = (colorcode >> 8) & 0xFF;
262 b = (colorcode >> 0) & 0xFF;
446 if( rhs.
r >
r)
r = rhs.
r;
447 if( rhs.
g >
g)
g = rhs.
g;
448 if( rhs.
b >
b)
b = rhs.
b;
464 if( rhs.
r <
r)
r = rhs.
r;
465 if( rhs.
g <
g)
g = rhs.
g;
466 if( rhs.
b <
b)
b = rhs.
b;
480 inline explicit operator bool() const __attribute__((always_inline))
486 inline explicit operator uint32_t()
const
488 return uint32_t{0xff000000} |
489 (uint32_t{
r} << 16) |
504#if (defined SmartMatrix_h || defined SmartMatrix3_h)
507 operator rgb24()
const {
523 scale8_LEAVING_R1_DIRTY(
g, 183) + \
524 scale8_LEAVING_R1_DIRTY(
b, 18);
531#if FASTLED_SCALE8_FIXED == 1
532 const uint8_t eightyfive = 85;
534 const uint8_t eightyfive = 86;
537 scale8_LEAVING_R1_DIRTY(
g, eightyfive) + \
538 scale8_LEAVING_R1_DIRTY(
b, eightyfive);
555 uint16_t factor = ((uint16_t)(limit) * 256) / max;
556 red = (
red * factor) / 256;
589 uint8_t sum =
r +
g +
b;
619 if( parity == curparity)
return;
623 if( (
b > 0) && (
b < 255)) {
624 if(
r ==
g &&
g ==
b) {
629 }
else if( (
r > 0) && (
r < 255)) {
631 }
else if( (
g > 0) && (
g < 255)) {
634 if(
r ==
g &&
g ==
b) {
643 if(
r ==
g &&
g ==
b) {
653 if(
r ==
g &&
g ==
b) {
829 return (lhs.
r == rhs.
r) && (lhs.
g == rhs.
g) && (lhs.
b == rhs.
b);
835 return !(lhs == rhs);
841 return (lhs.
h == rhs.
h) && (lhs.
s == rhs.
s) && (lhs.
v == rhs.
v);
847 return !(lhs == rhs);
854 sl = lhs.
r + lhs.
g + lhs.
b;
855 sr = rhs.
r + rhs.
g + rhs.
b;
863 sl = lhs.
r + lhs.
g + lhs.
b;
864 sr = rhs.
r + rhs.
g + rhs.
b;
872 sl = lhs.
r + lhs.
g + lhs.
b;
873 sr = rhs.
r + rhs.
g + rhs.
b;
881 sl = lhs.
r + lhs.
g + lhs.
b;
882 sr = rhs.
r + rhs.
g + rhs.
b;
888__attribute__((always_inline))
897__attribute__((always_inline))
906__attribute__((always_inline))
915__attribute__((always_inline))
918 return CRGB( p1.r/d, p1.g/d, p1.b/d);
923__attribute__((always_inline))
926 return CRGB( p1.r < p2.r ? p1.r : p2.r,
927 p1.g < p2.g ? p1.g : p2.g,
928 p1.b < p2.b ? p1.b : p2.b);
932__attribute__((always_inline))
935 return CRGB( p1.r > p2.r ? p1.r : p2.r,
936 p1.g > p2.g ? p1.g : p2.g,
937 p1.b > p2.b ? p1.b : p2.b);
941__attribute__((always_inline))
central include file for FastLED, defines the CFastLED class/object
Contains definitions for color correction and temperature.
ColorTemperature
Color temperature values.
LEDColorCorrection
Color correction starting points.
uint8_t fract8
ANSI: unsigned short _Fract.
uint16_t fract16
ANSI: unsigned _Fract.
LIB8STATIC uint8_t lerp8by8(uint8_t a, uint8_t b, fract8 frac)
Linear interpolation between two unsigned 8-bit values, with 8-bit fraction.
LIB8STATIC uint16_t lerp16by16(uint16_t a, uint16_t b, fract16 frac)
Linear interpolation between two unsigned 16-bit values, with 16-bit fraction.
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
LIB8STATIC_ALWAYS_INLINE uint8_t qmul8(uint8_t i, uint8_t j)
8x8 bit multiplication with 8-bit result, saturating at 0xFF.
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
Subtract one byte from another, saturating at 0x00.
void hsv2rgb_rainbow(const CHSV &hsv, CRGB &rgb)
Forward declaration of hsv2rgb_rainbow here, to avoid circular dependencies.
EOrder
RGB color channel orderings, used when instantiating controllers to determine what order the controll...
bool operator>(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is greater than another.
bool operator<(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is less than another.
bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
HSVHue
Pre-defined hue values for CHSV objects.
bool operator>=(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is greater than or equal to another.
bool operator<=(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is less than or equal to another.
bool operator!=(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects do not have the same color data.
@ RGB
Red, Green, Blue (0012)
@ BGR
Blue, Green, Red (0210)
@ BRG
Blue, Red, Green (0201)
@ GRB
Green, Red, Blue (0102)
@ RBG
Red, Blue, Green (0021)
@ GBR
Green, Blue, Red (0120)
@ HUE_ORANGE
Orange (45°)
@ HUE_YELLOW
Yellow (90°)
@ HUE_PURPLE
Purple (270°)
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8() does not clean up the R1 register on AVR.
LIB8STATIC void nscale8x3(uint8_t &r, uint8_t &g, uint8_t &b, fract8 scale)
Scale three one-byte values by a fourth one, which is treated as the numerator of a fraction whose de...
LIB8STATIC void nscale8x3_video(uint8_t &r, uint8_t &g, uint8_t &b, fract8 scale)
Scale three one-byte values by a fourth one, which is treated as the numerator of a fraction whose de...
Fast, efficient 8-bit math functions specifically designed for high-performance LED programming.
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
CHSV & operator=(const CHSV &rhs)=default
Allow copy construction.
uint8_t v
Color value (brightness).
uint8_t raw[3]
Access the hue, saturation, and value data as an array.
uint8_t sat
Color saturation.
CHSV()=default
Default constructor.
uint8_t value
Color value (brightness).
uint8_t saturation
Color saturation.
CHSV(const CHSV &rhs)=default
Allow copy construction.
uint8_t s
Color saturation.
uint8_t val
Color value (brightness).
uint8_t & operator[](uint8_t x)
Array access operator to index into the CHSV object.
CHSV & setHSV(uint8_t ih, uint8_t is, uint8_t iv)
Assign new HSV values.
Representation of an RGB pixel (Red, Green, Blue)
CRGB & nscale8(const CRGB &scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
CRGB & operator++()
Add a constant of '1' from each channel, saturating at 0xFF.
CRGB(ColorTemperature colorcode)
Allow construction from a ColorTemperature enum.
CRGB & nscale8_video(uint8_t scaledown)
Scale down a RGB to N/256ths of it's current brightness using "video" dimming rules.
CRGB(LEDColorCorrection colorcode)
Allow construction from a LEDColorCorrection enum.
CRGB(const CHSV &rhs)
Allow construction from a CHSV color.
CRGB & operator-=(const CRGB &rhs)
Subtract one CRGB from another, saturating at 0x00 for each channel.
uint8_t raw[3]
Access the red, green, and blue data as an array.
CRGB & setColorCode(uint32_t colorcode)
Allow assignment from 32-bit (really 24-bit) 0xRRGGBB color code.
uint8_t r
Red channel value.
CRGB & setHSV(uint8_t hue, uint8_t sat, uint8_t val)
Allow assignment from hue, saturation, and value.
CRGB operator-() const
Invert each channel.
CRGB & subtractFromRGB(uint8_t d)
Subtract a constant from each channel, saturating at 0x00.
CRGB(const CRGB &rhs)=default
Allow copy construction.
CRGB scale8(const CRGB &scaledown) const
Return a CRGB object that is a scaled down version of this object.
CRGB & operator/=(uint8_t d)
Divide each of the channels by a constant.
CRGB & operator%=(uint8_t scaledown)
%= is a synonym for nscale8_video().
CRGB scale8(uint8_t scaledown) const
Return a CRGB object that is a scaled down version of this object.
CRGB()=default
Default constructor.
CRGB & fadeLightBy(uint8_t fadefactor)
fadeLightBy is a synonym for nscale8_video(), as a fade instead of a scale
CRGB & operator+=(const CRGB &rhs)
Add one CRGB to another, saturating at 0xFF for each channel.
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
uint8_t & operator[](uint8_t x)
Array access operator to index into the CRGB object.
void maximizeBrightness(uint8_t limit=255)
Maximize the brightness of this CRGB object.
CRGB & operator|=(const CRGB &rhs)
"or" operator brings each channel up to the higher of the two values
CRGB & addToRGB(uint8_t d)
Add a constant to each channel, saturating at 0xFF.
CRGB lerp8(const CRGB &other, fract8 frac) const
Return a new CRGB object after performing a linear interpolation between this object and the passed i...
CRGB lerp16(const CRGB &other, fract16 frac) const
Return a new CRGB object after performing a linear interpolation between this object and the passed i...
uint8_t g
Green channel value.
uint8_t red
Red channel value.
CRGB & setHue(uint8_t hue)
Allow assignment from just a hue.
uint8_t blue
Blue channel value.
CRGB & setRGB(uint8_t nr, uint8_t ng, uint8_t nb)
Allow assignment from red, green, and blue.
uint8_t getAverageLight() const
Get the average of the R, G, and B values.
uint8_t b
Blue channel value.
CRGB & operator=(const CRGB &rhs)=default
Allow assignment from one RGB struct to another.
uint8_t green
Green channel value.
uint8_t getLuma() const
Get the "luma" of a CRGB object.
void setParity(uint8_t parity)
Adjusts the color in the smallest way possible so that the parity of the coloris now the desired valu...
CRGB & operator*=(uint8_t d)
Multiply each of the channels by a constant, saturating each channel at 0xFF.
CRGB & operator--()
Subtract a constant of '1' from each channel, saturating at 0x00.
HTMLColorCode
Predefined RGB colors.
CRGB(uint32_t colorcode)
Allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code.
CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
uint8_t getParity()
Returns 0 or 1, depending on the lowest bit of the sum of the color components.
CRGB & operator>>=(uint8_t d)
Right shift each of the channels by a constant.
CRGB & operator&=(const CRGB &rhs)
"and" operator brings each channel down to the lower of the two values