FastLED 3.9.12
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 "fl/xymap.h"
11#include "fl/deprecated.h"
12
13#if !defined(FASTLED_USE_32_BIT_GRADIENT_FILL)
14 #if defined(__AVR__)
15 #define FASTLED_USE_32_BIT_GRADIENT_FILL 0
16 #else
17 #define FASTLED_USE_32_BIT_GRADIENT_FILL 1
18 #endif
19#endif
20
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wcast-align"
23
69#define DEFINE_GRADIENT_PALETTE(X) \
70 FL_ALIGN_PROGMEM \
71 extern const ::TProgmemRGBGradientPalette_byte X[] FL_PROGMEM =
72
74#define DECLARE_GRADIENT_PALETTE(X) \
75 FL_ALIGN_PROGMEM \
76 extern const ::TProgmemRGBGradientPalette_byte X[] FL_PROGMEM
77
78
79typedef uint32_t TProgmemRGBPalette16[16];
80typedef uint32_t TProgmemHSVPalette16[16];
82#define TProgmemPalette16 TProgmemRGBPalette16
83typedef uint32_t TProgmemRGBPalette32[32];
84typedef uint32_t TProgmemHSVPalette32[32];
86#define TProgmemPalette32 TProgmemRGBPalette32
87
89typedef const uint8_t TProgmemRGBGradientPalette_byte;
96
97
98
99
100
101
103
107
111
116void fill_solid( struct CRGB * targetArray, int numToFill,
117 const struct CRGB& color);
118
120void fill_solid( struct CHSV* targetArray, int numToFill,
121 const struct CHSV& color);
122
123
131void fill_rainbow( struct CRGB * targetArray, int numToFill,
132 uint8_t initialhue,
133 uint8_t deltahue = 5);
134
136void fill_rainbow( struct CHSV * targetArray, int numToFill,
137 uint8_t initialhue,
138 uint8_t deltahue = 5);
139
140
149void fill_rainbow_circular(struct CRGB* targetArray, int numToFill,
150 uint8_t initialhue, bool reversed=false);
151
153void fill_rainbow_circular(struct CHSV* targetArray, int numToFill,
154 uint8_t initialhue, bool reversed=false);
155
156
166
167
170#define saccum87 int16_t
171
172
188template <typename T>
189void fill_gradient( T* targetArray,
190 uint16_t startpos, CHSV startcolor,
191 uint16_t endpos, CHSV endcolor,
192 TGradientDirectionCode directionCode = SHORTEST_HUES )
193{
194 // if the points are in the wrong order, straighten them
195 if( endpos < startpos ) {
196 uint16_t t = endpos;
197 CHSV tc = endcolor;
198 endcolor = startcolor;
199 endpos = startpos;
200 startpos = t;
201 startcolor = tc;
202 }
203
204 // If we're fading toward black (val=0) or white (sat=0),
205 // then set the endhue to the starthue.
206 // This lets us ramp smoothly to black or white, regardless
207 // of what 'hue' was set in the endcolor (since it doesn't matter)
208 if( endcolor.value == 0 || endcolor.saturation == 0) {
209 endcolor.hue = startcolor.hue;
210 }
211
212 // Similarly, if we're fading in from black (val=0) or white (sat=0)
213 // then set the starthue to the endhue.
214 // This lets us ramp smoothly up from black or white, regardless
215 // of what 'hue' was set in the startcolor (since it doesn't matter)
216 if( startcolor.value == 0 || startcolor.saturation == 0) {
217 startcolor.hue = endcolor.hue;
218 }
219
220 saccum87 huedistance87;
221 saccum87 satdistance87;
222 saccum87 valdistance87;
223
224 satdistance87 = (endcolor.sat - startcolor.sat) << 7;
225 valdistance87 = (endcolor.val - startcolor.val) << 7;
226
227 uint8_t huedelta8 = endcolor.hue - startcolor.hue;
228
229 if( directionCode == SHORTEST_HUES ) {
230 directionCode = FORWARD_HUES;
231 if( huedelta8 > 127) {
232 directionCode = BACKWARD_HUES;
233 }
234 }
235
236 if( directionCode == LONGEST_HUES ) {
237 directionCode = FORWARD_HUES;
238 if( huedelta8 < 128) {
239 directionCode = BACKWARD_HUES;
240 }
241 }
242
243 if( directionCode == FORWARD_HUES) {
244 huedistance87 = huedelta8 << 7;
245 }
246 else /* directionCode == BACKWARD_HUES */
247 {
248 huedistance87 = (uint8_t)(256 - huedelta8) << 7;
249 huedistance87 = -huedistance87;
250 }
251
252 uint16_t pixeldistance = endpos - startpos;
253 int16_t divisor = pixeldistance ? pixeldistance : 1;
254
255 #if FASTLED_USE_32_BIT_GRADIENT_FILL
256 // Use higher precision 32 bit math for new micros.
257 int32_t huedelta823 = (huedistance87 * 65536) / divisor;
258 int32_t satdelta823 = (satdistance87 * 65536) / divisor;
259 int32_t valdelta823 = (valdistance87 * 65536) / divisor;
260
261 huedelta823 *= 2;
262 satdelta823 *= 2;
263 valdelta823 *= 2;
264 uint32_t hue824 = static_cast<uint32_t>(startcolor.hue) << 24;
265 uint32_t sat824 = static_cast<uint32_t>(startcolor.sat) << 24;
266 uint32_t val824 = static_cast<uint32_t>(startcolor.val) << 24;
267 for( uint16_t i = startpos; i <= endpos; ++i) {
268 targetArray[i] = CHSV( hue824 >> 24, sat824 >> 24, val824 >> 24);
269 hue824 += huedelta823;
270 sat824 += satdelta823;
271 val824 += valdelta823;
272 }
273 #else
274 // Use 8-bit math for older micros.
275 saccum87 huedelta87 = huedistance87 / divisor;
276 saccum87 satdelta87 = satdistance87 / divisor;
277 saccum87 valdelta87 = valdistance87 / divisor;
278
279 huedelta87 *= 2;
280 satdelta87 *= 2;
281 valdelta87 *= 2;
282
283 accum88 hue88 = startcolor.hue << 8;
284 accum88 sat88 = startcolor.sat << 8;
285 accum88 val88 = startcolor.val << 8;
286 for( uint16_t i = startpos; i <= endpos; ++i) {
287 targetArray[i] = CHSV( hue88 >> 8, sat88 >> 8, val88 >> 8);
288 hue88 += huedelta87;
289 sat88 += satdelta87;
290 val88 += valdelta87;
291 }
292 #endif // defined(__AVR__)
293}
294
295
303template <typename T>
304void fill_gradient( T* targetArray, uint16_t numLeds, const CHSV& c1, const CHSV& c2,
305 TGradientDirectionCode directionCode = SHORTEST_HUES )
306{
307 uint16_t last = numLeds - 1;
308 fill_gradient( targetArray, 0, c1, last, c2, directionCode);
309}
310
319template <typename T>
320void fill_gradient( T* targetArray, uint16_t numLeds,
321 const CHSV& c1, const CHSV& c2, const CHSV& c3,
322 TGradientDirectionCode directionCode = SHORTEST_HUES )
323{
324 uint16_t half = (numLeds / 2);
325 uint16_t last = numLeds - 1;
326 fill_gradient( targetArray, 0, c1, half, c2, directionCode);
327 fill_gradient( targetArray, half, c2, last, c3, directionCode);
328}
329
339template <typename T>
340void fill_gradient( T* targetArray, uint16_t numLeds,
341 const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4,
342 TGradientDirectionCode directionCode = SHORTEST_HUES )
343{
344 uint16_t onethird = (numLeds / 3);
345 uint16_t twothirds = ((numLeds * 2) / 3);
346 uint16_t last = numLeds - 1;
347 fill_gradient( targetArray, 0, c1, onethird, c2, directionCode);
348 fill_gradient( targetArray, onethird, c2, twothirds, c3, directionCode);
349 fill_gradient( targetArray, twothirds, c3, last, c4, directionCode);
350}
351
353#define fill_gradient_HSV fill_gradient
354
355
365void fill_gradient_RGB( CRGB* leds,
366 uint16_t startpos, CRGB startcolor,
367 uint16_t endpos, CRGB endcolor );
368
375void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2);
376
384void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2, const CRGB& c3);
385
394void fill_gradient_RGB( CRGB* leds, uint16_t numLeds, const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4);
395
397
398
402
408void fadeLightBy( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
409
411void fade_video( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
412
418void nscale8_video( CRGB* leds, uint16_t num_leds, uint8_t scale);
419
420
426void fadeToBlackBy( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
427
429void fade_raw( CRGB* leds, uint16_t num_leds, uint8_t fadeBy);
430
431
438void nscale8( CRGB* leds, uint16_t num_leds, uint8_t scale);
439
440
451void fadeUsingColor( CRGB* leds, uint16_t numLeds, const CRGB& colormask);
452
454
455
459
464CRGB blend( const CRGB& p1, const CRGB& p2, fract8 amountOfP2 );
465
468CHSV blend( const CHSV& p1, const CHSV& p2, fract8 amountOfP2,
469 TGradientDirectionCode directionCode = SHORTEST_HUES );
470
471
480CRGB* blend( const CRGB* src1, const CRGB* src2, CRGB* dest,
481 uint16_t count, fract8 amountOfsrc2 );
482
485CHSV* blend( const CHSV* src1, const CHSV* src2, CHSV* dest,
486 uint16_t count, fract8 amountOfsrc2,
487 TGradientDirectionCode directionCode = SHORTEST_HUES );
488
489
494CRGB& nblend( CRGB& existing, const CRGB& overlay, fract8 amountOfOverlay );
495
498CHSV& nblend( CHSV& existing, const CHSV& overlay, fract8 amountOfOverlay,
499 TGradientDirectionCode directionCode = SHORTEST_HUES );
500
501
507void nblend( CRGB* existing, CRGB* overlay, uint16_t count, fract8 amountOfOverlay);
508
511void nblend( CHSV* existing, CHSV* overlay, uint16_t count, fract8 amountOfOverlay,
512 TGradientDirectionCode directionCode = SHORTEST_HUES);
513
515
516
520
535void blur1d( CRGB* leds, uint16_t numLeds, fract8 blur_amount);
536
552void blur2d( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount, const fl::XYMap& xymap);
553
556void blur2d( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount) FASTLED_DEPRECATED("Use blur2d(..., const fl::XYMap& xymap) instead");
557
558
565void blurRows( CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount, const fl::XYMap& xymap);
566
569void blurColumns(CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount, const fl::XYMap& xymap);
570
572
573
576
582CRGB HeatColor( uint8_t temperature);
583
586
587
655
656
663
664class CRGBPalette16;
665class CRGBPalette32;
666class CRGBPalette256;
667class CHSVPalette16;
668class CHSVPalette32;
669class CHSVPalette256;
670
671
672
677typedef union {
678 struct {
679 uint8_t index;
680 uint8_t r;
681 uint8_t g;
682 uint8_t b;
683 };
684 uint32_t dword;
685 uint8_t bytes[4];
687
691
693
694
698
702void UpscalePalette(const class CRGBPalette16& srcpal16, class CRGBPalette256& destpal256);
704void UpscalePalette(const class CHSVPalette16& srcpal16, class CHSVPalette256& destpal256);
705
709void UpscalePalette(const class CRGBPalette16& srcpal16, class CRGBPalette32& destpal32);
711void UpscalePalette(const class CHSVPalette16& srcpal16, class CHSVPalette32& destpal32);
712
716void UpscalePalette(const class CRGBPalette32& srcpal32, class CRGBPalette256& destpal256);
718void UpscalePalette(const class CHSVPalette32& srcpal32, class CHSVPalette256& destpal256);
719
721
722
725
728public:
730
733
735 CHSVPalette16( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03,
736 const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07,
737 const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11,
738 const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 )
739 {
740 entries[0]=c00; entries[1]=c01; entries[2]=c02; entries[3]=c03;
741 entries[4]=c04; entries[5]=c05; entries[6]=c06; entries[7]=c07;
742 entries[8]=c08; entries[9]=c09; entries[10]=c10; entries[11]=c11;
743 entries[12]=c12; entries[13]=c13; entries[14]=c14; entries[15]=c15;
744 };
745
748 {
749 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
750 }
751
754 {
755 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
756 return *this;
757 }
758
761 {
762 for( uint8_t i = 0; i < 16; ++i) {
763 CRGB xyz(FL_PGM_READ_DWORD_NEAR( rhs + i));
764 entries[i].hue = xyz.red;
765 entries[i].sat = xyz.green;
766 entries[i].val = xyz.blue;
767 }
768 }
769
772 {
773 for( uint8_t i = 0; i < 16; ++i) {
774 CRGB xyz(FL_PGM_READ_DWORD_NEAR( rhs + i));
775 entries[i].hue = xyz.red;
776 entries[i].sat = xyz.green;
777 entries[i].val = xyz.blue;
778 }
779 return *this;
780 }
781
788 inline CHSV& operator[] (uint8_t x) __attribute__((always_inline))
789 {
790 return entries[x];
791 }
792
794 inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline))
795 {
796 return entries[x];
797 }
798
800 inline CHSV& operator[] (int x) __attribute__((always_inline))
801 {
802 return entries[(uint8_t)x];
803 }
804
806 inline const CHSV& operator[] (int x) const __attribute__((always_inline))
807 {
808 return entries[(uint8_t)x];
809 }
810
812 operator CHSV*()
813 {
814 return &(entries[0]);
815 }
816
818 bool operator==( const CHSVPalette16 &rhs) const
819 {
820 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
821 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
822 if( p == q) return true;
823 for( uint8_t i = 0; i < (sizeof( entries)); ++i) {
824 if( *p != *q) return false;
825 ++p;
826 ++q;
827 }
828 return true;
829 }
830
832 bool operator!=( const CHSVPalette16 &rhs) const
833 {
834 return !( *this == rhs);
835 }
836
839 CHSVPalette16( const CHSV& c1)
840 {
841 fill_solid( &(entries[0]), 16, c1);
842 }
843
847 CHSVPalette16( const CHSV& c1, const CHSV& c2)
848 {
849 fill_gradient( &(entries[0]), 16, c1, c2);
850 }
851
856 CHSVPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3)
857 {
858 fill_gradient( &(entries[0]), 16, c1, c2, c3);
859 }
860
866 CHSVPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
867 {
868 fill_gradient( &(entries[0]), 16, c1, c2, c3, c4);
869 }
870
871};
872
875public:
877
880
885 CHSVPalette256( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03,
886 const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07,
887 const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11,
888 const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 )
889 {
890 CHSVPalette16 p16(c00,c01,c02,c03,c04,c05,c06,c07,
891 c08,c09,c10,c11,c12,c13,c14,c15);
892 *this = p16;
893 };
894
897 {
898 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
899 }
902 {
903 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
904 return *this;
905 }
906
909 {
910 UpscalePalette( rhs16, *this);
911 }
914 {
915 UpscalePalette( rhs16, *this);
916 return *this;
917 }
918
921 {
922 CHSVPalette16 p16(rhs);
923 *this = p16;
924 }
927 {
928 CHSVPalette16 p16(rhs);
929 *this = p16;
930 return *this;
931 }
932
934 inline CHSV& operator[] (uint8_t x) __attribute__((always_inline))
935 {
936 return entries[x];
937 }
939 inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline))
940 {
941 return entries[x];
942 }
943
945 inline CHSV& operator[] (int x) __attribute__((always_inline))
946 {
947 return entries[(uint8_t)x];
948 }
950 inline const CHSV& operator[] (int x) const __attribute__((always_inline))
951 {
952 return entries[(uint8_t)x];
953 }
954
956 operator CHSV*()
957 {
958 return &(entries[0]);
959 }
960
962 bool operator==( const CHSVPalette256 &rhs) const
963 {
964 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
965 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
966 if( p == q) return true;
967 for( uint16_t i = 0; i < (sizeof( entries)); ++i) {
968 if( *p != *q) return false;
969 ++p;
970 ++q;
971 }
972 return true;
973 }
974
976 bool operator!=( const CHSVPalette256 &rhs) const
977 {
978 return !( *this == rhs);
979 }
980
983 {
984 fill_solid( &(entries[0]), 256, c1);
985 }
987 CHSVPalette256( const CHSV& c1, const CHSV& c2)
988 {
989 fill_gradient( &(entries[0]), 256, c1, c2);
990 }
992 CHSVPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3)
993 {
994 fill_gradient( &(entries[0]), 256, c1, c2, c3);
995 }
997 CHSVPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
998 {
999 fill_gradient( &(entries[0]), 256, c1, c2, c3, c4);
1000 }
1001};
1002
1005public:
1007
1010
1012 CRGBPalette16( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03,
1013 const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07,
1014 const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11,
1015 const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 )
1016 {
1017 entries[0]=c00; entries[1]=c01; entries[2]=c02; entries[3]=c03;
1018 entries[4]=c04; entries[5]=c05; entries[6]=c06; entries[7]=c07;
1019 entries[8]=c08; entries[9]=c09; entries[10]=c10; entries[11]=c11;
1020 entries[12]=c12; entries[13]=c13; entries[14]=c14; entries[15]=c15;
1021 };
1022
1025 {
1026 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1027 }
1029 CRGBPalette16( const CRGB rhs[16])
1030 {
1031 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1032 }
1035 {
1036 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1037 return *this;
1038 }
1041 {
1042 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1043 return *this;
1044 }
1045
1048 {
1049 for( uint8_t i = 0; i < 16; ++i) {
1050 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1051 }
1052 }
1054 CRGBPalette16( const CHSV rhs[16])
1055 {
1056 for( uint8_t i = 0; i < 16; ++i) {
1057 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1058 }
1059 }
1062 {
1063 for( uint8_t i = 0; i < 16; ++i) {
1064 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1065 }
1066 return *this;
1067 }
1070 {
1071 for( uint8_t i = 0; i < 16; ++i) {
1072 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1073 }
1074 return *this;
1075 }
1076
1079 {
1080 for( uint8_t i = 0; i < 16; ++i) {
1081 entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i);
1082 }
1083 }
1086 {
1087 for( uint8_t i = 0; i < 16; ++i) {
1088 entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i);
1089 }
1090 return *this;
1091 }
1092
1094 bool operator==( const CRGBPalette16 &rhs) const
1095 {
1096 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
1097 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
1098 if( p == q) return true;
1099 for( uint8_t i = 0; i < (sizeof( entries)); ++i) {
1100 if( *p != *q) return false;
1101 ++p;
1102 ++q;
1103 }
1104 return true;
1105 }
1107 bool operator!=( const CRGBPalette16 &rhs) const
1108 {
1109 return !( *this == rhs);
1110 }
1112 inline CRGB& operator[] (uint8_t x) __attribute__((always_inline))
1113 {
1114 return entries[x];
1115 }
1117 inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline))
1118 {
1119 return entries[x];
1120 }
1121
1123 inline CRGB& operator[] (int x) __attribute__((always_inline))
1124 {
1125 return entries[(uint8_t)x];
1126 }
1128 inline const CRGB& operator[] (int x) const __attribute__((always_inline))
1129 {
1130 return entries[(uint8_t)x];
1131 }
1132
1134 operator CRGB*()
1135 {
1136 return &(entries[0]);
1137 }
1138
1141 {
1142 fill_solid( &(entries[0]), 16, c1);
1143 }
1145 CRGBPalette16( const CHSV& c1, const CHSV& c2)
1146 {
1147 fill_gradient( &(entries[0]), 16, c1, c2);
1148 }
1150 CRGBPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3)
1151 {
1152 fill_gradient( &(entries[0]), 16, c1, c2, c3);
1153 }
1155 CRGBPalette16( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
1156 {
1157 fill_gradient( &(entries[0]), 16, c1, c2, c3, c4);
1158 }
1159
1162 {
1163 fill_solid( &(entries[0]), 16, c1);
1164 }
1166 CRGBPalette16( const CRGB& c1, const CRGB& c2)
1167 {
1168 fill_gradient_RGB( &(entries[0]), 16, c1, c2);
1169 }
1171 CRGBPalette16( const CRGB& c1, const CRGB& c2, const CRGB& c3)
1172 {
1173 fill_gradient_RGB( &(entries[0]), 16, c1, c2, c3);
1174 }
1176 CRGBPalette16( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4)
1177 {
1178 fill_gradient_RGB( &(entries[0]), 16, c1, c2, c3, c4);
1179 }
1180
1211 {
1212 *this = progpal;
1213 }
1216 {
1219
1220 // Count entries
1221 uint16_t count = 0;
1222 do {
1223 u.dword = FL_PGM_READ_DWORD_NEAR(progent + count);
1224 ++count;
1225 } while ( u.index != 255);
1226
1227 int8_t lastSlotUsed = -1;
1228
1229 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1230 CRGB rgbstart( u.r, u.g, u.b);
1231
1232 int indexstart = 0;
1233 uint8_t istart8 = 0;
1234 uint8_t iend8 = 0;
1235 while( indexstart < 255) {
1236 ++progent;
1237 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1238 int indexend = u.index;
1239 CRGB rgbend( u.r, u.g, u.b);
1240 istart8 = indexstart / 16;
1241 iend8 = indexend / 16;
1242 if( count < 16) {
1243 if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) {
1244 istart8 = lastSlotUsed + 1;
1245 if( iend8 < istart8) {
1246 iend8 = istart8;
1247 }
1248 }
1249 lastSlotUsed = iend8;
1250 }
1251 fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend);
1252 indexstart = indexend;
1253 rgbstart = rgbend;
1254 }
1255 return *this;
1256 }
1260 {
1263
1264 // Count entries
1265 uint16_t count = 0;
1266 do {
1267 u = *(ent + count);
1268 ++count;
1269 } while ( u.index != 255);
1270
1271 int8_t lastSlotUsed = -1;
1272
1273
1274 u = *ent;
1275 CRGB rgbstart( u.r, u.g, u.b);
1276
1277 int indexstart = 0;
1278 uint8_t istart8 = 0;
1279 uint8_t iend8 = 0;
1280 while( indexstart < 255) {
1281 ++ent;
1282 u = *ent;
1283 int indexend = u.index;
1284 CRGB rgbend( u.r, u.g, u.b);
1285 istart8 = indexstart / 16;
1286 iend8 = indexend / 16;
1287 if( count < 16) {
1288 if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) {
1289 istart8 = lastSlotUsed + 1;
1290 if( iend8 < istart8) {
1291 iend8 = istart8;
1292 }
1293 }
1294 lastSlotUsed = iend8;
1295 }
1296 fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend);
1297 indexstart = indexend;
1298 rgbstart = rgbend;
1299 }
1300 return *this;
1301 }
1302
1303};
1304
1305
1308public:
1310
1313
1318 CHSVPalette32( const CHSV& c00,const CHSV& c01,const CHSV& c02,const CHSV& c03,
1319 const CHSV& c04,const CHSV& c05,const CHSV& c06,const CHSV& c07,
1320 const CHSV& c08,const CHSV& c09,const CHSV& c10,const CHSV& c11,
1321 const CHSV& c12,const CHSV& c13,const CHSV& c14,const CHSV& c15 )
1322 {
1323 for( uint8_t i = 0; i < 2; ++i) {
1324 entries[0+i]=c00; entries[2+i]=c01; entries[4+i]=c02; entries[6+i]=c03;
1325 entries[8+i]=c04; entries[10+i]=c05; entries[12+i]=c06; entries[14+i]=c07;
1326 entries[16+i]=c08; entries[18+i]=c09; entries[20+i]=c10; entries[22+i]=c11;
1327 entries[24+i]=c12; entries[26+i]=c13; entries[28+i]=c14; entries[30+i]=c15;
1328 }
1329 };
1330
1333 {
1334 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1335 }
1338 {
1339 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1340 return *this;
1341 }
1342
1345 {
1346 for( uint8_t i = 0; i < 32; ++i) {
1347 CRGB xyz(FL_PGM_READ_DWORD_NEAR( rhs + i));
1348 entries[i].hue = xyz.red;
1349 entries[i].sat = xyz.green;
1350 entries[i].val = xyz.blue;
1351 }
1352 }
1355 {
1356 for( uint8_t i = 0; i < 32; ++i) {
1357 CRGB xyz(FL_PGM_READ_DWORD_NEAR( rhs + i));
1358 entries[i].hue = xyz.red;
1359 entries[i].sat = xyz.green;
1360 entries[i].val = xyz.blue;
1361 }
1362 return *this;
1363 }
1364
1366 inline CHSV& operator[] (uint8_t x) __attribute__((always_inline))
1367 {
1368 return entries[x];
1369 }
1371 inline const CHSV& operator[] (uint8_t x) const __attribute__((always_inline))
1372 {
1373 return entries[x];
1374 }
1375
1377 inline CHSV& operator[] (int x) __attribute__((always_inline))
1378 {
1379 return entries[(uint8_t)x];
1380 }
1382 inline const CHSV& operator[] (int x) const __attribute__((always_inline))
1383 {
1384 return entries[(uint8_t)x];
1385 }
1386
1388 operator CHSV*()
1389 {
1390 return &(entries[0]);
1391 }
1392
1394 bool operator==( const CHSVPalette32 &rhs) const
1395 {
1396 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
1397 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
1398 if( p == q) return true;
1399 for( uint8_t i = 0; i < (sizeof( entries)); ++i) {
1400 if( *p != *q) return false;
1401 ++p;
1402 ++q;
1403 }
1404 return true;
1405 }
1407 bool operator!=( const CHSVPalette32 &rhs) const
1408 {
1409 return !( *this == rhs);
1410 }
1411
1414 {
1415 fill_solid( &(entries[0]), 32, c1);
1416 }
1418 CHSVPalette32( const CHSV& c1, const CHSV& c2)
1419 {
1420 fill_gradient( &(entries[0]), 32, c1, c2);
1421 }
1423 CHSVPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3)
1424 {
1425 fill_gradient( &(entries[0]), 32, c1, c2, c3);
1426 }
1428 CHSVPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
1429 {
1430 fill_gradient( &(entries[0]), 32, c1, c2, c3, c4);
1431 }
1432
1433};
1434
1437public:
1439
1442
1448 CRGBPalette32( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03,
1449 const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07,
1450 const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11,
1451 const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 )
1452 {
1453 for( uint8_t i = 0; i < 2; ++i) {
1454 entries[0+i]=c00; entries[2+i]=c01; entries[4+i]=c02; entries[6+i]=c03;
1455 entries[8+i]=c04; entries[10+i]=c05; entries[12+i]=c06; entries[14+i]=c07;
1456 entries[16+i]=c08; entries[18+i]=c09; entries[20+i]=c10; entries[22+i]=c11;
1457 entries[24+i]=c12; entries[26+i]=c13; entries[28+i]=c14; entries[30+i]=c15;
1458 }
1459 };
1460
1463 {
1464 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1465 }
1467 CRGBPalette32( const CRGB rhs[32])
1468 {
1469 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1470 }
1473 {
1474 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1475 return *this;
1476 }
1479 {
1480 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1481 return *this;
1482 }
1483
1486 {
1487 for( uint8_t i = 0; i < 32; ++i) {
1488 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1489 }
1490 }
1492 CRGBPalette32( const CHSV rhs[32])
1493 {
1494 for( uint8_t i = 0; i < 32; ++i) {
1495 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1496 }
1497 }
1500 {
1501 for( uint8_t i = 0; i < 32; ++i) {
1502 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1503 }
1504 return *this;
1505 }
1508 {
1509 for( uint8_t i = 0; i < 32; ++i) {
1510 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1511 }
1512 return *this;
1513 }
1514
1517 {
1518 for( uint8_t i = 0; i < 32; ++i) {
1519 entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i);
1520 }
1521 }
1524 {
1525 for( uint8_t i = 0; i < 32; ++i) {
1526 entries[i] = FL_PGM_READ_DWORD_NEAR( rhs + i);
1527 }
1528 return *this;
1529 }
1530
1532 bool operator==( const CRGBPalette32 &rhs) const
1533 {
1534 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
1535 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
1536 if( p == q) return true;
1537 for( uint8_t i = 0; i < (sizeof( entries)); ++i) {
1538 if( *p != *q) return false;
1539 ++p;
1540 ++q;
1541 }
1542 return true;
1543 }
1545 bool operator!=( const CRGBPalette32 &rhs) const
1546 {
1547 return !( *this == rhs);
1548 }
1549
1551 inline CRGB& operator[] (uint8_t x) __attribute__((always_inline))
1552 {
1553 return entries[x];
1554 }
1556 inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline))
1557 {
1558 return entries[x];
1559 }
1560
1562 inline CRGB& operator[] (int x) __attribute__((always_inline))
1563 {
1564 return entries[(uint8_t)x];
1565 }
1567 inline const CRGB& operator[] (int x) const __attribute__((always_inline))
1568 {
1569 return entries[(uint8_t)x];
1570 }
1571
1573 operator CRGB*()
1574 {
1575 return &(entries[0]);
1576 }
1577
1580 {
1581 fill_solid( &(entries[0]), 32, c1);
1582 }
1584 CRGBPalette32( const CHSV& c1, const CHSV& c2)
1585 {
1586 fill_gradient( &(entries[0]), 32, c1, c2);
1587 }
1589 CRGBPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3)
1590 {
1591 fill_gradient( &(entries[0]), 32, c1, c2, c3);
1592 }
1594 CRGBPalette32( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
1595 {
1596 fill_gradient( &(entries[0]), 32, c1, c2, c3, c4);
1597 }
1598
1601 {
1602 fill_solid( &(entries[0]), 32, c1);
1603 }
1605 CRGBPalette32( const CRGB& c1, const CRGB& c2)
1606 {
1607 fill_gradient_RGB( &(entries[0]), 32, c1, c2);
1608 }
1610 CRGBPalette32( const CRGB& c1, const CRGB& c2, const CRGB& c3)
1611 {
1612 fill_gradient_RGB( &(entries[0]), 32, c1, c2, c3);
1613 }
1615 CRGBPalette32( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4)
1616 {
1617 fill_gradient_RGB( &(entries[0]), 32, c1, c2, c3, c4);
1618 }
1619
1620
1623 {
1624 UpscalePalette( rhs16, *this);
1625 }
1628 {
1629 UpscalePalette( rhs16, *this);
1630 return *this;
1631 }
1632
1635 {
1636 CRGBPalette16 p16(rhs);
1637 *this = p16;
1638 }
1641 {
1642 CRGBPalette16 p16(rhs);
1643 *this = p16;
1644 return *this;
1645 }
1646
1647
1650 {
1651 *this = progpal;
1652 }
1655 {
1658
1659 // Count entries
1660 uint16_t count = 0;
1661 do {
1662 u.dword = FL_PGM_READ_DWORD_NEAR(progent + count);
1663 ++count;
1664 } while ( u.index != 255);
1665
1666 int8_t lastSlotUsed = -1;
1667
1668 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1669 CRGB rgbstart( u.r, u.g, u.b);
1670
1671 int indexstart = 0;
1672 uint8_t istart8 = 0;
1673 uint8_t iend8 = 0;
1674 while( indexstart < 255) {
1675 ++progent;
1676 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1677 int indexend = u.index;
1678 CRGB rgbend( u.r, u.g, u.b);
1679 istart8 = indexstart / 8;
1680 iend8 = indexend / 8;
1681 if( count < 16) {
1682 if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) {
1683 istart8 = lastSlotUsed + 1;
1684 if( iend8 < istart8) {
1685 iend8 = istart8;
1686 }
1687 }
1688 lastSlotUsed = iend8;
1689 }
1690 fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend);
1691 indexstart = indexend;
1692 rgbstart = rgbend;
1693 }
1694 return *this;
1695 }
1698 {
1701
1702 // Count entries
1703 uint16_t count = 0;
1704 do {
1705 u = *(ent + count);
1706 ++count;
1707 } while ( u.index != 255);
1708
1709 int8_t lastSlotUsed = -1;
1710
1711
1712 u = *ent;
1713 CRGB rgbstart( u.r, u.g, u.b);
1714
1715 int indexstart = 0;
1716 uint8_t istart8 = 0;
1717 uint8_t iend8 = 0;
1718 while( indexstart < 255) {
1719 ++ent;
1720 u = *ent;
1721 int indexend = u.index;
1722 CRGB rgbend( u.r, u.g, u.b);
1723 istart8 = indexstart / 8;
1724 iend8 = indexend / 8;
1725 if( count < 16) {
1726 if( (istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) {
1727 istart8 = lastSlotUsed + 1;
1728 if( iend8 < istart8) {
1729 iend8 = istart8;
1730 }
1731 }
1732 lastSlotUsed = iend8;
1733 }
1734 fill_gradient_RGB( &(entries[0]), istart8, rgbstart, iend8, rgbend);
1735 indexstart = indexend;
1736 rgbstart = rgbend;
1737 }
1738 return *this;
1739 }
1740
1741};
1742
1743
1746public:
1748
1751
1757 CRGBPalette256( const CRGB& c00,const CRGB& c01,const CRGB& c02,const CRGB& c03,
1758 const CRGB& c04,const CRGB& c05,const CRGB& c06,const CRGB& c07,
1759 const CRGB& c08,const CRGB& c09,const CRGB& c10,const CRGB& c11,
1760 const CRGB& c12,const CRGB& c13,const CRGB& c14,const CRGB& c15 )
1761 {
1762 CRGBPalette16 p16(c00,c01,c02,c03,c04,c05,c06,c07,
1763 c08,c09,c10,c11,c12,c13,c14,c15);
1764 *this = p16;
1765 };
1766
1769 {
1770 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1771 }
1773 CRGBPalette256( const CRGB rhs[256])
1774 {
1775 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1776 }
1779 {
1780 memmove8( (void *) &(entries[0]), &(rhs.entries[0]), sizeof( entries));
1781 return *this;
1782 }
1785 {
1786 memmove8( (void *) &(entries[0]), &(rhs[0]), sizeof( entries));
1787 return *this;
1788 }
1789
1792 {
1793 for( int i = 0; i < 256; ++i) {
1794 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1795 }
1796 }
1798 CRGBPalette256( const CHSV rhs[256])
1799 {
1800 for( int i = 0; i < 256; ++i) {
1801 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1802 }
1803 }
1806 {
1807 for( int i = 0; i < 256; ++i) {
1808 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1809 }
1810 return *this;
1811 }
1814 {
1815 for( int i = 0; i < 256; ++i) {
1816 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1817 }
1818 return *this;
1819 }
1820
1823 {
1824 UpscalePalette( rhs16, *this);
1825 }
1828 {
1829 UpscalePalette( rhs16, *this);
1830 return *this;
1831 }
1832
1835 {
1836 CRGBPalette16 p16(rhs);
1837 *this = p16;
1838 }
1841 {
1842 CRGBPalette16 p16(rhs);
1843 *this = p16;
1844 return *this;
1845 }
1846
1848 bool operator==( const CRGBPalette256 &rhs) const
1849 {
1850 const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
1851 const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
1852 if( p == q) return true;
1853 for( uint16_t i = 0; i < (sizeof( entries)); ++i) {
1854 if( *p != *q) return false;
1855 ++p;
1856 ++q;
1857 }
1858 return true;
1859 }
1861 bool operator!=( const CRGBPalette256 &rhs) const
1862 {
1863 return !( *this == rhs);
1864 }
1865
1867 inline CRGB& operator[] (uint8_t x) __attribute__((always_inline))
1868 {
1869 return entries[x];
1870 }
1872 inline const CRGB& operator[] (uint8_t x) const __attribute__((always_inline))
1873 {
1874 return entries[x];
1875 }
1876
1878 inline CRGB& operator[] (int x) __attribute__((always_inline))
1879 {
1880 return entries[(uint8_t)x];
1881 }
1883 inline const CRGB& operator[] (int x) const __attribute__((always_inline))
1884 {
1885 return entries[(uint8_t)x];
1886 }
1887
1889 operator CRGB*()
1890 {
1891 return &(entries[0]);
1892 }
1893
1896 {
1897 fill_solid( &(entries[0]), 256, c1);
1898 }
1900 CRGBPalette256( const CHSV& c1, const CHSV& c2)
1901 {
1902 fill_gradient( &(entries[0]), 256, c1, c2);
1903 }
1905 CRGBPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3)
1906 {
1907 fill_gradient( &(entries[0]), 256, c1, c2, c3);
1908 }
1910 CRGBPalette256( const CHSV& c1, const CHSV& c2, const CHSV& c3, const CHSV& c4)
1911 {
1912 fill_gradient( &(entries[0]), 256, c1, c2, c3, c4);
1913 }
1914
1917 {
1918 fill_solid( &(entries[0]), 256, c1);
1919 }
1921 CRGBPalette256( const CRGB& c1, const CRGB& c2)
1922 {
1923 fill_gradient_RGB( &(entries[0]), 256, c1, c2);
1924 }
1926 CRGBPalette256( const CRGB& c1, const CRGB& c2, const CRGB& c3)
1927 {
1928 fill_gradient_RGB( &(entries[0]), 256, c1, c2, c3);
1929 }
1931 CRGBPalette256( const CRGB& c1, const CRGB& c2, const CRGB& c3, const CRGB& c4)
1932 {
1933 fill_gradient_RGB( &(entries[0]), 256, c1, c2, c3, c4);
1934 }
1935
1938 {
1939 *this = progpal;
1940 }
1943 {
1946 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1947 CRGB rgbstart( u.r, u.g, u.b);
1948
1949 int indexstart = 0;
1950 while( indexstart < 255) {
1951 ++progent;
1952 u.dword = FL_PGM_READ_DWORD_NEAR( progent);
1953 int indexend = u.index;
1954 CRGB rgbend( u.r, u.g, u.b);
1955 fill_gradient_RGB( &(entries[0]), indexstart, rgbstart, indexend, rgbend);
1956 indexstart = indexend;
1957 rgbstart = rgbend;
1958 }
1959 return *this;
1960 }
1963 {
1966 u = *ent;
1967 CRGB rgbstart( u.r, u.g, u.b);
1968
1969 int indexstart = 0;
1970 while( indexstart < 255) {
1971 ++ent;
1972 u = *ent;
1973 int indexend = u.index;
1974 CRGB rgbend( u.r, u.g, u.b);
1975 fill_gradient_RGB( &(entries[0]), indexstart, rgbstart, indexend, rgbend);
1976 indexstart = indexend;
1977 rgbstart = rgbend;
1978 }
1979 return *this;
1980 }
1981};
1982
1984
1985
1989
1996
2007 uint8_t index,
2008 uint8_t brightness=255,
2009 TBlendType blendType=LINEARBLEND);
2010
2011
2018 const CRGBPalette16& pal,
2019 uint16_t index,
2020 uint8_t brightness,
2021 TBlendType blendType);
2022
2029 const CRGBPalette32& pal,
2030 uint16_t index,
2031 uint8_t brightness,
2032 TBlendType blendType);
2033
2036 uint8_t index,
2037 uint8_t brightness=255,
2038 TBlendType blendType=LINEARBLEND);
2039
2042 uint8_t index,
2043 uint8_t brightness=255,
2044 TBlendType blendType=NOBLEND );
2045
2046// @author https://github.com/generalelectrix
2048 uint16_t index,
2049 uint8_t brightness,
2050 TBlendType blendType);
2051
2054 uint8_t index,
2055 uint8_t brightness=255,
2056 TBlendType blendType=LINEARBLEND);
2057
2060 uint8_t index,
2061 uint8_t brightness=255,
2062 TBlendType blendType=NOBLEND );
2063
2066 uint8_t index,
2067 uint8_t brightness=255,
2068 TBlendType blendType=LINEARBLEND);
2069
2072 uint8_t index,
2073 uint8_t brightness=255,
2074 TBlendType blendType=LINEARBLEND);
2075
2078 uint8_t index,
2079 uint8_t brightness=255,
2080 TBlendType blendType=LINEARBLEND);
2081
2082
2093template <typename PALETTE>
2094void fill_palette(CRGB* L, uint16_t N, uint8_t startIndex, uint8_t incIndex,
2095 const PALETTE& pal, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
2096{
2097 uint8_t colorIndex = startIndex;
2098 for( uint16_t i = 0; i < N; ++i) {
2099 L[i] = ColorFromPalette( pal, colorIndex, brightness, blendType);
2100 colorIndex += incIndex;
2101 }
2102}
2103
2104
2116template <typename PALETTE>
2117void fill_palette_circular(CRGB* L, uint16_t N, uint8_t startIndex,
2118 const PALETTE& pal, uint8_t brightness=255, TBlendType blendType=LINEARBLEND,
2119 bool reversed=false)
2120{
2121 if (N == 0) return; // avoiding div/0
2122
2123 const uint16_t colorChange = 65535 / N; // color change for each LED, * 256 for precision
2124 uint16_t colorIndex = ((uint16_t) startIndex) << 8; // offset for color index, with precision (*256)
2125
2126 for (uint16_t i = 0; i < N; ++i) {
2127 L[i] = ColorFromPalette(pal, (colorIndex >> 8), brightness, blendType);
2128 if (reversed) colorIndex -= colorChange;
2129 else colorIndex += colorChange;
2130 }
2131}
2132
2133
2151template <typename PALETTE>
2153 uint8_t *dataArray, uint16_t dataCount,
2154 CRGB* targetColorArray,
2155 const PALETTE& pal,
2156 uint8_t brightness=255,
2157 uint8_t opacity=255,
2158 TBlendType blendType=LINEARBLEND)
2159{
2160 for( uint16_t i = 0; i < dataCount; ++i) {
2161 uint8_t d = dataArray[i];
2162 CRGB rgb = ColorFromPalette( pal, d, brightness, blendType);
2163 if( opacity == 255 ) {
2164 targetColorArray[i] = rgb;
2165 } else {
2166 targetColorArray[i].nscale8( 256 - opacity);
2167 rgb.nscale8_video( opacity);
2168 targetColorArray[i] += rgb;
2169 }
2170 }
2171}
2172
2173
2212void nblendPaletteTowardPalette( CRGBPalette16& currentPalette,
2213 CRGBPalette16& targetPalette,
2214 uint8_t maxChanges=24);
2215
2217
2218
2219
2221
2222
2254
2259uint8_t applyGamma_video( uint8_t brightness, float gamma);
2260
2265CRGB applyGamma_video( const CRGB& orig, float gamma);
2266
2273CRGB applyGamma_video( const CRGB& orig, float gammaR, float gammaG, float gammaB);
2274
2275
2279CRGB& napplyGamma_video( CRGB& rgb, float gamma);
2280
2286CRGB& napplyGamma_video( CRGB& rgb, float gammaR, float gammaG, float gammaB);
2287
2292void napplyGamma_video( CRGB* rgbarray, uint16_t count, float gamma);
2293
2300void napplyGamma_video( CRGB* rgbarray, uint16_t count, float gammaR, float gammaG, float gammaB);
2301
2303
2305
2306#pragma GCC diagnostic pop
2307
2308#endif
central include file for FastLED, defines the CFastLED class/object
HSV color palette with 16 discrete values.
Definition colorutils.h:727
CHSVPalette16(const CHSV &c1)
Create palette filled with one color.
Definition colorutils.h:839
CHSVPalette16(const CHSVPalette16 &rhs)
Copy constructor.
Definition colorutils.h:747
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:735
CHSVPalette16 & operator=(const TProgmemHSVPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition colorutils.h:771
bool operator==(const CHSVPalette16 &rhs) const
Check if two palettes have the same color entries.
Definition colorutils.h:818
bool operator!=(const CHSVPalette16 &rhs) const
Check if two palettes do not have the same color entries.
Definition colorutils.h:832
CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4)
Create palette with four-color gradient.
Definition colorutils.h:866
CHSVPalette16()
Default constructor.
Definition colorutils.h:732
CHSVPalette16(const CHSV &c1, const CHSV &c2)
Create palette with a gradient from one color to another.
Definition colorutils.h:847
CHSV entries[16]
the color entries that make up the palette
Definition colorutils.h:729
CHSVPalette16 & operator=(const CHSVPalette16 &rhs)
Copy constructor.
Definition colorutils.h:753
CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3)
Create palette with three-color gradient.
Definition colorutils.h:856
CHSVPalette16(const TProgmemHSVPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition colorutils.h:760
CHSV & operator[](uint8_t x)
Array access operator to index into the gradient entries.
Definition colorutils.h:788
HSV color palette with 256 discrete values.
Definition colorutils.h:874
CHSV & operator[](uint8_t x)
Array access operator to index into the gradient entries.
Definition colorutils.h:934
CHSVPalette256()
Default constructor.
Definition colorutils.h:879
CHSVPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4)
Create palette with four-color gradient.
Definition colorutils.h:997
CHSVPalette256 & operator=(const CHSVPalette256 &rhs)
Copy constructor.
Definition colorutils.h:901
CHSVPalette256(const CHSV &c1)
Create palette filled with one color.
Definition colorutils.h:982
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:885
CHSV entries[256]
the color entries that make up the palette
Definition colorutils.h:876
CHSVPalette256(const CHSVPalette16 &rhs16)
Create upscaled palette from 16-entry palette.
Definition colorutils.h:908
CHSVPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3)
Create palette with three-color gradient.
Definition colorutils.h:992
CHSVPalette256(const CHSVPalette256 &rhs)
Copy constructor.
Definition colorutils.h:896
CHSVPalette256 & operator=(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition colorutils.h:926
CHSVPalette256(const CHSV &c1, const CHSV &c2)
Create palette with a gradient from one color to another.
Definition colorutils.h:987
bool operator!=(const CHSVPalette256 &rhs) const
Check if two palettes do not have the same color entries.
Definition colorutils.h:976
bool operator==(const CHSVPalette256 &rhs) const
Check if two palettes have the same color entries.
Definition colorutils.h:962
CHSVPalette256 & operator=(const CHSVPalette16 &rhs16)
Create upscaled palette from 16-entry palette.
Definition colorutils.h:913
CHSVPalette256(const TProgmemRGBPalette16 &rhs)
Create palette from palette stored in PROGMEM.
Definition colorutils.h:920
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.
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
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.
uint32_t TProgmemRGBPalette32[32]
CRGBPalette32 entries stored in PROGMEM memory.
Definition colorutils.h:83
uint32_t TProgmemRGBPalette16[16]
CRGBPalette16 entries stored in PROGMEM memory.
Definition colorutils.h:79
uint32_t TProgmemHSVPalette32[32]
CHSVPalette32 entries stored in PROGMEM memory.
Definition colorutils.h:84
TProgmemRGBGradientPalette_bytes TProgmemRGBGradientPaletteRef
Alias of TProgmemRGBGradientPalette_bytes.
Definition colorutils.h:95
const TProgmemRGBGradientPalette_byte * TProgmemRGBGradientPalette_bytes
Pointer to bytes of an RGB gradient, stored in PROGMEM memory.
Definition colorutils.h:93
const uint8_t TProgmemRGBGradientPalette_byte
Byte of an RGB gradient, stored in PROGMEM memory.
Definition colorutils.h:89
uint32_t TProgmemHSVPalette16[16]
CHSVPalette16 entries stored in PROGMEM memory.
Definition colorutils.h:80
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 fl::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 fl::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 fl::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:160
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:189
#define saccum87
ANSI: signed short _Accum.
Definition colorutils.h:170
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:164
@ FORWARD_HUES
Hue always goes clockwise around the color wheel.
Definition colorutils.h:161
@ SHORTEST_HUES
Hue goes whichever way is shortest.
Definition colorutils.h:163
@ BACKWARD_HUES
Hue always goes counter-clockwise around the color wheel.
Definition colorutils.h:162
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:58
uint8_t fract8
ANSI: unsigned short _Fract.
Definition types.h:36
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:690
uint8_t TDynamicRGBGradientPalette_byte
Byte of an RGB gradient entry, stored in dynamic (heap) memory.
Definition colorutils.h:688
const TDynamicRGBGradientPalette_byte * TDynamicRGBGradientPalette_bytes
Pointer to bytes of an RGB gradient, stored in dynamic (heap) memory.
Definition colorutils.h:689
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.
CRGB ColorFromPaletteExtended(const CRGBPalette16 &pal, uint16_t index, uint8_t brightness, TBlendType blendType)
Same as ColorFromPalette, but with uint16_t index to give greater precision.
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.
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
Definition namespace.h:16
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Definition namespace.h:14
Includes defintions for RGB and HSV pixels.
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:16
uint8_t hue
Color hue.
Definition chsv.h:23
uint8_t sat
Color saturation.
Definition chsv.h:30
uint8_t value
Color value (brightness).
Definition chsv.h:36
uint8_t saturation
Color saturation.
Definition chsv.h:29
uint8_t val
Color value (brightness).
Definition chsv.h:37
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54
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:78
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:58
uint8_t red
Red channel value.
Definition crgb.h:59
uint8_t blue
Blue channel value.
Definition crgb.h:67
uint8_t green
Green channel value.
Definition crgb.h:63
Struct for digesting gradient pointer data into its components.
Definition colorutils.h:677
uint8_t g
CRGB::green channel value of the color entry.
Definition colorutils.h:681
uint32_t dword
values as a packed 32-bit double word
Definition colorutils.h:684
uint8_t b
CRGB::blue channel value of the color entry.
Definition colorutils.h:682
uint8_t index
index of the color entry in the gradient
Definition colorutils.h:679
uint8_t r
CRGB::red channel value of the color entry.
Definition colorutils.h:680