FastLED 3.9.15
Loading...
Searching...
No Matches
Pixel Data Types (CRGB/CHSV)

Detailed Description

Structs that hold pixel color data.

Classes

struct  CHSV
 Representation of an HSV pixel (hue, saturation, value (aka brightness)). More...
 
union  CHSV.__unnamed0__
 
struct  CHSV.__unnamed0__.__unnamed0__
 
union  CHSV.__unnamed0__.__unnamed0__.__unnamed0__
 
union  CHSV.__unnamed0__.__unnamed0__.__unnamed1__
 
union  CHSV.__unnamed0__.__unnamed0__.__unnamed2__
 
struct  CRGB
 Representation of an RGB pixel (Red, Green, Blue) More...
 
union  CRGB.__unnamed0__
 
struct  CRGB.__unnamed0__.__unnamed0__
 
union  CRGB.__unnamed0__.__unnamed0__.__unnamed0__
 
union  CRGB.__unnamed0__.__unnamed0__.__unnamed1__
 
union  CRGB.__unnamed0__.__unnamed0__.__unnamed2__
 

Enumerations

enum  HSVHue {
  HUE_RED = 0 , HUE_ORANGE = 32 , HUE_YELLOW = 64 , HUE_GREEN = 96 ,
  HUE_AQUA = 128 , HUE_BLUE = 160 , HUE_PURPLE = 192 , HUE_PINK = 224
}
 Pre-defined hue values for CHSV objects. More...
 

Functions

void hsv2rgb_rainbow (const struct CHSV &hsv, struct CRGB &rgb)
 Forward declaration of hsv2rgb_rainbow here, to avoid circular dependencies.
 
FASTLED_FORCE_INLINE bool operator!= (const CHSV &lhs, const CHSV &rhs)
 Check if two CHSV objects do not have the same color data.
 
FASTLED_FORCE_INLINE bool operator!= (const CRGB &lhs, const CRGB &rhs)
 Check if two CRGB objects do not have the same color data.
 
FASTLED_FORCE_INLINE CRGB operator% (const CRGB &p1, uint8_t d)
 Scale using CRGB::nscale8_video()
 
FASTLED_FORCE_INLINE CRGB operator& (const CRGB &p1, const CRGB &p2)
 Combine two CRGB objects, taking the smallest value of each channel.
 
FASTLED_FORCE_INLINE CRGB operator* (const CRGB &p1, uint8_t d)
 Multiply each of the channels by a constant, saturating each channel at 0xFF.
 
FASTLED_FORCE_INLINE CRGB operator+ (const CRGB &p1, const CRGB &p2)
 Add one CRGB to another, saturating at 0xFF for each channel.
 
FASTLED_FORCE_INLINE CRGB operator- (const CRGB &p1, const CRGB &p2)
 Subtract one CRGB from another, saturating at 0x00 for each channel.
 
FASTLED_FORCE_INLINE CRGB operator/ (const CRGB &p1, uint8_t d)
 Divide each of the channels by a constant.
 
FASTLED_FORCE_INLINE bool operator< (const CRGB &lhs, const CRGB &rhs)
 Check if the sum of the color channels in one CRGB object is less than another.
 
FASTLED_FORCE_INLINE 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.
 
FASTLED_FORCE_INLINE bool operator== (const CHSV &lhs, const CHSV &rhs)
 Check if two CHSV objects have the same color data.
 
FASTLED_FORCE_INLINE bool operator== (const CRGB &lhs, const CRGB &rhs)
 Check if two CRGB objects have the same color data.
 
FASTLED_FORCE_INLINE bool operator> (const CRGB &lhs, const CRGB &rhs)
 Check if the sum of the color channels in one CRGB object is greater than another.
 
FASTLED_FORCE_INLINE 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.
 
FASTLED_FORCE_INLINE CRGB operator| (const CRGB &p1, const CRGB &p2)
 Combine two CRGB objects, taking the largest value of each channel.
 

