FastLED  3.1
pixeltypes.h
1 #ifndef __INC_PIXELS_H
2 #define __INC_PIXELS_H
3 
4 #include "FastLED.h"
5 
6 #include <stdint.h>
7 #include "lib8tion.h"
8 #include "color.h"
9 
10 FASTLED_NAMESPACE_BEGIN
11 
12 struct CRGB;
13 struct CHSV;
14 
17 
20 extern void hsv2rgb_rainbow( const CHSV& hsv, CRGB& rgb);
21 
23 struct CHSV {
24  union {
25  struct {
26  union {
27  uint8_t hue;
28  uint8_t h; };
29  union {
30  uint8_t saturation;
31  uint8_t sat;
32  uint8_t s; };
33  union {
34  uint8_t value;
35  uint8_t val;
36  uint8_t v; };
37  };
38  uint8_t raw[3];
39  };
40 
42  inline CHSV() __attribute__((always_inline))
43  {
44  }
45 
47  inline CHSV( uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
48  : h(ih), s(is), v(iv)
49  {
50  }
51 
53  inline CHSV(const CHSV& rhs) __attribute__((always_inline))
54  {
55  h = rhs.h;
56  s = rhs.s;
57  v = rhs.v;
58  }
59 
60  inline CHSV& operator= (const CHSV& rhs) __attribute__((always_inline))
61  {
62  h = rhs.h;
63  s = rhs.s;
64  v = rhs.v;
65  return *this;
66  }
67 
68  inline CHSV& setHSV(uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
69  {
70  h = ih;
71  s = is;
72  v = iv;
73  return *this;
74  }
75 };
76 
78 typedef enum {
79  HUE_RED = 0,
80  HUE_ORANGE = 32,
81  HUE_YELLOW = 64,
82  HUE_GREEN = 96,
83  HUE_AQUA = 128,
84  HUE_BLUE = 160,
85  HUE_PURPLE = 192,
86  HUE_PINK = 224
87 } HSVHue;
88 
90 struct CRGB {
91  union {
92  struct {
93  union {
94  uint8_t r;
95  uint8_t red;
96  };
97  union {
98  uint8_t g;
99  uint8_t green;
100  };
101  union {
102  uint8_t b;
103  uint8_t blue;
104  };
105  };
106  uint8_t raw[3];
107  };
108 
110  inline uint8_t& operator[] (uint8_t x) __attribute__((always_inline))
111  {
112  return raw[x];
113  }
114 
116  inline const uint8_t& operator[] (uint8_t x) const __attribute__((always_inline))
117  {
118  return raw[x];
119  }
120 
121  // default values are UNINITIALIZED
122  inline CRGB() __attribute__((always_inline))
123  {
124  }
125 
127  inline CRGB( uint8_t ir, uint8_t ig, uint8_t ib) __attribute__((always_inline))
128  : r(ir), g(ig), b(ib)
129  {
130  }
131 
133  inline CRGB( uint32_t colorcode) __attribute__((always_inline))
134  : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
135  {
136  }
137 
139  inline CRGB( LEDColorCorrection colorcode) __attribute__((always_inline))
140  : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
141  {
142 
143  }
144 
146  inline CRGB( ColorTemperature colorcode) __attribute__((always_inline))
147  : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
148  {
149 
150  }
151 
153  inline CRGB(const CRGB& rhs) __attribute__((always_inline))
154  {
155  r = rhs.r;
156  g = rhs.g;
157  b = rhs.b;
158  }
159 
161  inline CRGB(const CHSV& rhs) __attribute__((always_inline))
162  {
163  hsv2rgb_rainbow( rhs, *this);
164  }
165 
167  inline CRGB& operator= (const CRGB& rhs) __attribute__((always_inline))
168  {
169  r = rhs.r;
170  g = rhs.g;
171  b = rhs.b;
172  return *this;
173  }
174 
176  inline CRGB& operator= (const uint32_t colorcode) __attribute__((always_inline))
177  {
178  r = (colorcode >> 16) & 0xFF;
179  g = (colorcode >> 8) & 0xFF;
180  b = (colorcode >> 0) & 0xFF;
181  return *this;
182  }
183 
185  inline CRGB& setRGB (uint8_t nr, uint8_t ng, uint8_t nb) __attribute__((always_inline))
186  {
187  r = nr;
188  g = ng;
189  b = nb;
190  return *this;
191  }
192 
194  inline CRGB& setHSV (uint8_t hue, uint8_t sat, uint8_t val) __attribute__((always_inline))
195  {
196  hsv2rgb_rainbow( CHSV(hue, sat, val), *this);
197  return *this;
198  }
199 
201  inline CRGB& setHue (uint8_t hue) __attribute__((always_inline))
202  {
203  hsv2rgb_rainbow( CHSV(hue, 255, 255), *this);
204  return *this;
205  }
206 
208  inline CRGB& operator= (const CHSV& rhs) __attribute__((always_inline))
209  {
210  hsv2rgb_rainbow( rhs, *this);
211  return *this;
212  }
213 
215  inline CRGB& setColorCode (uint32_t colorcode) __attribute__((always_inline))
216  {
217  r = (colorcode >> 16) & 0xFF;
218  g = (colorcode >> 8) & 0xFF;
219  b = (colorcode >> 0) & 0xFF;
220  return *this;
221  }
222 
223 
225  inline CRGB& operator+= (const CRGB& rhs )
226  {
227  r = qadd8( r, rhs.r);
228  g = qadd8( g, rhs.g);
229  b = qadd8( b, rhs.b);
230  return *this;
231  }
232 
237  inline CRGB& addToRGB (uint8_t d )
238  {
239  r = qadd8( r, d);
240  g = qadd8( g, d);
241  b = qadd8( b, d);
242  return *this;
243  }
244 
246  inline CRGB& operator-= (const CRGB& rhs )
247  {
248  r = qsub8( r, rhs.r);
249  g = qsub8( g, rhs.g);
250  b = qsub8( b, rhs.b);
251  return *this;
252  }
253 
258  inline CRGB& subtractFromRGB(uint8_t d )
259  {
260  r = qsub8( r, d);
261  g = qsub8( g, d);
262  b = qsub8( b, d);
263  return *this;
264  }
265 
267  inline CRGB& operator-- () __attribute__((always_inline))
268  {
269  subtractFromRGB(1);
270  return *this;
271  }
272 
274  inline CRGB operator-- (int ) __attribute__((always_inline))
275  {
276  CRGB retval(*this);
277  --(*this);
278  return retval;
279  }
280 
282  inline CRGB& operator++ () __attribute__((always_inline))
283  {
284  addToRGB(1);
285  return *this;
286  }
287 
289  inline CRGB operator++ (int ) __attribute__((always_inline))
290  {
291  CRGB retval(*this);
292  ++(*this);
293  return retval;
294  }
295 
297  inline CRGB& operator/= (uint8_t d )
298  {
299  r /= d;
300  g /= d;
301  b /= d;
302  return *this;
303  }
304 
306  inline CRGB& operator>>= (uint8_t d)
307  {
308  r >>= d;
309  g >>= d;
310  b >>= d;
311  return *this;
312  }
313 
316  inline CRGB& operator*= (uint8_t d )
317  {
318  r = qmul8( r, d);
319  g = qmul8( g, d);
320  b = qmul8( b, d);
321  return *this;
322  }
323 
329  inline CRGB& nscale8_video (uint8_t scaledown )
330  {
331  nscale8x3_video( r, g, b, scaledown);
332  return *this;
333  }
334 
337  inline CRGB& operator%= (uint8_t scaledown )
338  {
339  nscale8x3_video( r, g, b, scaledown);
340  return *this;
341  }
342 
344  inline CRGB& fadeLightBy (uint8_t fadefactor )
345  {
346  nscale8x3_video( r, g, b, 255 - fadefactor);
347  return *this;
348  }
349 
353  inline CRGB& nscale8 (uint8_t scaledown )
354  {
355  nscale8x3( r, g, b, scaledown);
356  return *this;
357  }
358 
362  inline CRGB& nscale8 (const CRGB & scaledown )
363  {
364  r = ::scale8(r, scaledown.r);
365  g = ::scale8(g, scaledown.g);
366  b = ::scale8(b, scaledown.b);
367  return *this;
368  }
369 
371  inline CRGB scale8 (const CRGB & scaledown ) const
372  {
373  CRGB out;
374  out.r = ::scale8(r, scaledown.r);
375  out.g = ::scale8(g, scaledown.g);
376  out.b = ::scale8(b, scaledown.b);
377  return out;
378  }
379 
381  inline CRGB& fadeToBlackBy (uint8_t fadefactor )
382  {
383  nscale8x3( r, g, b, 255 - fadefactor);
384  return *this;
385  }
386 
388  inline CRGB& operator|= (const CRGB& rhs )
389  {
390  if( rhs.r > r) r = rhs.r;
391  if( rhs.g > g) g = rhs.g;
392  if( rhs.b > b) b = rhs.b;
393  return *this;
394  }
395 
397  inline CRGB& operator|= (uint8_t d )
398  {
399  if( d > r) r = d;
400  if( d > g) g = d;
401  if( d > b) b = d;
402  return *this;
403  }
404 
406  inline CRGB& operator&= (const CRGB& rhs )
407  {
408  if( rhs.r < r) r = rhs.r;
409  if( rhs.g < g) g = rhs.g;
410  if( rhs.b < b) b = rhs.b;
411  return *this;
412  }
413 
415  inline CRGB& operator&= (uint8_t d )
416  {
417  if( d < r) r = d;
418  if( d < g) g = d;
419  if( d < b) b = d;
420  return *this;
421  }
422 
424  inline operator bool() const __attribute__((always_inline))
425  {
426  return r || g || b;
427  }
428 
430  inline CRGB operator- ()
431  {
432  CRGB retval;
433  retval.r = 255 - r;
434  retval.g = 255 - g;
435  retval.b = 255 - b;
436  return retval;
437  }
438 
439 #if (defined SmartMatrix_h || defined SmartMatrix3_h)
440  operator rgb24() const {
441  rgb24 ret;
442  ret.red = r;
443  ret.green = g;
444  ret.blue = b;
445  return ret;
446  }
447 #endif
448 
451  inline uint8_t getLuma ( ) const {
452  //Y' = 0.2126 R' + 0.7152 G' + 0.0722 B'
453  // 54 183 18 (!)
454 
455  uint8_t luma = scale8_LEAVING_R1_DIRTY( r, 54) + \
456  scale8_LEAVING_R1_DIRTY( g, 183) + \
458  cleanup_R1();
459  return luma;
460  }
461 
463  inline uint8_t getAverageLight( ) const {
464 #if FASTLED_SCALE8_FIXED == 1
465  const uint8_t eightyfive = 85;
466 #else
467  const uint8_t eightyfive = 86;
468 #endif
469  uint8_t avg = scale8_LEAVING_R1_DIRTY( r, eightyfive) + \
470  scale8_LEAVING_R1_DIRTY( g, eightyfive) + \
471  scale8_LEAVING_R1_DIRTY( b, eightyfive);
472  cleanup_R1();
473  return avg;
474  }
475 
477  inline void maximizeBrightness( uint8_t limit = 255 ) {
478  uint8_t max = red;
479  if( green > max) max = green;
480  if( blue > max) max = blue;
481  uint16_t factor = ((uint16_t)(limit) * 256) / max;
482  red = (red * factor) / 256;
483  green = (green * factor) / 256;
484  blue = (blue * factor) / 256;
485  }
486 
488  inline CRGB lerp8( CRGB & other, fract8 frac)
489  {
490  CRGB ret;
491 
492  ret.r = lerp8by8(r,other.r,frac);
493  ret.g = lerp8by8(g,other.g,frac);
494  ret.b = lerp8by8(b,other.b,frac);
495 
496  return ret;
497  }
498 
500  inline CRGB lerp16( CRGB & other, fract16 frac)
501  {
502  CRGB ret;
503 
504  ret.r = lerp16by16(r<<8,other.r<<8,frac)>>8;
505  ret.g = lerp16by16(g<<8,other.g<<8,frac)>>8;
506  ret.b = lerp16by16(b<<8,other.b<<8,frac)>>8;
507 
508  return ret;
509  }
510 
513  inline uint8_t getParity()
514  {
515  uint8_t sum = r + g + b;
516  return (sum & 0x01);
517  }
518 
542  inline void setParity( uint8_t parity)
543  {
544  uint8_t curparity = getParity();
545 
546  if( parity == curparity) return;
547 
548  if( parity ) {
549  // going 'up'
550  if( (b > 0) && (b < 255)) {
551  if( r == g && g == b) {
552  r++;
553  g++;
554  }
555  b++;
556  } else if( (r > 0) && (r < 255)) {
557  r++;
558  } else if( (g > 0) && (g < 255)) {
559  g++;
560  } else {
561  if( r == g && g == b) {
562  r ^= 0x01;
563  g ^= 0x01;
564  }
565  b ^= 0x01;
566  }
567  } else {
568  // going 'down'
569  if( b > 1) {
570  if( r == g && g == b) {
571  r--;
572  g--;
573  }
574  b--;
575  } else if( g > 1) {
576  g--;
577  } else if( r > 1) {
578  r--;
579  } else {
580  if( r == g && g == b) {
581  r ^= 0x01;
582  g ^= 0x01;
583  }
584  b ^= 0x01;
585  }
586  }
587  }
588 
590  typedef enum {
591  AliceBlue=0xF0F8FF,
592  Amethyst=0x9966CC,
593  AntiqueWhite=0xFAEBD7,
594  Aqua=0x00FFFF,
595  Aquamarine=0x7FFFD4,
596  Azure=0xF0FFFF,
597  Beige=0xF5F5DC,
598  Bisque=0xFFE4C4,
599  Black=0x000000,
600  BlanchedAlmond=0xFFEBCD,
601  Blue=0x0000FF,
602  BlueViolet=0x8A2BE2,
603  Brown=0xA52A2A,
604  BurlyWood=0xDEB887,
605  CadetBlue=0x5F9EA0,
606  Chartreuse=0x7FFF00,
607  Chocolate=0xD2691E,
608  Coral=0xFF7F50,
609  CornflowerBlue=0x6495ED,
610  Cornsilk=0xFFF8DC,
611  Crimson=0xDC143C,
612  Cyan=0x00FFFF,
613  DarkBlue=0x00008B,
614  DarkCyan=0x008B8B,
615  DarkGoldenrod=0xB8860B,
616  DarkGray=0xA9A9A9,
617  DarkGrey=0xA9A9A9,
618  DarkGreen=0x006400,
619  DarkKhaki=0xBDB76B,
620  DarkMagenta=0x8B008B,
621  DarkOliveGreen=0x556B2F,
622  DarkOrange=0xFF8C00,
623  DarkOrchid=0x9932CC,
624  DarkRed=0x8B0000,
625  DarkSalmon=0xE9967A,
626  DarkSeaGreen=0x8FBC8F,
627  DarkSlateBlue=0x483D8B,
628  DarkSlateGray=0x2F4F4F,
629  DarkSlateGrey=0x2F4F4F,
630  DarkTurquoise=0x00CED1,
631  DarkViolet=0x9400D3,
632  DeepPink=0xFF1493,
633  DeepSkyBlue=0x00BFFF,
634  DimGray=0x696969,
635  DimGrey=0x696969,
636  DodgerBlue=0x1E90FF,
637  FireBrick=0xB22222,
638  FloralWhite=0xFFFAF0,
639  ForestGreen=0x228B22,
640  Fuchsia=0xFF00FF,
641  Gainsboro=0xDCDCDC,
642  GhostWhite=0xF8F8FF,
643  Gold=0xFFD700,
644  Goldenrod=0xDAA520,
645  Gray=0x808080,
646  Grey=0x808080,
647  Green=0x008000,
648  GreenYellow=0xADFF2F,
649  Honeydew=0xF0FFF0,
650  HotPink=0xFF69B4,
651  IndianRed=0xCD5C5C,
652  Indigo=0x4B0082,
653  Ivory=0xFFFFF0,
654  Khaki=0xF0E68C,
655  Lavender=0xE6E6FA,
656  LavenderBlush=0xFFF0F5,
657  LawnGreen=0x7CFC00,
658  LemonChiffon=0xFFFACD,
659  LightBlue=0xADD8E6,
660  LightCoral=0xF08080,
661  LightCyan=0xE0FFFF,
662  LightGoldenrodYellow=0xFAFAD2,
663  LightGreen=0x90EE90,
664  LightGrey=0xD3D3D3,
665  LightPink=0xFFB6C1,
666  LightSalmon=0xFFA07A,
667  LightSeaGreen=0x20B2AA,
668  LightSkyBlue=0x87CEFA,
669  LightSlateGray=0x778899,
670  LightSlateGrey=0x778899,
671  LightSteelBlue=0xB0C4DE,
672  LightYellow=0xFFFFE0,
673  Lime=0x00FF00,
674  LimeGreen=0x32CD32,
675  Linen=0xFAF0E6,
676  Magenta=0xFF00FF,
677  Maroon=0x800000,
678  MediumAquamarine=0x66CDAA,
679  MediumBlue=0x0000CD,
680  MediumOrchid=0xBA55D3,
681  MediumPurple=0x9370DB,
682  MediumSeaGreen=0x3CB371,
683  MediumSlateBlue=0x7B68EE,
684  MediumSpringGreen=0x00FA9A,
685  MediumTurquoise=0x48D1CC,
686  MediumVioletRed=0xC71585,
687  MidnightBlue=0x191970,
688  MintCream=0xF5FFFA,
689  MistyRose=0xFFE4E1,
690  Moccasin=0xFFE4B5,
691  NavajoWhite=0xFFDEAD,
692  Navy=0x000080,
693  OldLace=0xFDF5E6,
694  Olive=0x808000,
695  OliveDrab=0x6B8E23,
696  Orange=0xFFA500,
697  OrangeRed=0xFF4500,
698  Orchid=0xDA70D6,
699  PaleGoldenrod=0xEEE8AA,
700  PaleGreen=0x98FB98,
701  PaleTurquoise=0xAFEEEE,
702  PaleVioletRed=0xDB7093,
703  PapayaWhip=0xFFEFD5,
704  PeachPuff=0xFFDAB9,
705  Peru=0xCD853F,
706  Pink=0xFFC0CB,
707  Plaid=0xCC5533,
708  Plum=0xDDA0DD,
709  PowderBlue=0xB0E0E6,
710  Purple=0x800080,
711  Red=0xFF0000,
712  RosyBrown=0xBC8F8F,
713  RoyalBlue=0x4169E1,
714  SaddleBrown=0x8B4513,
715  Salmon=0xFA8072,
716  SandyBrown=0xF4A460,
717  SeaGreen=0x2E8B57,
718  Seashell=0xFFF5EE,
719  Sienna=0xA0522D,
720  Silver=0xC0C0C0,
721  SkyBlue=0x87CEEB,
722  SlateBlue=0x6A5ACD,
723  SlateGray=0x708090,
724  SlateGrey=0x708090,
725  Snow=0xFFFAFA,
726  SpringGreen=0x00FF7F,
727  SteelBlue=0x4682B4,
728  Tan=0xD2B48C,
729  Teal=0x008080,
730  Thistle=0xD8BFD8,
731  Tomato=0xFF6347,
732  Turquoise=0x40E0D0,
733  Violet=0xEE82EE,
734  Wheat=0xF5DEB3,
735  White=0xFFFFFF,
736  WhiteSmoke=0xF5F5F5,
737  Yellow=0xFFFF00,
738  YellowGreen=0x9ACD32,
739 
740  // LED RGB color that roughly approximates
741  // the color of incandescent fairy lights,
742  // assuming that you're using FastLED
743  // color correction on your LEDs (recommended).
744  FairyLight=0xFFE42D,
745  // If you are using no color correction, use this
746  FairyLightNCC=0xFF9D2A
747 
748  } HTMLColorCode;
749 };
750 
751 
752 inline __attribute__((always_inline)) bool operator== (const CRGB& lhs, const CRGB& rhs)
753 {
754  return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
755 }
756 
757 inline __attribute__((always_inline)) bool operator!= (const CRGB& lhs, const CRGB& rhs)
758 {
759  return !(lhs == rhs);
760 }
761 
762 inline __attribute__((always_inline)) bool operator< (const CRGB& lhs, const CRGB& rhs)
763 {
764  uint16_t sl, sr;
765  sl = lhs.r + lhs.g + lhs.b;
766  sr = rhs.r + rhs.g + rhs.b;
767  return sl < sr;
768 }
769 
770 inline __attribute__((always_inline)) bool operator> (const CRGB& lhs, const CRGB& rhs)
771 {
772  uint16_t sl, sr;
773  sl = lhs.r + lhs.g + lhs.b;
774  sr = rhs.r + rhs.g + rhs.b;
775  return sl > sr;
776 }
777 
778 inline __attribute__((always_inline)) bool operator>= (const CRGB& lhs, const CRGB& rhs)
779 {
780  uint16_t sl, sr;
781  sl = lhs.r + lhs.g + lhs.b;
782  sr = rhs.r + rhs.g + rhs.b;
783  return sl >= sr;
784 }
785 
786 inline __attribute__((always_inline)) bool operator<= (const CRGB& lhs, const CRGB& rhs)
787 {
788  uint16_t sl, sr;
789  sl = lhs.r + lhs.g + lhs.b;
790  sr = rhs.r + rhs.g + rhs.b;
791  return sl <= sr;
792 }
793 
794 
795 __attribute__((always_inline))
796 inline CRGB operator+( const CRGB& p1, const CRGB& p2)
797 {
798  return CRGB( qadd8( p1.r, p2.r),
799  qadd8( p1.g, p2.g),
800  qadd8( p1.b, p2.b));
801 }
802 
803 __attribute__((always_inline))
804 inline CRGB operator-( const CRGB& p1, const CRGB& p2)
805 {
806  return CRGB( qsub8( p1.r, p2.r),
807  qsub8( p1.g, p2.g),
808  qsub8( p1.b, p2.b));
809 }
810 
811 __attribute__((always_inline))
812 inline CRGB operator*( const CRGB& p1, uint8_t d)
813 {
814  return CRGB( qmul8( p1.r, d),
815  qmul8( p1.g, d),
816  qmul8( p1.b, d));
817 }
818 
819 __attribute__((always_inline))
820 inline CRGB operator/( const CRGB& p1, uint8_t d)
821 {
822  return CRGB( p1.r/d, p1.g/d, p1.b/d);
823 }
824 
825 
826 __attribute__((always_inline))
827 inline CRGB operator&( const CRGB& p1, const CRGB& p2)
828 {
829  return CRGB( p1.r < p2.r ? p1.r : p2.r,
830  p1.g < p2.g ? p1.g : p2.g,
831  p1.b < p2.b ? p1.b : p2.b);
832 }
833 
834 __attribute__((always_inline))
835 inline CRGB operator|( const CRGB& p1, const CRGB& p2)
836 {
837  return CRGB( p1.r > p2.r ? p1.r : p2.r,
838  p1.g > p2.g ? p1.g : p2.g,
839  p1.b > p2.b ? p1.b : p2.b);
840 }
841 
842 __attribute__((always_inline))
843 inline CRGB operator%( const CRGB& p1, uint8_t d)
844 {
845  CRGB retval( p1);
846  retval.nscale8_video( d);
847  return retval;
848 }
849 
850 
851 
855 enum EOrder {
856  RGB=0012,
857  RBG=0021,
858  GRB=0102,
859  GBR=0120,
860  BRG=0201,
861  BGR=0210
862 };
863 
864 FASTLED_NAMESPACE_END
866 
867 #endif
CRGB & setHue(uint8_t hue) __attribute__((always_inline))
allow assignment from just a Hue, saturation and value automatically at max.
Definition: pixeltypes.h:201
CRGB & nscale8(const CRGB &scaledown)
scale down a RGB to N 256ths of it's current brightness, using 'plain math' dimming rules...
Definition: pixeltypes.h:362
uint8_t getLuma() const
Get the 'luma' of a CRGB object - aka roughly how much light the CRGB pixel is putting out (from 0 to...
Definition: pixeltypes.h:451
CRGB & operator/=(uint8_t d)
divide each of the channels by a constant
Definition: pixeltypes.h:297
HSVHue
Pre-defined hue values for HSV objects.
Definition: pixeltypes.h:78
Representation of an RGB pixel (Red, Green, Blue)
Definition: pixeltypes.h:90
CHSV() __attribute__((always_inline))
default values are UNITIALIZED
Definition: pixeltypes.h:42
CRGB & setHSV(uint8_t hue, uint8_t sat, uint8_t val) __attribute__((always_inline))
allow assignment from H, S, and V
Definition: pixeltypes.h:194
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
Definition: scale8.h:299
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
subtract one byte from another, saturating at 0x00
Definition: math8.h:86
LIB8STATIC uint8_t lerp8by8(uint8_t a, uint8_t b, fract8 frac)
linear interpolation between two unsigned 8-bit values, with 8-bit fraction
Definition: lib8tion.h:457
CRGB lerp8(CRGB &other, fract8 frac)
return a new CRGB object after performing a linear interpolation between this object and the passed i...
Definition: pixeltypes.h:488
uint16_t fract16
ANSI: unsigned _Fract.
Definition: lib8tion.h:343
LIB8STATIC uint16_t lerp16by16(uint16_t a, uint16_t b, fract16 frac)
linear interpolation between two unsigned 16-bit values, with 16-bit fraction
Definition: lib8tion.h:474
CRGB operator-()
invert each channel
Definition: pixeltypes.h:430
LIB8STATIC_ALWAYS_INLINE uint8_t qmul8(uint8_t i, uint8_t j)
saturating 8x8 bit multiplication, with 8 bit result
Definition: math8.h:320
uint8_t getParity()
getParity returns 0 or 1, depending on the lowest bit of the sum of the color components.
Definition: pixeltypes.h:513
CRGB & subtractFromRGB(uint8_t d)
subtract a constant from each channel, saturating at 0x00 this is NOT an operator+= overload because ...
Definition: pixeltypes.h:258
CRGB & setColorCode(uint32_t colorcode) __attribute__((always_inline))
allow assignment from 32-bit (really 24-bit) 0xRRGGBB color code
Definition: pixeltypes.h:215
CRGB(ColorTemperature colorcode) __attribute__((always_inline))
allow construction from a ColorTemperature enum
Definition: pixeltypes.h:146
CRGB & operator%=(uint8_t scaledown)
%= is a synonym for nscale8_video.
Definition: pixeltypes.h:337
CRGB & setRGB(uint8_t nr, uint8_t ng, uint8_t nb) __attribute__((always_inline))
allow assignment from R, G, and B
Definition: pixeltypes.h:185
CRGB & operator>>=(uint8_t d)
right shift each of the channels by a constant
Definition: pixeltypes.h:306
CRGB & operator-=(const CRGB &rhs)
subtract one RGB from another, saturating at 0x00 for each channel
Definition: pixeltypes.h:246
CRGB(const CHSV &rhs) __attribute__((always_inline))
allow construction from HSV color
Definition: pixeltypes.h:161
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...
Definition: scale8.h:344
CRGB & operator|=(const CRGB &rhs)
"or" operator brings each channel up to the higher of the two values
Definition: pixeltypes.h:388
CRGB(const CRGB &rhs) __attribute__((always_inline))
allow copy construction
Definition: pixeltypes.h:153
uint8_t fract8
ANSI unsigned short _Fract.
Definition: lib8tion.h:335
CRGB(uint8_t ir, uint8_t ig, uint8_t ib) __attribute__((always_inline))
allow construction from R, G, B
Definition: pixeltypes.h:127
CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8( ..., 255-fadefactor)
Definition: pixeltypes.h:381
CRGB & nscale8_video(uint8_t scaledown)
scale down a RGB to N 256ths of it's current brightness, using 'video' dimming rules, which means that unless the scale factor is ZERO each channel is guaranteed NOT to dim down to zero.
Definition: pixeltypes.h:329
CRGB & operator--() __attribute__((always_inline))
subtract a constant of '1' from each channel, saturating at 0x00
Definition: pixeltypes.h:267
CRGB & nscale8(uint8_t scaledown)
scale down a RGB to N 256ths of it's current brightness, using 'plain math' dimming rules...
Definition: pixeltypes.h:353
uint8_t getAverageLight() const
Get the average of the R, G, and B values.
Definition: pixeltypes.h:463
CRGB & operator+=(const CRGB &rhs)
add one RGB to another, saturating at 0xFF for each channel
Definition: pixeltypes.h:225
LEDColorCorrection
Definition: color.h:13
CRGB & operator++() __attribute__((always_inline))
add a constant of '1' from each channel, saturating at 0xFF
Definition: pixeltypes.h:282
central include file for FastLED, defines the CFastLED class/object
CRGB & operator*=(uint8_t d)
multiply each of the channels by a constant, saturating each channel at 0xFF
Definition: pixeltypes.h:316
contains definitions for color correction and temperature
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
add one byte to another, saturating at 0xFF
Definition: math8.h:21
void maximizeBrightness(uint8_t limit=255)
maximize the brightness of this CRGB object
Definition: pixeltypes.h:477
CRGB & operator&=(const CRGB &rhs)
"and" operator brings each channel down to the lower of the two values
Definition: pixeltypes.h:406
CRGB & fadeLightBy(uint8_t fadefactor)
fadeLightBy is a synonym for nscale8_video( ..., 255-fadefactor)
Definition: pixeltypes.h:344
CRGB & operator=(const CRGB &rhs) __attribute__((always_inline))
allow assignment from one RGB struct to another
Definition: pixeltypes.h:167
void hsv2rgb_rainbow(const CHSV &hsv, CRGB &rgb)
Forward declaration of hsv2rgb_rainbow here, to avoid circular dependencies.
Definition: hsv2rgb.cpp:278
CRGB(LEDColorCorrection colorcode) __attribute__((always_inline))
allow construction from a LEDColorCorrection enum
Definition: pixeltypes.h:139
CRGB lerp16(CRGB &other, fract16 frac)
return a new CRGB object after performing a linear interpolation between this object and the passed i...
Definition: pixeltypes.h:500
CRGB scale8(const CRGB &scaledown) const
return a CRGB object that is a scaled down version of this object
Definition: pixeltypes.h:371
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...
Definition: scale8.h:314
__attribute__((always_inline)) bool operator
Do an 8byte by 8bit rotation.
Definition: fastled_delay.h:92
ColorTemperature
Definition: color.h:35
CRGB(uint32_t colorcode) __attribute__((always_inline))
allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code
Definition: pixeltypes.h:133
void setParity(uint8_t parity)
setParity adjusts the color in the smallest way possible so that the parity of the color is now the d...
Definition: pixeltypes.h:542
CRGB & addToRGB(uint8_t d)
add a contstant to each channel, saturating at 0xFF this is NOT an operator+= overload because the co...
Definition: pixeltypes.h:237
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition: pixeltypes.h:23
uint8_t & operator[](uint8_t x) __attribute__((always_inline))
Array access operator to index into the crgb object.
Definition: pixeltypes.h:110
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 If you are doing several 'scale8's in...
Definition: scale8.h:146
CHSV(const CHSV &rhs) __attribute__((always_inline))
allow copy construction
Definition: pixeltypes.h:53
HTMLColorCode
Predefined RGB colors.
Definition: pixeltypes.h:590
CHSV(uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
allow construction from H, S, V
Definition: pixeltypes.h:47