FastLED 3.9.3
Loading...
Searching...
No Matches
colorutils.h
Go to the documentation of this file.
1#ifndef __INC_COLORUTILS_H
2#define __INC_COLORUTILS_H
3
6
7#include "FastLED.h"
8#include "pixeltypes.h"
9#include "fastled_progmem.h"
10#include "xymap.h"
11
12#if !defined(FASTLED_USE_32_BIT_GRADIENT_FILL)
13 #if defined(__AVR__)
14 #define FASTLED_USE_32_BIT_GRADIENT_FILL 0
15 #else
16 #define FASTLED_USE_32_BIT_GRADIENT_FILL 1
17 #endif
18#endif
19
20
66#define DEFINE_GRADIENT_PALETTE(X) \
67 FL_ALIGN_PROGMEM \
68 extern const ::TProgmemRGBGradientPalette_byte X[] FL_PROGMEM =
69
71#define DECLARE_GRADIENT_PALETTE(X) \
72 FL_ALIGN_PROGMEM \
73 extern const ::TProgmemRGBGradientPalette_byte X[] FL_PROGMEM
74
75
76typedef uint32_t TProgmemRGBPalette16[16];
77typedef uint32_t TProgmemHSVPalette16[16];
79#define TProgmemPalette16 TProgmemRGBPalette16
80typedef uint32_t TProgmemRGBPalette32[32];
81typedef uint32_t TProgmemHSVPalette32[32];
83#define TProgmemPalette32 TProgmemRGBPalette32
84
86typedef const uint8_t TProgmemRGBGradientPalette_byte;
93
94
95
96
97
98
99FASTLED_NAMESPACE_BEGIN
100
104
108
113void fill_solid( struct CRGB * targetArray, int numToFill,
114 const struct CRGB& color);
115
117void fill_solid( struct CHSV* targetArray, int numToFill,
118 const struct CHSV& color);
119
120
128void fill_rainbow( struct CRGB * targetArray, int numToFill,
129 uint8_t initialhue,
130 uint8_t deltahue = 5);
131
133void fill_rainbow( struct CHSV * targetArray, int numToFill,
134 uint8_t initialhue,
135 uint8_t deltahue = 5);
136
137
146void fill_rainbow_circular(struct CRGB* targetArray, int numToFill,
147 uint8_t initialhue, bool reversed=false);
148
150void fill_rainbow_circular(struct CHSV* targetArray, int numToFill,
151 uint8_t initialhue, bool reversed=false);
152
153
163
164
167#define saccum87 int16_t
168
169
185template <typename T>
186void fill_gradient( T* targetArray,
187 uint16_t startpos, CHSV startcolor,
188 uint16_t endpos, CHSV endcolor,
189 TGradientDirectionCode directionCode = SHORTEST_HUES )
190{
191 // if the points are in the wrong order, straighten them
192 if( endpos < startpos ) {
193 uint16_t t = endpos;
194 CHSV tc = endcolor;
195 endcolor = startcolor;
196 endpos = startpos;
197 startpos = t;
198 startcolor = tc;
199 }
200
201 // If we're fading toward black (val=0) or white (sat=0),
202 // then set the endhue to the starthue.
203 // This lets us ramp smoothly to black or white, regardless
204 // of what 'hue' was set in the endcolor (since it doesn't matter)
205 if( endcolor.value == 0 || endcolor.saturation == 0) {
206 endcolor.hue = startcolor.hue;
207 }
208
209 // Similarly, if we're fading in from black (val=0) or white (sat=0)
210 // then set the starthue to the endhue.
211 // This lets us ramp smoothly up from black or white, regardless
212 // of what 'hue' was set in the startcolor (since it doesn't matter)
213 if( startcolor.value == 0 || startcolor.saturation == 0) {
214 startcolor.hue = endcolor.hue;
215 }
216
217 saccum87 huedistance87;
218 saccum87 satdistance87;
219 saccum87 valdistance87;
220
221 satdistance87 = (endcolor.sat - startcolor.sat) << 7;
222 valdistance87 = (endcolor.val - startcolor.val) << 7;
223
224 uint8_t huedelta8 = endcolor.hue - startcolor.hue;
225
226 if( directionCode == SHORTEST_HUES ) {
227 directionCode = FORWARD_HUES;
228 if( huedelta8 > 127) {
229 directionCode = BACKWARD_HUES;
230 }
231 }
232
233 if( directionCode == LONGEST_HUES ) {
234 directionCode = FORWARD_HUES;
235 if( huedelta8 < 128) {
236 directionCode = BACKWARD_HUES;
237 }
238 }
239
240 if( directionCode == FORWARD_HUES) {
241 huedistance87 = huedelta8 << 7;
242 }
243 else /* directionCode == BACKWARD_HUES */
244 {
245 huedistance87 = (uint8_t)(256 - huedelta8) << 7;
246 huedistance87 = -huedistance87;
247 }
248
249 uint16_t pixeldistance = endpos - startpos;
250 int16_t divisor = pixeldistance ? pixeldistance : 1;
251
252 #if FASTLED_USE_32_BIT_GRADIENT_FILL
253 // Use higher precision 32 bit math for new micros.
254 int32_t huedelta823 = (huedistance87 * 65536) / divisor;
255 int32_t satdelta823 = (satdistance87 * 65536) / divisor;
256 int32_t valdelta823 = (valdistance87 * 65536) / divisor;
257
258 huedelta823 *= 2;
259 satdelta823 *= 2;
260 valdelta823 *= 2;
261 uint32_t hue824 = static_cast<uint32_t>(startcolor.hue) << 24;
262 uint32_t sat824 = static_cast<uint32_t>(startcolor.sat) << 24;
263 uint32_t val824 = static_cast<uint32_t>(startcolor.val) << 24;
264 for( uint16_t i = startpos; i <= endpos; ++i) {
265 targetArray[i] = CHSV( hue824 >> 24, sat824 >> 24, val824 >> 24);
266 hue824 += huedelta823;
267 sat824 += satdelta823;
268 val824 += valdelta823;
269 }
270 #else
271 // Use 8-bit math for older micros.
272 saccum87 huedelta87 = huedistance87 / divisor;
273 saccum87 satdelta87 = satdistance87 / divisor;
274 saccum87 valdelta87 = valdistance87 / divisor;
275
276 huedelta87 *= 2;
277 satdelta87 *= 2;
278 valdelta87 *= 2;
279
280 accum88 hue88 = startcolor.hue << 8;
281 accum88 sat88 = startcolor.sat << 8;
282 accum88 val88 = startcolor.val << 8;
283 for( uint16_t i = startpos; i <= endpos; ++i) {
284 targetArray[i] = CHSV( hue88 >> 8, sat88 >> 8, val88 >> 8);
285 hue88 += huedelta87;
286 sat88 += satdelta87;
287 val88 += valdelta87;
288 }
289 #endif // defined(__AVR__)
290}
291
292
300template <typename T>
301void fill_gradient( T* targetArray, uint16_t numLeds, const CHSV& c1, const CHSV& c2,
302 TGradientDirectionCode directionCode = SHORTEST_HUES )
303{
304 uint16_t last = numLeds - 1;
305 fill_gradient( targetArray, 0, c1, last, c2, directionCode);
306}
307
316template <typename T>
317void fill_gradient( T* targetArray, uint16_t numLeds,
318 const CHSV& c1, const CHSV& c2, const CHSV& c3,
319 TGradientDirectionCode directionCode = SHORTEST_HUES )
320{
321 uint16_t half = (numLeds / 2);
322 uint16_t last = numLeds - 1;
323 fill_gradient( targetArray, 0, c1, half, c2, directionCode);
324 fill_gradient( targetArray, half, c2, last, c3, directionCode);
325}
326
336template <typename T>
337void fill_gradient( T* targetArray, uint16_t numLeds,
338 const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4,
339 TGradientDirectionCode directionCode = SHORTEST_HUES )
340{
341 uint16_t onethird = (numLeds / 3);
342 uint16_t twothirds = ((numLeds * 2) / 3);
343 uint16_t last = numLeds - 1;
344 fill_gradient( targetArray, 0, c1, onethird, c2, directionCode);
345 fill_gradient( targetArray, onethird, c2, twothirds, c3, directionCode);
346 fill_gradient( targetArray, twothirds, c3, last, c4, directionCode);
347}
348
350#define fill_gradient_HSV fill_gradient
351
352
362void fill_gradient_RGB( CRGB* leds,
363 uint16_t startpos, CRGB startcolor,
364 uint16_t endpos, CRGB endcolor );
365
372void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2);
373
381void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2, const CRGB& c3);
382
391void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4);
392
394
395
399
405void fadeLightBy( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
406
408void fade_video( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
409
415void nscale8_video( CRGB* leds, uint16_t num_leds, uint8_t scale);
416
417
423void fadeToBlackBy( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
424
426void fade_raw( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
427
428
435void nscale8( CRGB* leds, uint16_t num_leds, uint8_t scale);
436
437
448void fadeUsingColor( CRGB* leds, uint16_t numLeds, const CRGB& colormask);
449
451
452
456
461CRGB blend( const CRGB& p1, const CRGB& p2, fract8 amountOfP2 );
462
465CHSV blend( const CHSV& p1, const CHSV& p2, fract8 amountOfP2,
466 TGradientDirectionCode directionCode = SHORTEST_HUES );
467
468
477CRGB* blend( const CRGB* src1, const CRGB* src2, CRGB* dest,
478 uint16_t count, fract8 amountOfsrc2 );
479
482CHSV* blend( const CHSV* src1, const CHSV* src2, CHSV* dest,
483 uint16_t count, fract8 amountOfsrc2,
484 TGradientDirectionCode directionCode = SHORTEST_HUES );
485
486
491CRGB& nblend( CRGB& existing, const CRGB& overlay, fract8 amountOfOverlay );
492
495CHSV& nblend( CHSV& existing, const CHSV& overlay, fract8 amountOfOverlay,
496 TGradientDirectionCode directionCode = SHORTEST_HUES );
497
498
504void nblend( CRGB* existing, CRGB* overlay, uint16_t count, fract8 amountOfOverlay);
505
508void nblend( CHSV* existing, CHSV* overlay, uint16_t count, fract8 amountOfOverlay,
509 TGradientDirectionCode directionCode = SHORTEST_HUES);
510
512
513
517
532void blur1d( CRGB* leds, uint16_t numLeds, fract8 blur_amount);
533
549void blur2d( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount, const XYMap& xymap);
550
551
558void blurRows( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount, const XYMap& xymap);
559
562void blurColumns(CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount, const XYMap& xymap);
563
565
566
569
575CRGB HeatColor( uint8_t temperature);
576
579
580
648
649
656
657class CRGBPalette16;
658class CRGBPalette32;
659class CRGBPalette256;
660class CHSVPalette16;
661class CHSVPalette32;
662class CHSVPalette256;
663
664
665
670typedef union {
671 struct {
672 uint8_t index;
673 uint8_t r;
674 uint8_t g;
675 uint8_t b;
676 };
677 uint32_t dword;
678 uint8_t bytes[4];
680
684
686
687
691
695void UpscalePalette(const class CRGBPalette16& srcpal16, class CRGBPalette256& destpal256);
697void UpscalePalette(const class CHSVPalette16& srcpal16, class CHSVPalette256& destpal256);
698
702void UpscalePalette(const class CRGBPalette16& srcpal16, class CRGBPalette32& destpal32);
704void UpscalePalette(const class CHSVPalette16& srcpal16, class CHSVPalette32& destpal32);
705
709void UpscalePalette(const class CRGBPalette32& srcpal32, class CRGBPalette256& destpal256);
711void UpscalePalette(const class CHSVPalette32& srcpal32, class CHSVPalette256& destpal256);
712
714
715
718
721public:
723
726
728 CHSVPalette16( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03,
729 const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07,
730 const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11,
731 const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 )
732 {
733 entries[0]=c00; entries[1]=c01; entries[2]=c02; entries[3]=c03;
734 entries[4]=c04; entries[5]=c05; entries[6]=c06; entries[7]=c07;
735 entries[8]=c08; entries[9]=c09; entries[10]=c10; entries[11]=c11;
736 entries[12]=c12; entries[13]=c13; entries[14]=c14; entries[15]=c15;
737 };
738
741 {
742 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
743 }
744
747 {
748 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
749 return *this;
750 }
751
754 {
755 for( uint8_t i = 0; i < 16; ++i) {
756 CRGB xyz(FL_PGM_READ_DWORD_NEAR( rhs + i));
757 entries[i].hue = xyz.red;
758 entries[i].sat = xyz.green;
759 entries[i].val = xyz.blue;
760 }
761 }
762
765 {
766 for( uint8_t i = 0; i < 16; ++i) {
767 CRGB xyz(FL_PGM_READ_DWORD_NEAR( rhs + i));
768 entries[i].hue = xyz.red;
769 entries[i].sat = xyz.green;
770 entries[i].val = xyz.blue;
771 }
772 return *this;
773 }
774
781 inline CHSV& operator[] (uint8_t x) __attribute__((always_inline))
782 {
783 return entries[x];
784 }
785
787 inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline))
788 {
789 return entries[x];
790 }
791
793 inline CHSV& operator[] (int x) __attribute__((always_inline))
794 {
795 return entries[(uint8_t)x];
796 }
797
799 inline const CHSV& operator[] (int x) const __attribute__((always_inline))
800 {
801 return entries[(uint8_t)x];
802 }
803
805 operator CHSV*()
806 {
807 return &(entries[0]);
808 }
809
811 bool operator==( const CHSVPalette16 &rhs) const
812 {
813 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
814 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
815 if( p == q) return true;
816 for( uint8_t i = 0; i < (sizeof( entries)); ++i) {
817 if( *p != *q) return false;
818 ++p;
819 ++q;
820 }
821 return true;
822 }
823
825 bool operator!=( const CHSVPalette16 &rhs) const
826 {
827 return !( *this == rhs);
828 }
829
832 CHSVPalette16( const CHSV& c1)
833 {
834 fill_solid( &(entries[0]), 16, c1);
835 }
836
840 CHSVPalette16( const CHSV& c1, const CHSV& c2)
841 {
842 fill_gradient( &(entries[0]), 16, c1, c2);
843 }
844
849 CHSVPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3)
850 {
851 fill_gradient( &(entries[0]), 16, c1, c2, c3);
852 }
853
859 CHSVPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
860 {
861 fill_gradient( &(entries[0]), 16, c1, c2, c3, c4);
862 }
863
864};
865
868public:
870
873
878 CHSVPalette256( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03,
879 const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07,
880 const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11,
881 const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 )
882 {
883 CHSVPalette16 p16(c00,c01,c02,c03,c04,c05,c06,c07,
884 c08,c09,c10,c11,c12,c13,c14,c15);
885 *this = p16;
886 };
887
890 {
891 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
892 }
895 {
896 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
897 return *this;
898 }
899
902 {
903 UpscalePalette( rhs16, *this);
904 }
907 {
908 UpscalePalette( rhs16, *this);
909 return *this;
910 }
911
914 {
915 CHSVPalette16 p16(rhs);
916 *this = p16;
917 }
920 {
921 CHSVPalette16 p16(rhs);
922 *this = p16;
923 return *this;
924 }
925
927 inline CHSV& operator[] (uint8_t x) __attribute__((always_inline))
928 {
929 return entries[x];
930 }
932 inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline))
933 {
934 return entries[x];
935 }
936
938 inline CHSV& operator[] (int x) __attribute__((always_inline))
939 {
940 return entries[(uint8_t)x];
941 }
943 inline const CHSV& operator[] (int x) const __attribute__((always_inline))
944 {
945 return entries[(uint8_t)x];
946 }
947
949 operator CHSV*()
950 {
951 return &(entries[0]);
952 }
953
955 bool operator==( const CHSVPalette256 &rhs) const
956 {
957 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
958 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
959 if( p == q) return true;
960 for( uint16_t i = 0; i < (sizeof( entries)); ++i) {
961 if( *p != *q) return false;
962 ++p;
963 ++q;
964 }
965 return true;
966 }
967
969 bool operator!=( const CHSVPalette256 &rhs) const
970 {
971 return !( *this == rhs);
972 }
973
976 {
977 fill_solid( &(entries[0]), 256, c1);
978 }
980 CHSVPalette256( const CHSV& c1, const CHSV& c2)
981 {
982 fill_gradient( &(entries[0]), 256, c1, c2);
983 }
985 CHSVPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3)
986 {
987 fill_gradient( &(entries[0]), 256, c1, c2, c3);
988 }
990 CHSVPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
991 {
992 fill_gradient( &(entries[0]), 256, c1, c2, c3, c4);
993 }
994};
995
998public:
1000
1003
1005 CRGBPalette16( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03,
1006 const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07,
1007 const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11,
1008 const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 )
1009 {
1010 entries[0]=c00; entries[1]=c01; entries[2]=c02; entries[3]=c03;
1011 entries[4]=c04; entries[5]=c05; entries[6]=c06; entries[7]=c07;
1012 entries[8]=c08; entries[9]=c09; entries[10]=c10; entries[11]=c11;
1013 entries[12]=c12; entries[13]=c13; entries[14]=c14; entries[15]=c15;
1014 };
1015
1018 {
1019 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1020 }
1022 CRGBPalette16( const CRGB rhs[16])
1023 {
1024 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1025 }
1028 {
1029 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1030 return *this;
1031 }
1034 {
1035 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1036 return *this;
1037 }
1038
1041 {
1042 for( uint8_t i = 0; i < 16; ++i) {
1043 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1044 }
1045 }
1047 CRGBPalette16( const CHSV rhs[16])
1048 {
1049 for( uint8_t i = 0; i < 16; ++i) {
1050 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1051 }
1052 }
1055 {
1056 for( uint8_t i = 0; i < 16; ++i) {
1057 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1058 }
1059 return *this;
1060 }
1063 {
1064 for( uint8_t i = 0; i < 16; ++i) {
1065 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1066 }
1067 return *this;
1068 }
1069
1072 {
1073 for( uint8_t i = 0; i < 16; ++i) {
1074 entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i);
1075 }
1076 }
1079 {
1080 for( uint8_t i = 0; i < 16; ++i) {
1081 entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i);
1082 }
1083 return *this;
1084 }
1085
1087 bool operator==( const CRGBPalette16 &rhs) const
1088 {
1089 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
1090 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
1091 if( p == q) return true;
1092 for( uint8_t i = 0; i < (sizeof( entries)); ++i) {
1093 if( *p != *q) return false;
1094 ++p;
1095 ++q;
1096 }
1097 return true;
1098 }
1100 bool operator!=( const CRGBPalette16 &rhs) const
1101 {
1102 return !( *this == rhs);
1103 }
1105 inline CRGB& operator[] (uint8_t x) __attribute__((always_inline))
1106 {
1107 return entries[x];
1108 }
1110 inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline))
1111 {
1112 return entries[x];
1113 }
1114
1116 inline CRGB& operator[] (int x) __attribute__((always_inline))
1117 {
1118 return entries[(uint8_t)x];
1119 }
1121 inline const CRGB& operator[] (int x) const __attribute__((always_inline))
1122 {
1123 return entries[(uint8_t)x];
1124 }
1125
1127 operator CRGB*()
1128 {
1129 return &(entries[0]);
1130 }
1131
1134 {
1135 fill_solid( &(entries[0]), 16, c1);
1136 }
1138 CRGBPalette16( const CHSV& c1, const CHSV& c2)
1139 {
1140 fill_gradient( &(entries[0]), 16, c1, c2);
1141 }
1143 CRGBPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3)
1144 {
1145 fill_gradient( &(entries[0]), 16, c1, c2, c3);
1146 }
1148 CRGBPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
1149 {
1150 fill_gradient( &(entries[0]), 16, c1, c2, c3, c4);
1151 }
1152
1155 {
1156 fill_solid( &(entries[0]), 16, c1);
1157 }
1159 CRGBPalette16( const CRGB& c1, const CRGB& c2)
1160 {
1161 fill_gradient_RGB( &(entries[0]), 16, c1, c2);
1162 }
1164 CRGBPalette16( const CRGB& c1, const CRGB& c2, const CRGB& c3)
1165 {
1166 fill_gradient_RGB( &(entries[0]), 16, c1, c2, c3);
1167 }
1169 CRGBPalette16( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4)
1170 {
1171 fill_gradient_RGB( &(entries[0]), 16, c1, c2, c3, c4);
1172 }
1173
1204 {
1205 *this = progpal;
1206 }
1209 {
1212
1213 // Count entries
1214 uint16_t count = 0;
1215 do {
1216 u.dword = FL_PGM_READ_DWORD_NEAR(progent + count);
1217 ++count;
1218 } while ( u.index != 255);
1219
1220 int8_t lastSlotUsed = -1;
1221
1222 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1223 CRGB rgbstart( u.r, u.g, u.b);
1224
1225 int indexstart = 0;
1226 uint8_t istart8 = 0;
1227 uint8_t iend8 = 0;
1228 while( indexstart < 255) {
1229 ++progent;
1230 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1231 int indexend = u.index;
1232 CRGB rgbend( u.r, u.g, u.b);
1233 istart8 = indexstart / 16;
1234 iend8 = indexend / 16;
1235 if( count < 16) {
1236 if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) {
1237 istart8 = lastSlotUsed + 1;
1238 if( iend8 < istart8) {
1239 iend8 = istart8;
1240 }
1241 }
1242 lastSlotUsed = iend8;
1243 }
1244 fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend);
1245 indexstart = indexend;
1246 rgbstart = rgbend;
1247 }
1248 return *this;
1249 }
1253 {
1256
1257 // Count entries
1258 uint16_t count = 0;
1259 do {
1260 u = *(ent + count);
1261 ++count;
1262 } while ( u.index != 255);
1263
1264 int8_t lastSlotUsed = -1;
1265
1266
1267 u = *ent;
1268 CRGB rgbstart( u.r, u.g, u.b);
1269
1270 int indexstart = 0;
1271 uint8_t istart8 = 0;
1272 uint8_t iend8 = 0;
1273 while( indexstart < 255) {
1274 ++ent;
1275 u = *ent;
1276 int indexend = u.index;
1277 CRGB rgbend( u.r, u.g, u.b);
1278 istart8 = indexstart / 16;
1279 iend8 = indexend / 16;
1280 if( count < 16) {
1281 if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) {
1282 istart8 = lastSlotUsed + 1;
1283 if( iend8 < istart8) {
1284 iend8 = istart8;
1285 }
1286 }
1287 lastSlotUsed = iend8;
1288 }
1289 fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend);
1290 indexstart = indexend;
1291 rgbstart = rgbend;
1292 }
1293 return *this;
1294 }
1295
1296};
1297
1298
1301public:
1303
1306
1311 CHSVPalette32( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03,
1312 const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07,
1313 const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11,
1314 const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 )
1315 {
1316 for( uint8_t i = 0; i < 2; ++i) {
1317 entries[0+i]=c00; entries[2+i]=c01; entries[4+i]=c02; entries[6+i]=c03;
1318 entries[8+i]=c04; entries[10+i]=c05; entries[12+i]=c06; entries[14+i]=c07;
1319 entries[16+i]=c08; entries[18+i]=c09; entries[20+i]=c10; entries[22+i]=c11;
1320 entries[24+i]=c12; entries[26+i]=c13; entries[28+i]=c14; entries[30+i]=c15;
1321 }
1322 };
1323
1326 {
1327 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1328 }
1331 {
1332 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1333 return *this;
1334 }
1335
1338 {
1339 for( uint8_t i = 0; i < 32; ++i) {
1340 CRGB xyz(FL_PGM_READ_DWORD_NEAR( rhs + i));
1341 entries[i].hue = xyz.red;
1342 entries[i].sat = xyz.green;
1343 entries[i].val = xyz.blue;
1344 }
1345 }
1348 {
1349 for( uint8_t i = 0; i < 32; ++i) {
1350 CRGB xyz(FL_PGM_READ_DWORD_NEAR( rhs + i));
1351 entries[i].hue = xyz.red;
1352 entries[i].sat = xyz.green;
1353 entries[i].val = xyz.blue;
1354 }
1355 return *this;
1356 }
1357
1359 inline CHSV& operator[] (uint8_t x) __attribute__((always_inline))
1360 {
1361 return entries[x];
1362 }
1364 inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline))
1365 {
1366 return entries[x];
1367 }
1368
1370 inline CHSV& operator[] (int x) __attribute__((always_inline))
1371 {
1372 return entries[(uint8_t)x];
1373 }
1375 inline const CHSV& operator[] (int x) const __attribute__((always_inline))
1376 {
1377 return entries[(uint8_t)x];
1378 }
1379
1381 operator CHSV*()
1382 {
1383 return &(entries[0]);
1384 }
1385
1387 bool operator==( const CHSVPalette32 &rhs) const
1388 {
1389 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
1390 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
1391 if( p == q) return true;
1392 for( uint8_t i = 0; i < (sizeof( entries)); ++i) {
1393 if( *p != *q) return false;
1394 ++p;
1395 ++q;
1396 }
1397 return true;
1398 }
1400 bool operator!=( const CHSVPalette32 &rhs) const
1401 {
1402 return !( *this == rhs);
1403 }
1404
1407 {
1408 fill_solid( &(entries[0]), 32, c1);
1409 }
1411 CHSVPalette32( const CHSV& c1, const CHSV& c2)
1412 {
1413 fill_gradient( &(entries[0]), 32, c1, c2);
1414 }
1416 CHSVPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3)
1417 {
1418 fill_gradient( &(entries[0]), 32, c1, c2, c3);
1419 }
1421 CHSVPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
1422 {
1423 fill_gradient( &(entries[0]), 32, c1, c2, c3, c4);
1424 }
1425
1426};
1427
1430public:
1432
1435
1441 CRGBPalette32( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03,
1442 const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07,
1443 const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11,
1444 const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 )
1445 {
1446 for( uint8_t i = 0; i < 2; ++i) {
1447 entries[0+i]=c00; entries[2+i]=c01; entries[4+i]=c02; entries[6+i]=c03;
1448 entries[8+i]=c04; entries[10+i]=c05; entries[12+i]=c06; entries[14+i]=c07;
1449 entries[16+i]=c08; entries[18+i]=c09; entries[20+i]=c10; entries[22+i]=c11;
1450 entries[24+i]=c12; entries[26+i]=c13; entries[28+i]=c14; entries[30+i]=c15;
1451 }
1452 };
1453
1456 {
1457 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1458 }
1460 CRGBPalette32( const CRGB rhs[32])
1461 {
1462 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1463 }
1466 {
1467 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1468 return *this;
1469 }
1472 {
1473 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1474 return *this;
1475 }
1476
1479 {
1480 for( uint8_t i = 0; i < 32; ++i) {
1481 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1482 }
1483 }
1485 CRGBPalette32( const CHSV rhs[32])
1486 {
1487 for( uint8_t i = 0; i < 32; ++i) {
1488 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1489 }
1490 }
1493 {
1494 for( uint8_t i = 0; i < 32; ++i) {
1495 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1496 }
1497 return *this;
1498 }
1501 {
1502 for( uint8_t i = 0; i < 32; ++i) {
1503 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1504 }
1505 return *this;
1506 }
1507
1510 {
1511 for( uint8_t i = 0; i < 32; ++i) {
1512 entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i);
1513 }
1514 }
1517 {
1518 for( uint8_t i = 0; i < 32; ++i) {
1519 entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i);
1520 }
1521 return *this;
1522 }
1523
1525 bool operator==( const CRGBPalette32 &rhs) const
1526 {
1527 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
1528 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
1529 if( p == q) return true;
1530 for( uint8_t i = 0; i < (sizeof( entries)); ++i) {
1531 if( *p != *q) return false;
1532 ++p;
1533 ++q;
1534 }
1535 return true;
1536 }
1538 bool operator!=( const CRGBPalette32 &rhs) const
1539 {
1540 return !( *this == rhs);
1541 }
1542
1544 inline CRGB& operator[] (uint8_t x) __attribute__((always_inline))
1545 {
1546 return entries[x];
1547 }
1549 inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline))
1550 {
1551 return entries[x];
1552 }
1553
1555 inline CRGB& operator[] (int x) __attribute__((always_inline))
1556 {
1557 return entries[(uint8_t)x];
1558 }
1560 inline const CRGB& operator[] (int x) const __attribute__((always_inline))
1561 {
1562 return entries[(uint8_t)x];
1563 }
1564
1566 operator CRGB*()
1567 {
1568 return &(entries[0]);
1569 }
1570
1573 {
1574 fill_solid( &(entries[0]), 32, c1);
1575 }
1577 CRGBPalette32( const CHSV& c1, const CHSV& c2)
1578 {
1579 fill_gradient( &(entries[0]), 32, c1, c2);
1580 }
1582 CRGBPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3)
1583 {
1584 fill_gradient( &(entries[0]), 32, c1, c2, c3);
1585 }
1587 CRGBPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
1588 {
1589 fill_gradient( &(entries[0]), 32, c1, c2, c3, c4);
1590 }
1591
1594 {
1595 fill_solid( &(entries[0]), 32, c1);
1596 }
1598 CRGBPalette32( const CRGB& c1, const CRGB& c2)
1599 {
1600 fill_gradient_RGB( &(entries[0]), 32, c1, c2);
1601 }
1603 CRGBPalette32( const CRGB& c1, const CRGB& c2, const CRGB& c3)
1604 {
1605 fill_gradient_RGB( &(entries[0]), 32, c1, c2, c3);
1606 }
1608 CRGBPalette32( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4)
1609 {
1610 fill_gradient_RGB( &(entries[0]), 32, c1, c2, c3, c4);
1611 }
1612
1613
1616 {
1617 UpscalePalette( rhs16, *this);
1618 }
1621 {
1622 UpscalePalette( rhs16, *this);
1623 return *this;
1624 }
1625
1628 {
1629 CRGBPalette16 p16(rhs);
1630 *this = p16;
1631 }
1634 {
1635 CRGBPalette16 p16(rhs);
1636 *this = p16;
1637 return *this;
1638 }
1639
1640
1643 {
1644 *this = progpal;
1645 }
1648 {
1651
1652 // Count entries
1653 uint16_t count = 0;
1654 do {
1655 u.dword = FL_PGM_READ_DWORD_NEAR(progent + count);
1656 ++count;
1657 } while ( u.index != 255);
1658
1659 int8_t lastSlotUsed = -1;
1660
1661 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1662 CRGB rgbstart( u.r, u.g, u.b);
1663
1664 int indexstart = 0;
1665 uint8_t istart8 = 0;
1666 uint8_t iend8 = 0;
1667 while( indexstart < 255) {
1668 ++progent;
1669 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1670 int indexend = u.index;
1671 CRGB rgbend( u.r, u.g, u.b);
1672 istart8 = indexstart / 8;
1673 iend8 = indexend / 8;
1674 if( count < 16) {
1675 if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) {
1676 istart8 = lastSlotUsed + 1;
1677 if( iend8 < istart8) {
1678 iend8 = istart8;
1679 }
1680 }
1681 lastSlotUsed = iend8;
1682 }
1683 fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend);
1684 indexstart = indexend;
1685 rgbstart = rgbend;
1686 }
1687 return *this;
1688 }
1691 {
1694
1695 // Count entries
1696 uint16_t count = 0;
1697 do {
1698 u = *(ent + count);
1699 ++count;
1700 } while ( u.index != 255);
1701
1702 int8_t lastSlotUsed = -1;
1703
1704
1705 u = *ent;
1706 CRGB rgbstart( u.r, u.g, u.b);
1707
1708 int indexstart = 0;
1709 uint8_t istart8 = 0;
1710 uint8_t iend8 = 0;
1711 while( indexstart < 255) {
1712 ++ent;
1713 u = *ent;
1714 int indexend = u.index;
1715 CRGB rgbend( u.r, u.g, u.b);
1716 istart8 = indexstart / 8;
1717 iend8 = indexend / 8;
1718 if( count < 16) {
1719 if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) {
1720 istart8 = lastSlotUsed + 1;
1721 if( iend8 < istart8) {
1722 iend8 = istart8;
1723 }
1724 }
1725 lastSlotUsed = iend8;
1726 }
1727 fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend);
1728 indexstart = indexend;
1729 rgbstart = rgbend;
1730 }
1731 return *this;
1732 }
1733
1734};
1735
1736
1739public:
1741
1744
1750 CRGBPalette256( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03,
1751 const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07,
1752 const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11,
1753 const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 )
1754 {
1755 CRGBPalette16 p16(c00,c01,c02,c03,c04,c05,c06,c07,
1756 c08,c09,c10,c11,c12,c13,c14,c15);
1757 *this = p16;
1758 };
1759
1762 {
1763 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1764 }
1766 CRGBPalette256( const CRGB rhs[256])
1767 {
1768 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1769 }
1772 {
1773 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1774 return *this;
1775 }
1778 {
1779 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1780 return *this;
1781 }
1782
1785 {
1786 for( int i = 0; i < 256; ++i) {
1787 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1788 }
1789 }
1791 CRGBPalette256( const CHSV rhs[256])
1792 {
1793 for( int i = 0; i < 256; ++i) {
1794 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1795 }
1796 }
1799 {
1800 for( int i = 0; i < 256; ++i) {
1801 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1802 }
1803 return *this;
1804 }
1807 {
1808 for( int i = 0; i < 256; ++i) {
1809 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1810 }
1811 return *this;
1812 }
1813
1816 {
1817 UpscalePalette( rhs16, *this);
1818 }
1821 {
1822 UpscalePalette( rhs16, *this);
1823 return *this;
1824 }
1825
1828 {
1829 CRGBPalette16 p16(rhs);
1830 *this = p16;
1831 }
1834 {
1835 CRGBPalette16 p16(rhs);
1836 *this = p16;
1837 return *this;
1838 }
1839
1841 bool operator==( const CRGBPalette256 &rhs) const
1842 {
1843 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
1844 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
1845 if( p == q) return true;
1846 for( uint16_t i = 0; i < (sizeof( entries)); ++i) {
1847 if( *p != *q) return false;
1848 ++p;
1849 ++q;
1850 }
1851 return true;
1852 }
1854 bool operator!=( const CRGBPalette256 &rhs) const
1855 {
1856 return !( *this == rhs);
1857 }
1858
1860 inline CRGB& operator[] (uint8_t x) __attribute__((always_inline))
1861 {
1862 return entries[x];
1863 }
1865 inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline))
1866 {
1867 return entries[x];
1868 }
1869
1871 inline CRGB& operator[] (int x) __attribute__((always_inline))
1872 {
1873 return entries[(uint8_t)x];
1874 }
1876 inline const CRGB& operator[] (int x) const __attribute__((always_inline))
1877 {
1878 return entries[(uint8_t)x];
1879 }
1880
1882 operator CRGB*()
1883 {
1884 return &(entries[0]);
1885 }
1886
1889 {
1890 fill_solid( &(entries[0]), 256, c1);
1891 }
1893 CRGBPalette256( const CHSV& c1, const CHSV& c2)
1894 {
1895 fill_gradient( &(entries[0]), 256, c1, c2);
1896 }
1898 CRGBPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3)
1899 {
1900 fill_gradient( &(entries[0]), 256, c1, c2, c3);
1901 }
1903 CRGBPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
1904 {
1905 fill_gradient( &(entries[0]), 256, c1, c2, c3, c4);
1906 }
1907
1910 {
1911 fill_solid( &(entries[0]), 256, c1);
1912 }
1914 CRGBPalette256( const CRGB& c1, const CRGB& c2)
1915 {
1916 fill_gradient_RGB( &(entries[0]), 256, c1, c2);
1917 }
1919 CRGBPalette256( const CRGB& c1, const CRGB& c2, const CRGB& c3)
1920 {
1921 fill_gradient_RGB( &(entries[0]), 256, c1, c2, c3);
1922 }
1924 CRGBPalette256( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4)
1925 {
1926 fill_gradient_RGB( &(entries[0]), 256, c1, c2, c3, c4);
1927 }
1928
1931 {
1932 *this = progpal;
1933 }
1936 {
1939 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1940 CRGB rgbstart( u.r, u.g, u.b);
1941
1942 int indexstart = 0;
1943 while( indexstart < 255) {
1944 ++progent;
1945 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1946 int indexend = u.index;
1947 CRGB rgbend( u.r, u.g, u.b);
1948 fill_gradient_RGB( &(entries[0]), indexstart, rgbstart, indexend, rgbend);
1949 indexstart = indexend;
1950 rgbstart = rgbend;
1951 }
1952 return *this;
1953 }
1956 {
1959 u = *ent;
1960 CRGB rgbstart( u.r, u.g, u.b);
1961
1962 int indexstart = 0;
1963 while( indexstart < 255) {
1964 ++ent;
1965 u = *ent;
1966 int indexend = u.index;
1967 CRGB rgbend( u.r, u.g, u.b);
1968 fill_gradient_RGB( &(entries[0]), indexstart, rgbstart, indexend, rgbend);
1969 indexstart = indexend;
1970 rgbstart = rgbend;
1971 }
1972 return *this;
1973 }
1974};
1975
1977
1978
1982
1989
2000 uint8_t index,
2001 uint8_t brightness=255,
2002 TBlendType blendType=LINEARBLEND);
2003
2004
2010CRGB ColorFromPaletteExtended(
2011 const CRGBPalette16& pal,
2012 uint16_t index,
2013 uint8_t brightness,
2014 TBlendType blendType);
2015
2021CRGB ColorFromPaletteExtended(
2022 const CRGBPalette32& pal,
2023 uint16_t index,
2024 uint8_t brightness,
2025 TBlendType blendType);
2026
2029 uint8_t index,
2030 uint8_t brightness=255,
2031 TBlendType blendType=LINEARBLEND);
2032
2035 uint8_t index,
2036 uint8_t brightness=255,
2037 TBlendType blendType=NOBLEND );
2038
2039// @author https://github.com/generalelectrix
2040CRGB ColorFromPaletteExtended(const CRGBPalette256& pal,
2041 uint16_t index,
2042 uint8_t brightness,
2043 TBlendType blendType);
2044
2047 uint8_t index,
2048 uint8_t brightness=255,
2049 TBlendType blendType=LINEARBLEND);
2050
2053 uint8_t index,
2054 uint8_t brightness=255,
2055 TBlendType blendType=NOBLEND );
2056
2059 uint8_t index,
2060 uint8_t brightness=255,
2061 TBlendType blendType=LINEARBLEND);
2062
2065 uint8_t index,
2066 uint8_t brightness=255,
2067 TBlendType blendType=LINEARBLEND);
2068
2071 uint8_t index,
2072 uint8_t brightness=255,
2073 TBlendType blendType=LINEARBLEND);
2074
2075
2086template <typename PALETTE>
2087void fill_palette(CRGB* L, uint16_t N, uint8_t startIndex, uint8_t incIndex,
2088 const PALETTE& pal, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
2089{
2090 uint8_t colorIndex = startIndex;
2091 for( uint16_t i = 0; i < N; ++i) {
2092 L[i] = ColorFromPalette( pal, colorIndex, brightness, blendType);
2093 colorIndex += incIndex;
2094 }
2095}
2096
2097
2109template <typename PALETTE>
2110void fill_palette_circular(CRGB* L, uint16_t N, uint8_t startIndex,
2111 const PALETTE& pal, uint8_t brightness=255, TBlendType blendType=LINEARBLEND,
2112 bool reversed=false)
2113{
2114 if (N == 0) return; // avoiding div/0
2115
2116 const uint16_t colorChange = 65535 / N; // color change for each LED, * 256 for precision
2117 uint16_t colorIndex = ((uint16_t) startIndex) << 8; // offset for color index, with precision (*256)
2118
2119 for (uint16_t i = 0; i < N; ++i) {
2120 L[i] = ColorFromPalette(pal, (colorIndex >> 8), brightness, blendType);
2121 if (reversed) colorIndex -= colorChange;
2122 else colorIndex += colorChange;
2123 }
2124}
2125
2126
2144template <typename PALETTE>
2146 uint8_t *dataArray, uint16_t dataCount,
2147 CRGB* targetColorArray,
2148 const PALETTE& pal,
2149 uint8_t brightness=255,
2150 uint8_t opacity=255,
2151 TBlendType blendType=LINEARBLEND)
2152{
2153 for( uint16_t i = 0; i < dataCount; ++i) {
2154 uint8_t d = dataArray[i];
2155 CRGB rgb = ColorFromPalette( pal, d, brightness, blendType);
2156 if( opacity == 255 ) {
2157 targetColorArray[i] = rgb;
2158 } else {
2159 targetColorArray[i].nscale8( 256 - opacity);
2160 rgb.nscale8_video( opacity);
2161 targetColorArray[i] += rgb;
2162 }
2163 }
2164}
2165
2166
2205void nblendPaletteTowardPalette( CRGBPalette16& currentPalette,
2206 CRGBPalette16& targetPalette,
2207 uint8_t maxChanges=24);
2208
2210
2211
2212
2214
2215
2247
2252uint8_t applyGamma_video( uint8_t brightness, float gamma);
2253
2258CRGB applyGamma_video( const CRGB& orig, float gamma);
2259
2266CRGB applyGamma_video( const CRGB& orig, float gammaR, float gammaG, float gammaB);
2267
2268
2272CRGB& napplyGamma_video( CRGB& rgb, float gamma);
2273
2279CRGB& napplyGamma_video( CRGB& rgb, float gammaR, float gammaG, float gammaB);
2280
2285void napplyGamma_video( CRGB* rgbarray, uint16_t count, float gamma);
2286
2293void napplyGamma_video( CRGB* rgbarray, uint16_t count, float gammaR, float gammaG, float gammaB);
2294
2296
2297FASTLED_NAMESPACE_END
2298
2299#endif
central include file for FastLED, defines the CFastLED class/object
HSV color palette with 16 discrete values.
Definition colorutils.h:720
CHSVPalette16(const CHSV &c1)
Create palette filled with one color.
Definition colorutils.h:832
CHSVPalette16(const CHSVPalette16 &rhs)
Copy constructor.
Definition colorutils.h:740
CHSVPalette16(const CHSV &c00, const CHSV &c01, const CHSV &c02, const CHSV &c03, const CHSV &c04, const CHSV &c05, const CHSV &c06, const CHSV &c07, const CHSV &c08, const CHSV &c09, const CHSV &c10, const CHSV &c11, const CHSV &c12, const CHSV &c13, const CHSV &c14, const CHSV &c15)
Create palette from 16 CHSV values.
Definition colorutils.h:728
CHSVPalette16 & operator=(const TProgmemHSVPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition colorutils.h:764
bool operator==(const CHSVPalette16 &rhs) const
Check if two palettes have the same color entries.
Definition colorutils.h:811
bool operator!=(const CHSVPalette16 &rhs) const
Check if two palettes do not have the same color entries.
Definition colorutils.h:825
CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4)
Create palette with four-color gradient.
Definition colorutils.h:859
CHSVPalette16()
Default constructor.
Definition colorutils.h:725
CHSVPalette16(const CHSV &c1, const CHSV &c2)
Create palette with a gradient from one color to another.
Definition colorutils.h:840
CHSV entries[16]
the color entries that make up the palette
Definition colorutils.h:722
CHSVPalette16 & operator=(const CHSVPalette16 &rhs)
Copy constructor.
Definition colorutils.h:746
CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3)
Create palette with three-color gradient.
Definition colorutils.h:849
CHSVPalette16(const TProgmemHSVPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition colorutils.h:753
CHSV & operator[](uint8_t x)
Array access operator to index into the gradient entries.
Definition colorutils.h:781
HSV color palette with 256 discrete values.
Definition colorutils.h:867
CHSV & operator[](uint8_t x)
Array access operator to index into the gradient entries.
Definition colorutils.h:927
CHSVPalette256()
Default constructor.
Definition colorutils.h:872
CHSVPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4)
Create palette with four-color gradient.
Definition colorutils.h:990
CHSVPalette256 & operator=(const CHSVPalette256 &rhs)
Copy constructor.
Definition colorutils.h:894
CHSVPalette256(const CHSV &c1)
Create palette filled with one color.
Definition colorutils.h:975
CHSVPalette256(const CHSV &c00, const CHSV &c01, const CHSV &c02, const CHSV &c03, const CHSV &c04, const CHSV &c05, const CHSV &c06, const CHSV &c07, const CHSV &c08, const CHSV &c09, const CHSV &c10, const CHSV &c11, const CHSV &c12, const CHSV &c13, const CHSV &c14, const CHSV &c15)
Create palette from 16 CHSV values.
Definition colorutils.h:878
CHSV entries[256]
the color entries that make up the palette
Definition colorutils.h:869
CHSVPalette256(const CHSVPalette16 &rhs16)
Create upscaled palette from 16-entry palette.
Definition colorutils.h:901
CHSVPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3)
Create palette with three-color gradient.
Definition colorutils.h:985
CHSVPalette256(const CHSVPalette256 &rhs)
Copy constructor.
Definition colorutils.h:889
CHSVPalette256 & operator=(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition colorutils.h:919
CHSVPalette256(const CHSV &c1, const CHSV &c2)
Create palette with a gradient from one color to another.
Definition colorutils.h:980
bool operator!=(const CHSVPalette256 &rhs) const
Check if two palettes do not have the same color entries.
Definition colorutils.h:969
bool operator==(const CHSVPalette256 &rhs) const
Check if two palettes have the same color entries.
Definition colorutils.h:955
CHSVPalette256 & operator=(const CHSVPalette16 &rhs16)
Create upscaled palette from 16-entry palette.
Definition colorutils.h:906
CHSVPalette256(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition colorutils.h:913
HSV color palette with 32 discrete values.
CHSV entries[32]
the color entries that make up the palette
CHSVPalette32(const TProgmemHSVPalette32 &rhs)
Create palette from palette stored in PROGMEM.
bool operator!=(const CHSVPalette32 &rhs) const
Check if two palettes do not have the same color entries.
CHSVPalette32(const CHSVPalette32 &rhs)
Copy constructor.
CHSVPalette32(const CHSV &c00, const CHSV &c01, const CHSV &c02, const CHSV &c03, const CHSV &c04, const CHSV &c05, const CHSV &c06, const CHSV &c07, const CHSV &c08, const CHSV &c09, const CHSV &c10, const CHSV &c11, const CHSV &c12, const CHSV &c13, const CHSV &c14, const CHSV &c15)
Create palette from 16 CHSV values.
CHSVPalette32 & operator=(const CHSVPalette32 &rhs)
Copy constructor.
CHSVPalette32(const CHSV &c1, const CHSV &c2)
Create palette with a gradient from one color to another.
CHSVPalette32()
Default constructor.
bool operator==(const CHSVPalette32 &rhs) const
Check if two palettes have the same color entries.
CHSVPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3)
Create palette with three-color gradient.
CHSVPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4)
Create palette with four-color gradient.
CHSVPalette32 & operator=(const TProgmemHSVPalette32 &rhs)
Create palette from palette stored in PROGMEM.
CHSV & operator[](uint8_t x)
Create palette from palette stored in PROGMEM.
CHSVPalette32(const CHSV &c1)
Create palette filled with one color.
RGB color palette with 16 discrete values.
Definition colorutils.h:997
CRGBPalette16(const CHSV &c1)
Create palette filled with one color.
CRGBPalette16(const CRGB &c1, const CRGB &c2)
Create palette with a gradient from one color to another.
CRGB entries[16]
the color entries that make up the palette
Definition colorutils.h:999
CRGBPalette16(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
bool operator!=(const CRGBPalette16 &rhs) const
Check if two palettes do not have the same color entries.
CRGBPalette16 & operator=(const CHSV rhs[16])
Create palette from array of CHSV colors.
CRGBPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4)
Create palette with four-color gradient.
CRGBPalette16(const CHSV rhs[16])
Create palette from array of CHSV colors.
bool operator==(const CRGBPalette16 &rhs) const
Check if two palettes have the same color entries.
CRGBPalette16(const CRGB &c00, const CRGB &c01, const CRGB &c02, const CRGB &c03, const CRGB &c04, const CRGB &c05, const CRGB &c06, const CRGB &c07, const CRGB &c08, const CRGB &c09, const CRGB &c10, const CRGB &c11, const CRGB &c12, const CRGB &c13, const CRGB &c14, const CRGB &c15)
Create palette from 16 CRGB values.
CRGBPalette16(const CRGB &c1, const CRGB &c2, const CRGB &c3)
Create palette with three-color gradient.
CRGBPalette16 & operator=(const CRGBPalette16 &rhs)
Copy constructor.
CRGBPalette16(const CHSVPalette16 &rhs)
Create palette from CHSV palette.
CRGBPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3)
Create palette with three-color gradient.
CRGBPalette16(TProgmemRGBGradientPalette_bytes progpal)
Creates a palette from a gradient palette in PROGMEM.
CRGBPalette16 & operator=(const CHSVPalette16 &rhs)
Create palette from CHSV palette.
CRGBPalette16 & operator=(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
CRGBPalette16(const CRGB rhs[16])
Create palette from array of CRGB colors.
CRGBPalette16(const CHSV &c1, const CHSV &c2)
Create palette with a gradient from one color to another.
CRGBPalette16(const CRGBPalette16 &rhs)
Copy constructor.
CRGBPalette16 & operator=(const CRGB rhs[16])
Create palette from array of CRGB colors.
CRGB & operator[](uint8_t x)
Array access operator to index into the gradient entries.
CRGBPalette16 & loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal)
Creates a palette from a gradient palette in dynamic (heap) memory.
CRGBPalette16(const CRGB &c1)
Create palette filled with one color.
CRGBPalette16(const CRGB &c1, const CRGB &c2, const CRGB &c3, const CRGB &c4)
Create palette with four-color gradient.
CRGBPalette16()
Default constructor.
CRGBPalette16 & operator=(TProgmemRGBGradientPalette_bytes progpal)
Creates a palette from a gradient palette in PROGMEM.
RGB color palette with 256 discrete values.
CRGBPalette256(const CRGBPalette16 &rhs16)
Create upscaled palette from 16-entry palette.
CRGBPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4)
Create palette with four-color gradient.
CRGBPalette256(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
CRGBPalette256(const CRGB &c1, const CRGB &c2)
Create palette with a gradient from one color to another.
CRGBPalette256 & operator=(const CHSV rhs[256])
Create palette from array of CHSV colors.
CRGB entries[256]
the color entries that make up the palette
bool operator!=(const CRGBPalette256 &rhs) const
Check if two palettes do not have the same color entries.
CRGBPalette256(const CRGB &c00, const CRGB &c01, const CRGB &c02, const CRGB &c03, const CRGB &c04, const CRGB &c05, const CRGB &c06, const CRGB &c07, const CRGB &c08, const CRGB &c09, const CRGB &c10, const CRGB &c11, const CRGB &c12, const CRGB &c13, const CRGB &c14, const CRGB &c15)
Create palette from 16 CRGB values.
CRGBPalette256(const CRGB &c1, const CRGB &c2, const CRGB &c3, const CRGB &c4)
Create palette with four-color gradient.
CRGBPalette256(const CHSVPalette256 &rhs)
Create palette from CHSV palette.
CRGBPalette256 & loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal)
Creates a palette from a gradient palette in dynamic (heap) memory.
CRGBPalette256 & operator=(TProgmemRGBGradientPalette_bytes progpal)
Creates a palette from a gradient palette in PROGMEM.
CRGBPalette256 & operator=(const CRGBPalette256 &rhs)
Copy constructor.
CRGBPalette256 & operator=(const CRGBPalette16 &rhs16)
Create upscaled palette from 16-entry palette.
CRGBPalette256(const CHSV &c1, const CHSV &c2)
Create palette with a gradient from one color to another.
CRGBPalette256(const CHSV rhs[256])
Create palette from array of CHSV colors.
CRGBPalette256(const CHSV &c1)
Create palette filled with one color.
CRGBPalette256(const CRGB rhs[256])
Create palette from array of CRGB colors.
CRGBPalette256(const CRGBPalette256 &rhs)
Copy constructor.
CRGBPalette256 & operator=(const CHSVPalette256 &rhs)
Copy constructor.
CRGBPalette256(const CRGB &c1, const CRGB &c2, const CRGB &c3)
Create palette with three-color gradient.
bool operator==(const CRGBPalette256 &rhs) const
Check if two palettes have the same color entries.
CRGBPalette256()
Default constructor.
CRGBPalette256 & operator=(const CRGB rhs[256])
Create palette from array of CRGB colors.
CRGBPalette256(TProgmemRGBGradientPalette_bytes progpal)
Creates a palette from a gradient palette in PROGMEM.
CRGB & operator[](uint8_t x)
Array access operator to index into the gradient entries.
CRGBPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3)
Create palette with three-color gradient.
CRGBPalette256(const CRGB &c1)
Create palette filled with one color.
CRGBPalette256 & operator=(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
RGB color palette with 32 discrete values.
CRGBPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3)
Create palette with three-color gradient.
CRGBPalette32(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
bool operator!=(const CRGBPalette32 &rhs) const
Check if two palettes do not have the same color entries.
CRGBPalette32(const CHSV &c1)
Create palette filled with one color.
CRGBPalette32()
Default constructor.
CRGBPalette32 & operator=(const CRGBPalette32 &rhs)
Copy constructor.
bool operator==(const CRGBPalette32 &rhs) const
Check if two palettes have the same color entries.
CRGBPalette32(const CRGB rhs[32])
Create palette from array of CRGB colors.
CRGBPalette32(const CHSV &c1, const CHSV &c2)
Create palette with a gradient from one color to another.
CRGBPalette32(const CRGB &c1, const CRGB &c2, const CRGB &c3)
Create palette with three-color gradient.
CRGBPalette32(const CRGB &c1)
Create palette filled with one color.
CRGBPalette32 & operator=(const CHSVPalette32 &rhs)
Create palette from CHSV palette.
CRGBPalette32 & loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal)
Creates a palette from a gradient palette in dynamic (heap) memory.
CRGBPalette32(const CRGBPalette32 &rhs)
Copy constructor.
CRGBPalette32(const TProgmemRGBPalette32 &rhs)
Create palette from palette stored in PROGMEM.
CRGBPalette32 & operator=(const CHSV rhs[32])
Create palette from array of CHSV colors.
CRGBPalette32 & operator=(const CRGB rhs[32])
Create palette from array of CRGB colors.
CRGBPalette32 & operator=(const CRGBPalette16 &rhs16)
Create upscaled palette from 16-entry palette.
CRGBPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4)
Create palette with four-color gradient.
CRGBPalette32(const CRGBPalette16 &rhs16)
Create upscaled palette from 16-entry palette.
CRGBPalette32 & operator=(const TProgmemRGBPalette32 &rhs)
Create palette from palette stored in PROGMEM.
CRGB & operator[](uint8_t x)
Array access operator to index into the gradient entries.
CRGBPalette32 & operator=(TProgmemRGBGradientPalette_bytes progpal)
Creates a palette from a gradient palette in PROGMEM.
CRGBPalette32(const CRGB &c1, const CRGB &c2, const CRGB &c3, const CRGB &c4)
Create palette with four-color gradient.
CRGBPalette32(const CHSV rhs[32])
Create palette from array of CHSV colors.
CRGBPalette32(const CRGB &c00, const CRGB &c01, const CRGB &c02, const CRGB &c03, const CRGB &c04, const CRGB &c05, const CRGB &c06, const CRGB &c07, const CRGB &c08, const CRGB &c09, const CRGB &c10, const CRGB &c11, const CRGB &c12, const CRGB &c13, const CRGB &c14, const CRGB &c15)
Create palette from 16 CRGB values.
CRGB entries[32]
the color entries that make up the palette
CRGBPalette32(const CHSVPalette32 &rhs)
Create palette from CHSV palette.
CRGBPalette32(TProgmemRGBGradientPalette_bytes progpal)
Creates a palette from a gradient palette in PROGMEM.
CRGBPalette32(const CRGB &c1, const CRGB &c2)
Create palette with a gradient from one color to another.
CRGBPalette32 & operator=(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition xymap.h:39
uint32_t TProgmemRGBPalette32[32]
CRGBPalette32 entries stored in PROGMEM memory.
Definition colorutils.h:80
uint32_t TProgmemRGBPalette16[16]
CRGBPalette16 entries stored in PROGMEM memory.
Definition colorutils.h:76
uint32_t TProgmemHSVPalette32[32]
CHSVPalette32 entries stored in PROGMEM memory.
Definition colorutils.h:81
TProgmemRGBGradientPalette_bytes TProgmemRGBGradientPaletteRef
Alias of TProgmemRGBGradientPalette_bytes.
Definition colorutils.h:92
const TProgmemRGBGradientPalette_byte * TProgmemRGBGradientPalette_bytes
Pointer to bytes of an RGB gradient, stored in PROGMEM memory.
Definition colorutils.h:90
const uint8_t TProgmemRGBGradientPalette_byte
Byte of an RGB gradient, stored in PROGMEM memory.
Definition colorutils.h:86
uint32_t TProgmemHSVPalette16[16]
CHSVPalette16 entries stored in PROGMEM memory.
Definition colorutils.h:77
Wrapper definitions to allow seamless use of PROGMEM in environments that have it.
#define FL_PGM_READ_DWORD_NEAR(x)
Read a double word (32-bit) from PROGMEM memory.
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)
Destructively modifies one color, blending in a given fraction of an overlay color.
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
Computes a new color blended some fraction of the way between two other colors.
void blurRows(CRGB *leds, uint8_t width, uint8_t height, fract8 blur_amount, const XYMap &xymap)
Perform a blur1d() on every row of a rectangular matrix.
void blurColumns(CRGB *leds, uint8_t width, uint8_t height, fract8 blur_amount, const XYMap &xymap)
Perform a blur1d() on every column of a rectangular matrix.
void blur1d(CRGB *leds, uint16_t numLeds, fract8 blur_amount)
One-dimensional blur filter.
void blur2d(CRGB *leds, uint8_t width, uint8_t height, fract8 blur_amount, const XYMap &xymap)
Two-dimensional blur filter.
void fadeToBlackBy(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
Reduce the brightness of an array of pixels all at once.
void nscale8_video(CRGB *leds, uint16_t num_leds, uint8_t scale)
Scale the brightness of an array of pixels all at once.
void fade_raw(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
Reduce the brightness of an array of pixels all at once.
void fadeLightBy(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
Reduce the brightness of an array of pixels all at once.
void nscale8(CRGB *leds, uint16_t num_leds, uint8_t scale)
Scale the brightness of an array of pixels all at once.
void fadeUsingColor(CRGB *leds, uint16_t numLeds, const CRGB &colormask)
Reduce the brightness of an array of pixels as thought it were seen through a transparent filter with...
void fade_video(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
Reduce the brightness of an array of pixels all at once.
TGradientDirectionCode
Hue direction for calculating fill gradients.
Definition colorutils.h:157
void fill_rainbow(struct CRGB *targetArray, int numToFill, uint8_t initialhue, uint8_t deltahue=5)
Fill a range of LEDs with a rainbow of colors.
void fill_gradient(T *targetArray, uint16_t startpos, CHSV startcolor, uint16_t endpos, CHSV endcolor, TGradientDirectionCode directionCode=SHORTEST_HUES)
Fill a range of LEDs with a smooth HSV gradient between two HSV colors.
Definition colorutils.h:186
#define saccum87
ANSI: signed short _Accum.
Definition colorutils.h:167
void fill_gradient_RGB(CRGB *leds, uint16_t startpos, CRGB startcolor, uint16_t endpos, CRGB endcolor)
Fill a range of LEDs with a smooth RGB gradient between two RGB colors.
void fill_rainbow_circular(struct CRGB *targetArray, int numToFill, uint8_t initialhue, bool reversed=false)
Fill a range of LEDs with a rainbow of colors, so that the hues are continuous between the end of the...
void fill_solid(struct CRGB *targetArray, int numToFill, const struct CRGB &color)
Fill a range of LEDs with a solid color.
CRGB HeatColor(uint8_t temperature)
Approximates a "black body radiation" spectrum for a given "heat" level.
@ LONGEST_HUES
Hue goes whichever way is longest.
Definition colorutils.h:161
@ FORWARD_HUES
Hue always goes clockwise around the color wheel.
Definition colorutils.h:158
@ SHORTEST_HUES
Hue goes whichever way is shortest.
Definition colorutils.h:160
@ BACKWARD_HUES
Hue always goes counter-clockwise around the color wheel.
Definition colorutils.h:159
void * memmove8(void *dst, const void *src, uint16_t num)
Faster alternative to memmove() on AVR.
uint16_t accum88
ANSI: unsigned short _Accum. 8 bits int, 8 bits fraction.
Definition types.h:52
uint8_t fract8
ANSI: unsigned short _Fract.
Definition types.h:30
CRGB & napplyGamma_video(CRGB &rgb, float gamma)
Destructively applies a gamma adjustment to a color.
uint8_t applyGamma_video(uint8_t brightness, float gamma)
Applies a gamma adjustment to a color channel.
TDynamicRGBGradientPalette_bytes TDynamicRGBGradientPaletteRef
Alias of TDynamicRGBGradientPalette_bytes.
Definition colorutils.h:683
uint8_t TDynamicRGBGradientPalette_byte
Byte of an RGB gradient entry, stored in dynamic (heap) memory.
Definition colorutils.h:681
const TDynamicRGBGradientPalette_byte * TDynamicRGBGradientPalette_bytes
Pointer to bytes of an RGB gradient, stored in dynamic (heap) memory.
Definition colorutils.h:682
void fill_palette_circular(CRGB *L, uint16_t N, uint8_t startIndex, const PALETTE &pal, uint8_t brightness=255, TBlendType blendType=LINEARBLEND, bool reversed=false)
Fill a range of LEDs with a sequence of entries from a palette, so that the entire palette smoothly c...
void nblendPaletteTowardPalette(CRGBPalette16 &currentPalette, CRGBPalette16 &targetPalette, uint8_t maxChanges=24)
Alter one palette by making it slightly more like a "target palette".
TBlendType
Color interpolation options for palette.
void fill_palette(CRGB *L, uint16_t N, uint8_t startIndex, uint8_t incIndex, const PALETTE &pal, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
Fill a range of LEDs with a sequence of entries from a palette.
CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
Get a color from a palette.
void map_data_into_colors_through_palette(uint8_t *dataArray, uint16_t dataCount, CRGB *targetColorArray, const PALETTE &pal, uint8_t brightness=255, uint8_t opacity=255, TBlendType blendType=LINEARBLEND)
Maps an array of palette color indexes into an array of LED colors.
@ NOBLEND
No interpolation between palette entries.
@ LINEARBLEND
Linear interpolation between palette entries, with wrap-around from end to the beginning again.
@ LINEARBLEND_NOWRAP
Linear interpolation between palette entries, but no wrap-around.
void UpscalePalette(const class CRGBPalette16 &srcpal16, class CRGBPalette256 &destpal256)
Convert a 16-entry palette to a 256-entry palette.
FASTLED_FORCE_INLINE CRGB & nscale8_video(uint8_t scaledown)
Scale down a RGB to N/256ths of it's current brightness using "video" dimming rules.
Definition crgb.hpp:75
FASTLED_FORCE_INLINE CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.hpp:108
uint8_t red
Red channel value.
Definition crgb.h:44
uint8_t blue
Blue channel value.
Definition crgb.h:52
uint8_t green
Green channel value.
Definition crgb.h:48
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:11
uint8_t hue
Color hue.
Definition chsv.h:18
uint8_t sat
Color saturation.
Definition chsv.h:25
uint8_t value
Color value (brightness).
Definition chsv.h:31
uint8_t saturation
Color saturation.
Definition chsv.h:24
uint8_t val
Color value (brightness).
Definition chsv.h:32
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39
Struct for digesting gradient pointer data into its components.
Definition colorutils.h:670
uint8_t g
CRGB::green channel value of the color entry.
Definition colorutils.h:674
uint32_t dword
values as a packed 32-bit double word
Definition colorutils.h:677
uint8_t b
CRGB::blue channel value of the color entry.
Definition colorutils.h:675
uint8_t index
index of the color entry in the gradient
Definition colorutils.h:672
uint8_t r
CRGB::red channel value of the color entry.
Definition colorutils.h:673