Where:

◆ CHSV.__unnamed0__.__unnamed0__

struct CHSV.__unnamed0__.__unnamed0__
Class Members
union CHSV.__unnamed0__.__unnamed0__.__unnamed2__ __unnamed__
union CHSV.__unnamed0__.__unnamed0__.__unnamed0__ __unnamed__
union CHSV.__unnamed0__.__unnamed0__.__unnamed1__ __unnamed__

◆ CHSV.__unnamed0__.__unnamed0__.__unnamed0__

union CHSV.__unnamed0__.__unnamed0__.__unnamed0__
Class Members
uint8_t h
uint8_t hue Color hue.

This is an 8-bit value representing an angle around the color wheel. Where 0 is 0°, and 255 is 358°.

◆ CHSV.__unnamed0__.__unnamed0__.__unnamed1__

union CHSV.__unnamed0__.__unnamed0__.__unnamed1__
Class Members
uint8_t s
uint8_t sat
uint8_t saturation Color saturation.

This is an 8-bit value representing a percentage.

◆ CHSV.__unnamed0__.__unnamed0__.__unnamed2__

union CHSV.__unnamed0__.__unnamed0__.__unnamed2__
Class Members
uint8_t v
uint8_t val
uint8_t value Color value (brightness).

This is an 8-bit value representing a percentage.

◆ CRGB.__unnamed0__

union CRGB.__unnamed0__
Class Members
struct CRGB.__unnamed0__.__unnamed0__ __unnamed__
uint8_t raw[3] Access the red, green, and blue data as an array.

Where:

  • raw[0] is the red value
  • raw[1] is the green value
  • raw[2] is the blue value

◆ CRGB.__unnamed0__.__unnamed0__

struct CRGB.__unnamed0__.__unnamed0__
Class Members
union CRGB.__unnamed0__.__unnamed0__.__unnamed1__ __unnamed__
union CRGB.__unnamed0__.__unnamed0__.__unnamed0__ __unnamed__
union CRGB.__unnamed0__.__unnamed0__.__unnamed2__ __unnamed__

◆ CRGB.__unnamed0__.__unnamed0__.__unnamed0__

union CRGB.__unnamed0__.__unnamed0__.__unnamed0__
Class Members
uint8_t r Red channel value.
uint8_t red

◆ CRGB.__unnamed0__.__unnamed0__.__unnamed1__

union CRGB.__unnamed0__.__unnamed0__.__unnamed1__
Class Members
uint8_t g Green channel value.
uint8_t green

◆ CRGB.__unnamed0__.__unnamed0__.__unnamed2__

union CRGB.__unnamed0__.__unnamed0__.__unnamed2__
Class Members
uint8_t b Blue channel value.
uint8_t blue

Enumeration Type Documentation

◆ HSVHue

enum HSVHue

Pre-defined hue values for CHSV objects.

Enumerator
HUE_RED 

Red (0°)

HUE_ORANGE 

Orange (45°)

HUE_YELLOW 

Yellow (90°)

HUE_GREEN 

Green (135°)

HUE_AQUA 

Aqua (180°)

HUE_BLUE 

Blue (225°)

HUE_PURPLE 

Purple (270°)

HUE_PINK 

Pink (315°)

Definition at line 97 of file chsv.h.

97 {
98 HUE_RED = 0,
99 HUE_ORANGE = 32,
100 HUE_YELLOW = 64,
101 HUE_GREEN = 96,
102 HUE_AQUA = 128,
103 HUE_BLUE = 160,
104 HUE_PURPLE = 192,
105 HUE_PINK = 224
106} HSVHue;
HSVHue
Pre-defined hue values for CHSV objects.
Definition chsv.h:97
@ HUE_ORANGE
Orange (45°)
Definition chsv.h:99
@ HUE_BLUE
Blue (225°)
Definition chsv.h:103
@ HUE_PINK
Pink (315°)
Definition chsv.h:105
@ HUE_YELLOW
Yellow (90°)
Definition chsv.h:100
@ HUE_PURPLE
Purple (270°)
Definition chsv.h:104
@ HUE_AQUA
Aqua (180°)
Definition chsv.h:102
@ HUE_GREEN
Green (135°)
Definition chsv.h:101
@ HUE_RED
Red (0°)
Definition chsv.h:98

