FastLED 3.9.15
Loading...
Searching...
No Matches
colorutils.h
Go to the documentation of this file.
1#pragma once
2
5
6// #include "FastLED.h"
7
8#include "fl/int.h"
9#include "crgb.h"
10#include "fastled_progmem.h"
11#include "fl/blur.h"
12#include "fl/colorutils_misc.h"
13#include "fl/deprecated.h"
14#include "fl/fill.h"
15#include "fl/xymap.h"
16#include "lib8tion/memmove.h"
17#include "fl/compiler_control.h"
18
19// #include "pixeltypes.h" // pulls in FastLED.h, beware.
20
27
28#if !defined(FASTLED_USE_32_BIT_GRADIENT_FILL)
29#if defined(__AVR__)
30#define FASTLED_USE_32_BIT_GRADIENT_FILL 0
31#else
32#define FASTLED_USE_32_BIT_GRADIENT_FILL 1
33#endif
34#endif
35
36#pragma GCC diagnostic push
37#pragma GCC diagnostic ignored "-Wcast-align"
38
39namespace fl {
40
42
46
52void fadeLightBy(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy);
53
55void fade_video(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy);
56
62void nscale8_video(CRGB *leds, fl::u16 num_leds, fl::u8 scale);
63
69void fadeToBlackBy(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy);
70
72void fade_raw(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy);
73
80void nscale8(CRGB *leds, fl::u16 num_leds, fl::u8 scale);
81
93void fadeUsingColor(CRGB *leds, fl::u16 numLeds, const CRGB &colormask);
94
96
100
106CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2);
107
110CHSV blend(const CHSV &p1, const CHSV &p2, fract8 amountOfP2,
111 TGradientDirectionCode directionCode = SHORTEST_HUES);
112
121CRGB *blend(const CRGB *src1, const CRGB *src2, CRGB *dest, fl::u16 count,
122 fract8 amountOfsrc2);
123
126CHSV *blend(const CHSV *src1, const CHSV *src2, CHSV *dest, fl::u16 count,
127 fract8 amountOfsrc2,
128 TGradientDirectionCode directionCode = SHORTEST_HUES);
129
135CRGB &nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay);
136
139CHSV &nblend(CHSV &existing, const CHSV &overlay, fract8 amountOfOverlay,
140 TGradientDirectionCode directionCode = SHORTEST_HUES);
141
148void nblend(CRGB *existing, const CRGB *overlay, fl::u16 count,
149 fract8 amountOfOverlay);
150
153void nblend(CHSV *existing, const CHSV *overlay, fl::u16 count,
154 fract8 amountOfOverlay,
155 TGradientDirectionCode directionCode = SHORTEST_HUES);
156
158
161
167CRGB HeatColor(fl::u8 temperature);
168
171
239
246
247class CRGBPalette16;
248class CRGBPalette32;
249class CRGBPalette256;
250class CHSVPalette16;
251class CHSVPalette32;
252class CHSVPalette256;
253
258typedef union {
259 struct {
260 fl::u8 index;
261 fl::u8 r;
262 fl::u8 g;
263 fl::u8 b;
264 };
265 fl::u32 dword;
266 fl::u8 bytes[4];
267} TRGBGradientPaletteEntryUnion;
268
269typedef fl::u8
270 TDynamicRGBGradientPalette_byte;
272typedef const TDynamicRGBGradientPalette_byte
273 *TDynamicRGBGradientPalette_bytes;
275typedef TDynamicRGBGradientPalette_bytes
276 TDynamicRGBGradientPaletteRef;
278
280
284
288void UpscalePalette(const class CRGBPalette16 &srcpal16,
289 class CRGBPalette256 &destpal256);
291void UpscalePalette(const class CHSVPalette16 &srcpal16,
292 class CHSVPalette256 &destpal256);
293
297void UpscalePalette(const class CRGBPalette16 &srcpal16,
298 class CRGBPalette32 &destpal32);
300void UpscalePalette(const class CHSVPalette16 &srcpal16,
301 class CHSVPalette32 &destpal32);
302
306void UpscalePalette(const class CRGBPalette32 &srcpal32,
307 class CRGBPalette256 &destpal256);
309void UpscalePalette(const class CHSVPalette32 &srcpal32,
310 class CHSVPalette256 &destpal256);
311
313
316
318class CHSVPalette16 {
319 public:
320 CHSV entries[16];
321
323 CHSVPalette16() {};
324
326 CHSVPalette16(const CHSV &c00, const CHSV &c01, const CHSV &c02,
327 const CHSV &c03, const CHSV &c04, const CHSV &c05,
328 const CHSV &c06, const CHSV &c07, const CHSV &c08,
329 const CHSV &c09, const CHSV &c10, const CHSV &c11,
330 const CHSV &c12, const CHSV &c13, const CHSV &c14,
331 const CHSV &c15) {
332 entries[0] = c00;
333 entries[1] = c01;
334 entries[2] = c02;
335 entries[3] = c03;
336 entries[4] = c04;
337 entries[5] = c05;
338 entries[6] = c06;
339 entries[7] = c07;
340 entries[8] = c08;
341 entries[9] = c09;
342 entries[10] = c10;
343 entries[11] = c11;
344 entries[12] = c12;
345 entries[13] = c13;
346 entries[14] = c14;
347 entries[15] = c15;
348 };
349
351 CHSVPalette16(const CHSVPalette16 &rhs) {
352 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
353 }
354
356 CHSVPalette16 &operator=(const CHSVPalette16 &rhs) {
357 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
358 return *this;
359 }
360
362 CHSVPalette16(const TProgmemHSVPalette16 &rhs) {
363 for (fl::u8 i = 0; i < 16; ++i) {
364 CRGB xyz(FL_PGM_READ_DWORD_NEAR(rhs + i));
365 entries[i].hue = xyz.red;
366 entries[i].sat = xyz.green;
367 entries[i].val = xyz.blue;
368 }
369 }
370
372 CHSVPalette16 &operator=(const TProgmemHSVPalette16 &rhs) {
373 for (fl::u8 i = 0; i < 16; ++i) {
374 CRGB xyz(FL_PGM_READ_DWORD_NEAR(rhs + i));
375 entries[i].hue = xyz.red;
376 entries[i].sat = xyz.green;
377 entries[i].val = xyz.blue;
378 }
379 return *this;
380 }
381
388 inline CHSV &operator[](fl::u8 x) __attribute__((always_inline)) {
389 return entries[x];
390 }
391
393 inline const CHSV &operator[](fl::u8 x) const
394 __attribute__((always_inline)) {
395 return entries[x];
396 }
397
399 inline CHSV &operator[](int x) __attribute__((always_inline)) {
400 return entries[(fl::u8)x];
401 }
402
404 inline const CHSV &operator[](int x) const __attribute__((always_inline)) {
405 return entries[(fl::u8)x];
406 }
407
409 operator CHSV *() { return &(entries[0]); }
410
412 bool operator==(const CHSVPalette16 &rhs) const {
413 const fl::u8 *p = (const fl::u8 *)(&(this->entries[0]));
414 const fl::u8 *q = (const fl::u8 *)(&(rhs.entries[0]));
415 if (p == q)
416 return true;
417 for (fl::u8 i = 0; i < (sizeof(entries)); ++i) {
418 if (*p != *q)
419 return false;
420 ++p;
421 ++q;
422 }
423 return true;
424 }
425
427 bool operator!=(const CHSVPalette16 &rhs) const { return !(*this == rhs); }
428
431 CHSVPalette16(const CHSV &c1) { fill_solid(&(entries[0]), 16, c1); }
432
436 CHSVPalette16(const CHSV &c1, const CHSV &c2) {
437 fill_gradient(&(entries[0]), 16, c1, c2);
438 }
439
444 CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
445 fill_gradient(&(entries[0]), 16, c1, c2, c3);
446 }
447
453 CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3,
454 const CHSV &c4) {
455 fill_gradient(&(entries[0]), 16, c1, c2, c3, c4);
456 }
457};
458
460class CHSVPalette256 {
461 public:
462 CHSV entries[256];
463
465 CHSVPalette256() {};
466
471 CHSVPalette256(const CHSV &c00, const CHSV &c01, const CHSV &c02,
472 const CHSV &c03, const CHSV &c04, const CHSV &c05,
473 const CHSV &c06, const CHSV &c07, const CHSV &c08,
474 const CHSV &c09, const CHSV &c10, const CHSV &c11,
475 const CHSV &c12, const CHSV &c13, const CHSV &c14,
476 const CHSV &c15) {
477 CHSVPalette16 p16(c00, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10,
478 c11, c12, c13, c14, c15);
479 *this = p16;
480 };
481
483 CHSVPalette256(const CHSVPalette256 &rhs) {
484 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
485 }
487 CHSVPalette256 &operator=(const CHSVPalette256 &rhs) {
488 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
489 return *this;
490 }
491
493 CHSVPalette256(const CHSVPalette16 &rhs16) { UpscalePalette(rhs16, *this); }
495 CHSVPalette256 &operator=(const CHSVPalette16 &rhs16) {
496 UpscalePalette(rhs16, *this);
497 return *this;
498 }
499
501 CHSVPalette256(const TProgmemRGBPalette16 &rhs) {
502 CHSVPalette16 p16(rhs);
503 *this = p16;
504 }
506 CHSVPalette256 &operator=(const TProgmemRGBPalette16 &rhs) {
507 CHSVPalette16 p16(rhs);
508 *this = p16;
509 return *this;
510 }
511
513 inline CHSV &operator[](fl::u8 x) __attribute__((always_inline)) {
514 return entries[x];
515 }
517 inline const CHSV &operator[](fl::u8 x) const
518 __attribute__((always_inline)) {
519 return entries[x];
520 }
521
523 inline CHSV &operator[](int x) __attribute__((always_inline)) {
524 return entries[(fl::u8)x];
525 }
527 inline const CHSV &operator[](int x) const __attribute__((always_inline)) {
528 return entries[(fl::u8)x];
529 }
530
532 operator CHSV *() { return &(entries[0]); }
533
535 bool operator==(const CHSVPalette256 &rhs) const {
536 const fl::u8 *p = (const fl::u8 *)(&(this->entries[0]));
537 const fl::u8 *q = (const fl::u8 *)(&(rhs.entries[0]));
538 if (p == q)
539 return true;
540 for (fl::u16 i = 0; i < (sizeof(entries)); ++i) {
541 if (*p != *q)
542 return false;
543 ++p;
544 ++q;
545 }
546 return true;
547 }
548
550 bool operator!=(const CHSVPalette256 &rhs) const { return !(*this == rhs); }
551
553 CHSVPalette256(const CHSV &c1) { fill_solid(&(entries[0]), 256, c1); }
555 CHSVPalette256(const CHSV &c1, const CHSV &c2) {
556 fill_gradient(&(entries[0]), 256, c1, c2);
557 }
560 CHSVPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
561 fill_gradient(&(entries[0]), 256, c1, c2, c3);
562 }
565 CHSVPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3,
566 const CHSV &c4) {
567 fill_gradient(&(entries[0]), 256, c1, c2, c3, c4);
568 }
569};
570
572class CRGBPalette16 {
573 public:
574 CRGB entries[16];
575
577 CRGBPalette16() {};
578
580 CRGBPalette16(const CRGB &c00, const CRGB &c01, const CRGB &c02,
581 const CRGB &c03, const CRGB &c04, const CRGB &c05,
582 const CRGB &c06, const CRGB &c07, const CRGB &c08,
583 const CRGB &c09, const CRGB &c10, const CRGB &c11,
584 const CRGB &c12, const CRGB &c13, const CRGB &c14,
585 const CRGB &c15) {
586 entries[0] = c00;
587 entries[1] = c01;
588 entries[2] = c02;
589 entries[3] = c03;
590 entries[4] = c04;
591 entries[5] = c05;
592 entries[6] = c06;
593 entries[7] = c07;
594 entries[8] = c08;
595 entries[9] = c09;
596 entries[10] = c10;
597 entries[11] = c11;
598 entries[12] = c12;
599 entries[13] = c13;
600 entries[14] = c14;
601 entries[15] = c15;
602 };
603
605 CRGBPalette16(const CRGBPalette16 &rhs) {
606 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
607 }
609 CRGBPalette16(const CRGB rhs[16]) {
610 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
611 }
613 CRGBPalette16 &operator=(const CRGBPalette16 &rhs) {
614 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
615 return *this;
616 }
618 CRGBPalette16 &operator=(const CRGB rhs[16]) {
619 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
620 return *this;
621 }
622
624 CRGBPalette16(const CHSVPalette16 &rhs) {
625 for (fl::u8 i = 0; i < 16; ++i) {
626 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
627 }
628 }
630 CRGBPalette16(const CHSV rhs[16]) {
631 for (fl::u8 i = 0; i < 16; ++i) {
632 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
633 }
634 }
636 CRGBPalette16 &operator=(const CHSVPalette16 &rhs) {
637 for (fl::u8 i = 0; i < 16; ++i) {
638 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
639 }
640 return *this;
641 }
643 CRGBPalette16 &operator=(const CHSV rhs[16]) {
644 for (fl::u8 i = 0; i < 16; ++i) {
645 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
646 }
647 return *this;
648 }
649
651 CRGBPalette16(const TProgmemRGBPalette16 &rhs) {
652 for (fl::u8 i = 0; i < 16; ++i) {
653 entries[i] = FL_PGM_READ_DWORD_NEAR(rhs + i);
654 }
655 }
657 CRGBPalette16 &operator=(const TProgmemRGBPalette16 &rhs) {
658 for (fl::u8 i = 0; i < 16; ++i) {
659 entries[i] = FL_PGM_READ_DWORD_NEAR(rhs + i);
660 }
661 return *this;
662 }
663
665 bool operator==(const CRGBPalette16 &rhs) const {
666 const fl::u8 *p = (const fl::u8 *)(&(this->entries[0]));
667 const fl::u8 *q = (const fl::u8 *)(&(rhs.entries[0]));
668 if (p == q)
669 return true;
670 for (fl::u8 i = 0; i < (sizeof(entries)); ++i) {
671 if (*p != *q)
672 return false;
673 ++p;
674 ++q;
675 }
676 return true;
677 }
679 bool operator!=(const CRGBPalette16 &rhs) const { return !(*this == rhs); }
681 inline CRGB &operator[](fl::u8 x) __attribute__((always_inline)) {
682 return entries[x];
683 }
685 inline const CRGB &operator[](fl::u8 x) const
686 __attribute__((always_inline)) {
687 return entries[x];
688 }
689
691 inline CRGB &operator[](int x) __attribute__((always_inline)) {
692 return entries[(fl::u8)x];
693 }
695 inline const CRGB &operator[](int x) const __attribute__((always_inline)) {
696 return entries[(fl::u8)x];
697 }
698
700 operator CRGB *() { return &(entries[0]); }
701
703 CRGBPalette16(const CHSV &c1) { fill_solid(&(entries[0]), 16, c1); }
705 CRGBPalette16(const CHSV &c1, const CHSV &c2) {
706 fill_gradient(&(entries[0]), 16, c1, c2);
707 }
710 CRGBPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
711 fill_gradient(&(entries[0]), 16, c1, c2, c3);
712 }
715 CRGBPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3,
716 const CHSV &c4) {
717 fill_gradient(&(entries[0]), 16, c1, c2, c3, c4);
718 }
719
721 CRGBPalette16(const CRGB &c1) { fill_solid(&(entries[0]), 16, c1); }
723 CRGBPalette16(const CRGB &c1, const CRGB &c2) {
724 fill_gradient_RGB(&(entries[0]), 16, c1, c2);
725 }
728 CRGBPalette16(const CRGB &c1, const CRGB &c2, const CRGB &c3) {
729 fill_gradient_RGB(&(entries[0]), 16, c1, c2, c3);
730 }
733 CRGBPalette16(const CRGB &c1, const CRGB &c2, const CRGB &c3,
734 const CRGB &c4) {
735 fill_gradient_RGB(&(entries[0]), 16, c1, c2, c3, c4);
736 }
737
767 CRGBPalette16(TProgmemRGBGradientPalette_bytes progpal) { *this = progpal; }
769 CRGBPalette16 &operator=(TProgmemRGBGradientPalette_bytes progpal) {
770 TRGBGradientPaletteEntryUnion *progent =
771 // (TRGBGradientPaletteEntryUnion *)(progpal);
773 TRGBGradientPaletteEntryUnion u;
774
775 // Count entries
776 fl::u16 count = 0;
777 do {
778 u.dword = FL_PGM_READ_DWORD_NEAR(progent + count);
779 ++count;
780 } while (u.index != 255);
781
782 fl::i8 lastSlotUsed = -1;
783
784 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
785 CRGB rgbstart(u.r, u.g, u.b);
786
787 int indexstart = 0;
788 fl::u8 istart8 = 0;
789 fl::u8 iend8 = 0;
790 while (indexstart < 255) {
791 ++progent;
792 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
793 int indexend = u.index;
794 CRGB rgbend(u.r, u.g, u.b);
795 istart8 = indexstart / 16;
796 iend8 = indexend / 16;
797 if (count < 16) {
798 if ((istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) {
799 istart8 = lastSlotUsed + 1;
800 if (iend8 < istart8) {
801 iend8 = istart8;
802 }
803 }
804 lastSlotUsed = iend8;
805 }
806 fill_gradient_RGB(&(entries[0]), istart8, rgbstart, iend8, rgbend);
807 indexstart = indexend;
808 rgbstart = rgbend;
809 }
810 return *this;
811 }
815 CRGBPalette16 &
816 loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal) {
817 TRGBGradientPaletteEntryUnion *ent =
818 // (TRGBGradientPaletteEntryUnion *)(gpal);
820 TRGBGradientPaletteEntryUnion u;
821
822 // Count entries
823 fl::u16 count = 0;
824 do {
825 u = *(ent + count);
826 ++count;
827 } while (u.index != 255);
828
829 fl::i8 lastSlotUsed = -1;
830
831 u = *ent;
832 CRGB rgbstart(u.r, u.g, u.b);
833
834 int indexstart = 0;
835 fl::u8 istart8 = 0;
836 fl::u8 iend8 = 0;
837 while (indexstart < 255) {
838 ++ent;
839 u = *ent;
840 int indexend = u.index;
841 CRGB rgbend(u.r, u.g, u.b);
842 istart8 = indexstart / 16;
843 iend8 = indexend / 16;
844 if (count < 16) {
845 if ((istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) {
846 istart8 = lastSlotUsed + 1;
847 if (iend8 < istart8) {
848 iend8 = istart8;
849 }
850 }
851 lastSlotUsed = iend8;
852 }
853 fill_gradient_RGB(&(entries[0]), istart8, rgbstart, iend8, rgbend);
854 indexstart = indexend;
855 rgbstart = rgbend;
856 }
857 return *this;
858 }
859};
860
862class CHSVPalette32 {
863 public:
864 CHSV entries[32];
865
867 CHSVPalette32() {};
868
873 CHSVPalette32(const CHSV &c00, const CHSV &c01, const CHSV &c02,
874 const CHSV &c03, const CHSV &c04, const CHSV &c05,
875 const CHSV &c06, const CHSV &c07, const CHSV &c08,
876 const CHSV &c09, const CHSV &c10, const CHSV &c11,
877 const CHSV &c12, const CHSV &c13, const CHSV &c14,
878 const CHSV &c15) {
879 for (fl::u8 i = 0; i < 2; ++i) {
880 entries[0 + i] = c00;
881 entries[2 + i] = c01;
882 entries[4 + i] = c02;
883 entries[6 + i] = c03;
884 entries[8 + i] = c04;
885 entries[10 + i] = c05;
886 entries[12 + i] = c06;
887 entries[14 + i] = c07;
888 entries[16 + i] = c08;
889 entries[18 + i] = c09;
890 entries[20 + i] = c10;
891 entries[22 + i] = c11;
892 entries[24 + i] = c12;
893 entries[26 + i] = c13;
894 entries[28 + i] = c14;
895 entries[30 + i] = c15;
896 }
897 };
898
900 CHSVPalette32(const CHSVPalette32 &rhs) {
901 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
902 }
904 CHSVPalette32 &operator=(const CHSVPalette32 &rhs) {
905 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
906 return *this;
907 }
908
910 CHSVPalette32(const TProgmemHSVPalette32 &rhs) {
911 for (fl::u8 i = 0; i < 32; ++i) {
912 CRGB xyz(FL_PGM_READ_DWORD_NEAR(rhs + i));
913 entries[i].hue = xyz.red;
914 entries[i].sat = xyz.green;
915 entries[i].val = xyz.blue;
916 }
917 }
919 CHSVPalette32 &operator=(const TProgmemHSVPalette32 &rhs) {
920 for (fl::u8 i = 0; i < 32; ++i) {
921 CRGB xyz(FL_PGM_READ_DWORD_NEAR(rhs + i));
922 entries[i].hue = xyz.red;
923 entries[i].sat = xyz.green;
924 entries[i].val = xyz.blue;
925 }
926 return *this;
927 }
928
930 inline CHSV &operator[](fl::u8 x) __attribute__((always_inline)) {
931 return entries[x];
932 }
934 inline const CHSV &operator[](fl::u8 x) const
935 __attribute__((always_inline)) {
936 return entries[x];
937 }
938
940 inline CHSV &operator[](int x) __attribute__((always_inline)) {
941 return entries[(fl::u8)x];
942 }
944 inline const CHSV &operator[](int x) const __attribute__((always_inline)) {
945 return entries[(fl::u8)x];
946 }
947
949 operator CHSV *() { return &(entries[0]); }
950
952 bool operator==(const CHSVPalette32 &rhs) const {
953 const fl::u8 *p = (const fl::u8 *)(&(this->entries[0]));
954 const fl::u8 *q = (const fl::u8 *)(&(rhs.entries[0]));
955 if (p == q)
956 return true;
957 for (fl::u8 i = 0; i < (sizeof(entries)); ++i) {
958 if (*p != *q)
959 return false;
960 ++p;
961 ++q;
962 }
963 return true;
964 }
966 bool operator!=(const CHSVPalette32 &rhs) const { return !(*this == rhs); }
967
969 CHSVPalette32(const CHSV &c1) { fill_solid(&(entries[0]), 32, c1); }
971 CHSVPalette32(const CHSV &c1, const CHSV &c2) {
972 fill_gradient(&(entries[0]), 32, c1, c2);
973 }
976 CHSVPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
977 fill_gradient(&(entries[0]), 32, c1, c2, c3);
978 }
981 CHSVPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3,
982 const CHSV &c4) {
983 fill_gradient(&(entries[0]), 32, c1, c2, c3, c4);
984 }
985};
986
988class CRGBPalette32 {
989 public:
990 CRGB entries[32];
991
993 CRGBPalette32() {};
994
1000 CRGBPalette32(const CRGB &c00, const CRGB &c01, const CRGB &c02,
1001 const CRGB &c03, const CRGB &c04, const CRGB &c05,
1002 const CRGB &c06, const CRGB &c07, const CRGB &c08,
1003 const CRGB &c09, const CRGB &c10, const CRGB &c11,
1004 const CRGB &c12, const CRGB &c13, const CRGB &c14,
1005 const CRGB &c15) {
1006 for (fl::u8 i = 0; i < 2; ++i) {
1007 entries[0 + i] = c00;
1008 entries[2 + i] = c01;
1009 entries[4 + i] = c02;
1010 entries[6 + i] = c03;
1011 entries[8 + i] = c04;
1012 entries[10 + i] = c05;
1013 entries[12 + i] = c06;
1014 entries[14 + i] = c07;
1015 entries[16 + i] = c08;
1016 entries[18 + i] = c09;
1017 entries[20 + i] = c10;
1018 entries[22 + i] = c11;
1019 entries[24 + i] = c12;
1020 entries[26 + i] = c13;
1021 entries[28 + i] = c14;
1022 entries[30 + i] = c15;
1023 }
1024 };
1025
1027 CRGBPalette32(const CRGBPalette32 &rhs) {
1028 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
1029 }
1031 CRGBPalette32(const CRGB rhs[32]) {
1032 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
1033 }
1035 CRGBPalette32 &operator=(const CRGBPalette32 &rhs) {
1036 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
1037 return *this;
1038 }
1040 CRGBPalette32 &operator=(const CRGB rhs[32]) {
1041 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
1042 return *this;
1043 }
1044
1046 CRGBPalette32(const CHSVPalette32 &rhs) {
1047 for (fl::u8 i = 0; i < 32; ++i) {
1048 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1049 }
1050 }
1052 CRGBPalette32(const CHSV rhs[32]) {
1053 for (fl::u8 i = 0; i < 32; ++i) {
1054 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1055 }
1056 }
1058 CRGBPalette32 &operator=(const CHSVPalette32 &rhs) {
1059 for (fl::u8 i = 0; i < 32; ++i) {
1060 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1061 }
1062 return *this;
1063 }
1065 CRGBPalette32 &operator=(const CHSV rhs[32]) {
1066 for (fl::u8 i = 0; i < 32; ++i) {
1067 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1068 }
1069 return *this;
1070 }
1071
1073 CRGBPalette32(const TProgmemRGBPalette32 &rhs) {
1074 for (fl::u8 i = 0; i < 32; ++i) {
1075 entries[i] = FL_PGM_READ_DWORD_NEAR(rhs + i);
1076 }
1077 }
1079 CRGBPalette32 &operator=(const TProgmemRGBPalette32 &rhs) {
1080 for (fl::u8 i = 0; i < 32; ++i) {
1081 entries[i] = FL_PGM_READ_DWORD_NEAR(rhs + i);
1082 }
1083 return *this;
1084 }
1085
1087 bool operator==(const CRGBPalette32 &rhs) const {
1088 const fl::u8 *p = (const fl::u8 *)(&(this->entries[0]));
1089 const fl::u8 *q = (const fl::u8 *)(&(rhs.entries[0]));
1090 if (p == q)
1091 return true;
1092 for (fl::u8 i = 0; i < (sizeof(entries)); ++i) {
1093 if (*p != *q)
1094 return false;
1095 ++p;
1096 ++q;
1097 }
1098 return true;
1099 }
1101 bool operator!=(const CRGBPalette32 &rhs) const { return !(*this == rhs); }
1102
1104 inline CRGB &operator[](fl::u8 x) __attribute__((always_inline)) {
1105 return entries[x];
1106 }
1108 inline const CRGB &operator[](fl::u8 x) const
1109 __attribute__((always_inline)) {
1110 return entries[x];
1111 }
1112
1114 inline CRGB &operator[](int x) __attribute__((always_inline)) {
1115 return entries[(fl::u8)x];
1116 }
1118 inline const CRGB &operator[](int x) const __attribute__((always_inline)) {
1119 return entries[(fl::u8)x];
1120 }
1121
1123 operator CRGB *() { return &(entries[0]); }
1124
1126 CRGBPalette32(const CHSV &c1) { fill_solid(&(entries[0]), 32, c1); }
1128 CRGBPalette32(const CHSV &c1, const CHSV &c2) {
1129 fill_gradient(&(entries[0]), 32, c1, c2);
1130 }
1133 CRGBPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
1134 fill_gradient(&(entries[0]), 32, c1, c2, c3);
1135 }
1138 CRGBPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3,
1139 const CHSV &c4) {
1140 fill_gradient(&(entries[0]), 32, c1, c2, c3, c4);
1141 }
1142
1144 CRGBPalette32(const CRGB &c1) { fill_solid(&(entries[0]), 32, c1); }
1146 CRGBPalette32(const CRGB &c1, const CRGB &c2) {
1147 fill_gradient_RGB(&(entries[0]), 32, c1, c2);
1148 }
1151 CRGBPalette32(const CRGB &c1, const CRGB &c2, const CRGB &c3) {
1152 fill_gradient_RGB(&(entries[0]), 32, c1, c2, c3);
1153 }
1156 CRGBPalette32(const CRGB &c1, const CRGB &c2, const CRGB &c3,
1157 const CRGB &c4) {
1158 fill_gradient_RGB(&(entries[0]), 32, c1, c2, c3, c4);
1159 }
1160
1162 CRGBPalette32(const CRGBPalette16 &rhs16) { UpscalePalette(rhs16, *this); }
1164 CRGBPalette32 &operator=(const CRGBPalette16 &rhs16) {
1165 UpscalePalette(rhs16, *this);
1166 return *this;
1167 }
1168
1170 CRGBPalette32(const TProgmemRGBPalette16 &rhs) {
1171 CRGBPalette16 p16(rhs);
1172 *this = p16;
1173 }
1175 CRGBPalette32 &operator=(const TProgmemRGBPalette16 &rhs) {
1176 CRGBPalette16 p16(rhs);
1177 *this = p16;
1178 return *this;
1179 }
1180
1182 CRGBPalette32(TProgmemRGBGradientPalette_bytes progpal) { *this = progpal; }
1184 CRGBPalette32 &operator=(TProgmemRGBGradientPalette_bytes progpal) {
1185 TRGBGradientPaletteEntryUnion *progent =
1186 //(TRGBGradientPaletteEntryUnion *)(progpal);
1188 TRGBGradientPaletteEntryUnion u;
1189
1190 // Count entries
1191 fl::u16 count = 0;
1192 do {
1193 u.dword = FL_PGM_READ_DWORD_NEAR(progent + count);
1194 ++count;
1195 } while (u.index != 255);
1196
1197 fl::i8 lastSlotUsed = -1;
1198
1199 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
1200 CRGB rgbstart(u.r, u.g, u.b);
1201
1202 int indexstart = 0;
1203 fl::u8 istart8 = 0;
1204 fl::u8 iend8 = 0;
1205 while (indexstart < 255) {
1206 ++progent;
1207 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
1208 int indexend = u.index;
1209 CRGB rgbend(u.r, u.g, u.b);
1210 istart8 = indexstart / 8;
1211 iend8 = indexend / 8;
1212 if (count < 16) {
1213 if ((istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) {
1214 istart8 = lastSlotUsed + 1;
1215 if (iend8 < istart8) {
1216 iend8 = istart8;
1217 }
1218 }
1219 lastSlotUsed = iend8;
1220 }
1221 fill_gradient_RGB(&(entries[0]), istart8, rgbstart, iend8, rgbend);
1222 indexstart = indexend;
1223 rgbstart = rgbend;
1224 }
1225 return *this;
1226 }
1229 CRGBPalette32 &
1230 loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal) {
1231 TRGBGradientPaletteEntryUnion *ent =
1232 // (TRGBGradientPaletteEntryUnion *)(gpal);
1234 TRGBGradientPaletteEntryUnion u;
1235
1236 // Count entries
1237 fl::u16 count = 0;
1238 do {
1239 u = *(ent + count);
1240 ++count;
1241 } while (u.index != 255);
1242
1243 fl::i8 lastSlotUsed = -1;
1244
1245 u = *ent;
1246 CRGB rgbstart(u.r, u.g, u.b);
1247
1248 int indexstart = 0;
1249 fl::u8 istart8 = 0;
1250 fl::u8 iend8 = 0;
1251 while (indexstart < 255) {
1252 ++ent;
1253 u = *ent;
1254 int indexend = u.index;
1255 CRGB rgbend(u.r, u.g, u.b);
1256 istart8 = indexstart / 8;
1257 iend8 = indexend / 8;
1258 if (count < 16) {
1259 if ((istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) {
1260 istart8 = lastSlotUsed + 1;
1261 if (iend8 < istart8) {
1262 iend8 = istart8;
1263 }
1264 }
1265 lastSlotUsed = iend8;
1266 }
1267 fill_gradient_RGB(&(entries[0]), istart8, rgbstart, iend8, rgbend);
1268 indexstart = indexend;
1269 rgbstart = rgbend;
1270 }
1271 return *this;
1272 }
1273};
1274
1276class CRGBPalette256 {
1277 public:
1278 CRGB entries[256];
1279
1281 CRGBPalette256() {};
1282
1288 CRGBPalette256(const CRGB &c00, const CRGB &c01, const CRGB &c02,
1289 const CRGB &c03, const CRGB &c04, const CRGB &c05,
1290 const CRGB &c06, const CRGB &c07, const CRGB &c08,
1291 const CRGB &c09, const CRGB &c10, const CRGB &c11,
1292 const CRGB &c12, const CRGB &c13, const CRGB &c14,
1293 const CRGB &c15) {
1294 CRGBPalette16 p16(c00, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10,
1295 c11, c12, c13, c14, c15);
1296 *this = p16;
1297 };
1298
1300 CRGBPalette256(const CRGBPalette256 &rhs) {
1301 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
1302 }
1304 CRGBPalette256(const CRGB rhs[256]) {
1305 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
1306 }
1308 CRGBPalette256 &operator=(const CRGBPalette256 &rhs) {
1309 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
1310 return *this;
1311 }
1313 CRGBPalette256 &operator=(const CRGB rhs[256]) {
1314 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
1315 return *this;
1316 }
1317
1319 CRGBPalette256(const CHSVPalette256 &rhs) {
1320 for (int i = 0; i < 256; ++i) {
1321 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1322 }
1323 }
1325 CRGBPalette256(const CHSV rhs[256]) {
1326 for (int i = 0; i < 256; ++i) {
1327 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1328 }
1329 }
1331 CRGBPalette256 &operator=(const CHSVPalette256 &rhs) {
1332 for (int i = 0; i < 256; ++i) {
1333 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1334 }
1335 return *this;
1336 }
1338 CRGBPalette256 &operator=(const CHSV rhs[256]) {
1339 for (int i = 0; i < 256; ++i) {
1340 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1341 }
1342 return *this;
1343 }
1344
1346 CRGBPalette256(const CRGBPalette16 &rhs16) { UpscalePalette(rhs16, *this); }
1348 CRGBPalette256 &operator=(const CRGBPalette16 &rhs16) {
1349 UpscalePalette(rhs16, *this);
1350 return *this;
1351 }
1352
1354 CRGBPalette256(const TProgmemRGBPalette16 &rhs) {
1355 CRGBPalette16 p16(rhs);
1356 *this = p16;
1357 }
1359 CRGBPalette256 &operator=(const TProgmemRGBPalette16 &rhs) {
1360 CRGBPalette16 p16(rhs);
1361 *this = p16;
1362 return *this;
1363 }
1364
1366 bool operator==(const CRGBPalette256 &rhs) const {
1367 const fl::u8 *p = (const fl::u8 *)(&(this->entries[0]));
1368 const fl::u8 *q = (const fl::u8 *)(&(rhs.entries[0]));
1369 if (p == q)
1370 return true;
1371 for (fl::u16 i = 0; i < (sizeof(entries)); ++i) {
1372 if (*p != *q)
1373 return false;
1374 ++p;
1375 ++q;
1376 }
1377 return true;
1378 }
1380 bool operator!=(const CRGBPalette256 &rhs) const { return !(*this == rhs); }
1381
1383 inline CRGB &operator[](fl::u8 x) __attribute__((always_inline)) {
1384 return entries[x];
1385 }
1387 inline const CRGB &operator[](fl::u8 x) const
1388 __attribute__((always_inline)) {
1389 return entries[x];
1390 }
1391
1393 inline CRGB &operator[](int x) __attribute__((always_inline)) {
1394 return entries[(fl::u8)x];
1395 }
1397 inline const CRGB &operator[](int x) const __attribute__((always_inline)) {
1398 return entries[(fl::u8)x];
1399 }
1400
1402 operator CRGB *() { return &(entries[0]); }
1403
1405 CRGBPalette256(const CHSV &c1) { fill_solid(&(entries[0]), 256, c1); }
1407 CRGBPalette256(const CHSV &c1, const CHSV &c2) {
1408 fill_gradient(&(entries[0]), 256, c1, c2);
1409 }
1412 CRGBPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
1413 fill_gradient(&(entries[0]), 256, c1, c2, c3);
1414 }
1417 CRGBPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3,
1418 const CHSV &c4) {
1419 fill_gradient(&(entries[0]), 256, c1, c2, c3, c4);
1420 }
1421
1423 CRGBPalette256(const CRGB &c1) { fill_solid(&(entries[0]), 256, c1); }
1425 CRGBPalette256(const CRGB &c1, const CRGB &c2) {
1426 fill_gradient_RGB(&(entries[0]), 256, c1, c2);
1427 }
1430 CRGBPalette256(const CRGB &c1, const CRGB &c2, const CRGB &c3) {
1431 fill_gradient_RGB(&(entries[0]), 256, c1, c2, c3);
1432 }
1435 CRGBPalette256(const CRGB &c1, const CRGB &c2, const CRGB &c3,
1436 const CRGB &c4) {
1437 fill_gradient_RGB(&(entries[0]), 256, c1, c2, c3, c4);
1438 }
1439
1441 CRGBPalette256(TProgmemRGBGradientPalette_bytes progpal) {
1442 *this = progpal;
1443 }
1445 CRGBPalette256 &operator=(TProgmemRGBGradientPalette_bytes progpal) {
1446 TRGBGradientPaletteEntryUnion *progent =
1447 // (TRGBGradientPaletteEntryUnion *)(progpal);
1449 TRGBGradientPaletteEntryUnion u;
1450 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
1451 CRGB rgbstart(u.r, u.g, u.b);
1452
1453 int indexstart = 0;
1454 while (indexstart < 255) {
1455 ++progent;
1456 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
1457 int indexend = u.index;
1458 CRGB rgbend(u.r, u.g, u.b);
1459 fill_gradient_RGB(&(entries[0]), indexstart, rgbstart, indexend,
1460 rgbend);
1461 indexstart = indexend;
1462 rgbstart = rgbend;
1463 }
1464 return *this;
1465 }
1468 CRGBPalette256 &
1469 loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal) {
1470 TRGBGradientPaletteEntryUnion *ent =
1471 //(TRGBGradientPaletteEntryUnion *)(gpal);
1473 TRGBGradientPaletteEntryUnion u;
1474 u = *ent;
1475 CRGB rgbstart(u.r, u.g, u.b);
1476
1477 int indexstart = 0;
1478 while (indexstart < 255) {
1479 ++ent;
1480 u = *ent;
1481 int indexend = u.index;
1482 CRGB rgbend(u.r, u.g, u.b);
1483 fill_gradient_RGB(&(entries[0]), indexstart, rgbstart, indexend,
1484 rgbend);
1485 indexstart = indexend;
1486 rgbstart = rgbend;
1487 }
1488 return *this;
1489 }
1490};
1491
1493
1497
1499typedef enum {
1500 NOBLEND = 0,
1501 BLEND = 1,
1502 LINEARBLEND = 1,
1504 LINEARBLEND_NOWRAP =
1505 2
1506} TBlendType;
1507
1518CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index,
1519 fl::u8 brightness = 255,
1520 TBlendType blendType = LINEARBLEND);
1521
1528CRGB ColorFromPaletteExtended(const CRGBPalette16 &pal, fl::u16 index,
1529 fl::u8 brightness, TBlendType blendType);
1530
1536CRGB ColorFromPaletteExtended(const CRGBPalette32 &pal, fl::u16 index,
1537 fl::u8 brightness, TBlendType blendType);
1538
1542 fl::u8 brightness = 255,
1543 TBlendType blendType = LINEARBLEND);
1544
1547CRGB ColorFromPalette(const CRGBPalette256 &pal, fl::u8 index,
1548 fl::u8 brightness = 255, TBlendType blendType = NOBLEND);
1549
1550// @author https://github.com/generalelectrix
1551CRGB ColorFromPaletteExtended(const CRGBPalette256 &pal, fl::u16 index,
1552 fl::u8 brightness = 255,
1553 TBlendType blendType = LINEARBLEND);
1554
1557CHSV ColorFromPalette(const CHSVPalette16 &pal, fl::u8 index,
1558 fl::u8 brightness = 255,
1559 TBlendType blendType = LINEARBLEND);
1560
1563CHSV ColorFromPalette(const CHSVPalette256 &pal, fl::u8 index,
1564 fl::u8 brightness = 255, TBlendType blendType = NOBLEND);
1565
1568CRGB ColorFromPalette(const CRGBPalette32 &pal, fl::u8 index,
1569 fl::u8 brightness = 255,
1570 TBlendType blendType = LINEARBLEND);
1571
1575 fl::u8 brightness = 255,
1576 TBlendType blendType = LINEARBLEND);
1577
1580CHSV ColorFromPalette(const CHSVPalette32 &pal, fl::u8 index,
1581 fl::u8 brightness = 255,
1582 TBlendType blendType = LINEARBLEND);
1583
1594template <typename PALETTE>
1595void fill_palette(CRGB *L, fl::u16 N, fl::u8 startIndex, fl::u8 incIndex,
1596 const PALETTE &pal, fl::u8 brightness = 255,
1597 TBlendType blendType = LINEARBLEND) {
1598 fl::u8 colorIndex = startIndex;
1599 for (fl::u16 i = 0; i < N; ++i) {
1600 L[i] = ColorFromPalette(pal, colorIndex, brightness, blendType);
1601 colorIndex += incIndex;
1602 }
1603}
1604
1616template <typename PALETTE>
1617void fill_palette_circular(CRGB *L, fl::u16 N, fl::u8 startIndex,
1618 const PALETTE &pal, fl::u8 brightness = 255,
1619 TBlendType blendType = LINEARBLEND,
1620 bool reversed = false) {
1621 if (N == 0)
1622 return; // avoiding div/0
1623
1624 const fl::u16 colorChange =
1625 65535 / N; // color change for each LED, * 256 for precision
1626 fl::u16 colorIndex = ((fl::u16)startIndex)
1627 << 8; // offset for color index, with precision (*256)
1628
1629 for (fl::u16 i = 0; i < N; ++i) {
1630 L[i] = ColorFromPalette(pal, (colorIndex >> 8), brightness, blendType);
1631 if (reversed)
1632 colorIndex -= colorChange;
1633 else
1634 colorIndex += colorChange;
1635 }
1636}
1637
1657template <typename PALETTE>
1658void map_data_into_colors_through_palette(
1659 fl::u8 *dataArray, fl::u16 dataCount, CRGB *targetColorArray,
1660 const PALETTE &pal, fl::u8 brightness = 255, fl::u8 opacity = 255,
1661 TBlendType blendType = LINEARBLEND) {
1662 for (fl::u16 i = 0; i < dataCount; ++i) {
1663 fl::u8 d = dataArray[i];
1664 CRGB rgb = ColorFromPalette(pal, d, brightness, blendType);
1665 if (opacity == 255) {
1666 targetColorArray[i] = rgb;
1667 } else {
1668 targetColorArray[i].nscale8(256 - opacity);
1669 rgb.nscale8_video(opacity);
1670 targetColorArray[i] += rgb;
1671 }
1672 }
1673}
1674
1713void nblendPaletteTowardPalette(CRGBPalette16 &currentPalette,
1714 CRGBPalette16 &targetPalette,
1715 fl::u8 maxChanges = 24);
1716
1718
1720
1752
1758
1763CRGB applyGamma_video(const CRGB &orig, float gamma);
1764
1771CRGB applyGamma_video(const CRGB &orig, float gammaR, float gammaG,
1772 float gammaB);
1773
1777CRGB &napplyGamma_video(CRGB &rgb, float gamma);
1778
1784CRGB &napplyGamma_video(CRGB &rgb, float gammaR, float gammaG, float gammaB);
1785
1791void napplyGamma_video(CRGB *rgbarray, fl::u16 count, float gamma);
1792
1800void napplyGamma_video(CRGB *rgbarray, fl::u16 count, float gammaR,
1801 float gammaG, float gammaB);
1802
1804
1805} // namespace fl
1806
CRGB leds[NUM_LEDS]
int x
Definition simple.h:92
CRGBPalette16 currentPalette
uint16_t scale
Definition Noise.ino:74
UISlider brightness("Brightness", 128, 0, 255, 1)
TGradientDirectionCode
Hue direction for calculating fill gradients.
void UpscalePalette(const class CRGBPalette16 &srcpal16, class CRGBPalette256 &destpal256)
@ SHORTEST_HUES
Hue goes whichever way is shortest.
void fill_gradient_RGB(CRGB *leds, u16 startpos, CRGB startcolor, u16 endpos, CRGB endcolor)
Fill a range of LEDs with a smooth RGB gradient between two RGB colors.
Definition fill.cpp:107
void fill_gradient(T *targetArray, u16 startpos, CHSV startcolor, u16 endpos, CHSV endcolor, TGradientDirectionCode directionCode=SHORTEST_HUES)
Fill a range of LEDs with a smooth HSV gradient between two HSV colors.
Definition fill.h:87
void fill_solid(struct CRGB *targetArray, int numToFill, const struct CRGB &color)
Fill a range of LEDs with a solid color.
Definition fill.cpp:9
fl::u32 TProgmemHSVPalette32[32]
CHSVPalette32 entries stored in PROGMEM memory.
const TProgmemRGBGradientPalette_byte * TProgmemRGBGradientPalette_bytes
Pointer to bytes of an RGB gradient, stored in PROGMEM memory.
fl::u32 TProgmemRGBPalette32[32]
CRGBPalette32 entries stored in PROGMEM memory.
fl::u32 TProgmemHSVPalette16[16]
CHSVPalette16 entries stored in PROGMEM memory.
fl::u32 TProgmemRGBPalette16[16]
CRGBPalette16 entries stored in PROGMEM memory.
#define FL_DISABLE_WARNING_RETURN_TYPE
#define FL_DISABLE_WARNING_IMPLICIT_INT_CONVERSION
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_SIGN_CONVERSION
#define FL_DISABLE_WARNING_POP
#define FL_DISABLE_WARNING_UNUSED_PARAMETER
#define FL_DISABLE_WARNING_FLOAT_CONVERSION
FASTLED_FORCE_INLINE bool operator!=(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects do not have the same color data.
Definition crgb.h:797
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
Definition crgb.h:791
Defines the red, green, and blue (RGB) pixel struct.
#define FL_PGM_READ_DWORD_NEAR(x)
Read a double word (32-bit) from PROGMEM memory.
Wrapper definitions to allow seamless use of PROGMEM in environments that have it.
void * memmove8(void *dst, const void *src, uint16_t num)
Faster alternative to memmove() on AVR.
unsigned char u8
Definition int.h:17
void fadeUsingColor(CRGB *leds, fl::u16 numLeds, const CRGB &colormask)
void UpscalePalette(const class CRGBPalette16 &srcpal16, class CRGBPalette256 &destpal256)
To bit_cast(const From &from) noexcept
Definition bit_cast.h:39
void fadeToBlackBy(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy)
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)
u8 fract8
Fixed-Point Fractional Types.
Definition int.h:49
void nscale8(CRGB *leds, fl::u16 num_leds, fl::u8 scale)
void fade_raw(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy)
void fade_video(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy)
CRGB ColorFromPaletteExtended(const CRGBPalette32 &pal, fl::u16 index, fl::u8 brightness, TBlendType blendType)
fl::u8 applyGamma_video(fl::u8 brightness, float gamma)
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)
CRGB HeatColor(fl::u8 temperature)
void fadeLightBy(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy)
signed char i8
Definition int.h:16
CRGB & napplyGamma_video(CRGB &rgb, float gamma)
void nblendPaletteTowardPalette(CRGBPalette16 &current, CRGBPalette16 &target, fl::u8 maxChanges)
void nscale8_video(CRGB *leds, fl::u16 num_leds, fl::u8 scale)
IMPORTANT!
Definition crgb.h:20
CRGB & nscale8(fl::u8 scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
FASTLED_FORCE_INLINE CRGB & nscale8_video(fl::u8 scaledown)
Scale down a RGB to N/256ths of it's current brightness using "video" dimming rules.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition hsv.h:15