Function Documentation

◆ hsv2rgb_rainbow()

void hsv2rgb_rainbow ( const struct CHSV & hsv,
struct CRGB & rgb )

Forward declaration of hsv2rgb_rainbow here, to avoid circular dependencies.

Convert an HSV value to RGB using a visually balanced rainbow. This "rainbow" yields better yellow and orange than a straight mathematical "spectrum".

FastLED 'Rainbow' Hue Chart

Parameters
hsvCHSV struct to convert to RGB. Max hue supported is HUE_MAX_RAINBOW
rgbCRGB struct to store the result of the conversion (will be modified)

Referenced by CRGB::CRGB(), CRGB::operator=(), CRGB::setHSV(), and CRGB::setHue().

+ Here is the caller graph for this function:

◆ operator!=() [1/2]

FASTLED_FORCE_INLINE bool operator!= ( const CHSV & lhs,
const CHSV & rhs )

Check if two CHSV objects do not have the same color data.

Definition at line 672 of file crgb.h.

673{
674 return !(lhs == rhs);
675}

References FASTLED_FORCE_INLINE.

◆ operator!=() [2/2]

FASTLED_FORCE_INLINE bool operator!= ( const CRGB & lhs,
const CRGB & rhs )

Check if two CRGB objects do not have the same color data.

Definition at line 660 of file crgb.h.

661{
662 return !(lhs == rhs);
663}

References FASTLED_FORCE_INLINE.

◆ operator%()

FASTLED_FORCE_INLINE CRGB operator% ( const CRGB & p1,
uint8_t d )

Scale using CRGB::nscale8_video()

Definition at line 224 of file crgb.hpp.

225{
226 CRGB retval( p1);
227 retval.nscale8_video( d);
228 return retval;
229}
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54

References FASTLED_FORCE_INLINE, and CRGB::nscale8_video().

+ Here is the call graph for this function:

◆ operator&()

FASTLED_FORCE_INLINE CRGB operator& ( const CRGB & p1,
const CRGB & p2 )

Combine two CRGB objects, taking the smallest value of each channel.

Definition at line 723 of file crgb.h.

724{
725 return CRGB( p1.r < p2.r ? p1.r : p2.r,
726 p1.g < p2.g ? p1.g : p2.g,
727 p1.b < p2.b ? p1.b : p2.b);
728}

References FASTLED_FORCE_INLINE.

◆ operator*()

FASTLED_FORCE_INLINE CRGB operator* ( const CRGB & p1,
uint8_t d )

Multiply each of the channels by a constant, saturating each channel at 0xFF.

Definition at line 216 of file crgb.hpp.

217{
218 return CRGB( qmul8( p1.r, d),
219 qmul8( p1.g, d),
220 qmul8( p1.b, d));
221}
LIB8STATIC_ALWAYS_INLINE uint8_t qmul8(uint8_t i, uint8_t j)
8x8 bit multiplication with 8-bit result, saturating at 0xFF.
Definition math8.h:470

References FASTLED_FORCE_INLINE, and qmul8().

+ Here is the call graph for this function:

◆ operator+()

FASTLED_FORCE_INLINE CRGB operator+ ( const CRGB & p1,
const CRGB & p2 )

Add one CRGB to another, saturating at 0xFF for each channel.

Definition at line 200 of file crgb.hpp.

201{
202 return CRGB( qadd8( p1.r, p2.r),
203 qadd8( p1.g, p2.g),
204 qadd8( p1.b, p2.b));
205}
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
Definition math8.h:31

References FASTLED_FORCE_INLINE, and qadd8().

+ Here is the call graph for this function:

◆ operator-()

FASTLED_FORCE_INLINE CRGB operator- ( const CRGB & p1,
const CRGB & p2 )

Subtract one CRGB from another, saturating at 0x00 for each channel.

Definition at line 208 of file crgb.hpp.

209{
210 return CRGB( qsub8( p1.r, p2.r),
211 qsub8( p1.g, p2.g),
212 qsub8( p1.b, p2.b));
213}
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
Subtract one byte from another, saturating at 0x00.
Definition math8.h:103

References FASTLED_FORCE_INLINE, and qsub8().

+ Here is the call graph for this function:

◆ operator/()

FASTLED_FORCE_INLINE CRGB operator/ ( const CRGB & p1,
uint8_t d )

Divide each of the channels by a constant.

Definition at line 716 of file crgb.h.

717{
718 return CRGB( p1.r/d, p1.g/d, p1.b/d);
719}

References FASTLED_FORCE_INLINE.

◆ operator<()

FASTLED_FORCE_INLINE bool operator< ( const CRGB & lhs,
const CRGB & rhs )

Check if the sum of the color channels in one CRGB object is less than another.

Definition at line 678 of file crgb.h.

679{
680 uint16_t sl, sr;
681 sl = lhs.r + lhs.g + lhs.b;
682 sr = rhs.r + rhs.g + rhs.b;
683 return sl < sr;
684}

References FASTLED_FORCE_INLINE.

◆ operator<=()

FASTLED_FORCE_INLINE 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.

Definition at line 705 of file crgb.h.

706{
707 uint16_t sl, sr;
708 sl = lhs.r + lhs.g + lhs.b;
709 sr = rhs.r + rhs.g + rhs.b;
710 return sl <= sr;
711}

References FASTLED_FORCE_INLINE.

◆ operator==() [1/2]

FASTLED_FORCE_INLINE bool operator== ( const CHSV & lhs,
const CHSV & rhs )

Check if two CHSV objects have the same color data.

Definition at line 666 of file crgb.h.

667{
668 return (lhs.h == rhs.h) && (lhs.s == rhs.s) && (lhs.v == rhs.v);
669}

References FASTLED_FORCE_INLINE.

◆ operator==() [2/2]

FASTLED_FORCE_INLINE bool operator== ( const CRGB & lhs,
const CRGB & rhs )

Check if two CRGB objects have the same color data.

Definition at line 654 of file crgb.h.

655{
656 return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
657}

References FASTLED_FORCE_INLINE.

◆ operator>()

FASTLED_FORCE_INLINE bool operator> ( const CRGB & lhs,
const CRGB & rhs )

Check if the sum of the color channels in one CRGB object is greater than another.

Definition at line 687 of file crgb.h.

688{
689 uint16_t sl, sr;
690 sl = lhs.r + lhs.g + lhs.b;
691 sr = rhs.r + rhs.g + rhs.b;
692 return sl > sr;
693}

References FASTLED_FORCE_INLINE.

◆ operator>=()

FASTLED_FORCE_INLINE 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.

Definition at line 696 of file crgb.h.

697{
698 uint16_t sl, sr;
699 sl = lhs.r + lhs.g + lhs.b;
700 sr = rhs.r + rhs.g + rhs.b;
701 return sl >= sr;
702}

References FASTLED_FORCE_INLINE.

◆ operator|()

FASTLED_FORCE_INLINE CRGB operator| ( const CRGB & p1,
const CRGB & p2 )

Combine two CRGB objects, taking the largest value of each channel.

Definition at line 731 of file crgb.h.

732{
733 return CRGB( p1.r > p2.r ? p1.r : p2.r,
734 p1.g > p2.g ? p1.g : p2.g,
735 p1.b > p2.b ? p1.b : p2.b);
736}

References FASTLED_FORCE_INLINE.