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 "crgb.h"
9#include "fastled_progmem.h"
10#include "fl/blur.h"
11#include "fl/colorutils_misc.h"
12#include "fl/deprecated.h"
13#include "fl/fill.h"
14#include "fl/xymap.h"
15#include "lib8tion/memmove.h"
16
17// #include "pixeltypes.h" // pulls in FastLED.h, beware.
18
19#if !defined(FASTLED_USE_32_BIT_GRADIENT_FILL)
20#if defined(__AVR__)
21#define FASTLED_USE_32_BIT_GRADIENT_FILL 0
22#else
23#define FASTLED_USE_32_BIT_GRADIENT_FILL 1
24#endif
25#endif
26
27#pragma GCC diagnostic push
28#pragma GCC diagnostic ignored "-Wcast-align"
29
30namespace fl {
31
33
37
43void fadeLightBy(CRGB *leds, uint16_t num_leds, uint8_t fadeBy);
44
46void fade_video(CRGB *leds, uint16_t num_leds, uint8_t fadeBy);
47
53void nscale8_video(CRGB *leds, uint16_t num_leds, uint8_t scale);
54
60void fadeToBlackBy(CRGB *leds, uint16_t num_leds, uint8_t fadeBy);
61
63void fade_raw(CRGB *leds, uint16_t num_leds, uint8_t fadeBy);
64
71void nscale8(CRGB *leds, uint16_t num_leds, uint8_t scale);
72
84void fadeUsingColor(CRGB *leds, uint16_t numLeds, const CRGB &colormask);
85
87
91
97CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2);
98
101CHSV blend(const CHSV &p1, const CHSV &p2, fract8 amountOfP2,
102 TGradientDirectionCode directionCode = SHORTEST_HUES);
103
112CRGB *blend(const CRGB *src1, const CRGB *src2, CRGB *dest, uint16_t count,
113 fract8 amountOfsrc2);
114
117CHSV *blend(const CHSV *src1, const CHSV *src2, CHSV *dest, uint16_t count,
118 fract8 amountOfsrc2,
119 TGradientDirectionCode directionCode = SHORTEST_HUES);
120
126CRGB &nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay);
127
130CHSV &nblend(CHSV &existing, const CHSV &overlay, fract8 amountOfOverlay,
131 TGradientDirectionCode directionCode = SHORTEST_HUES);
132
139void nblend(CRGB *existing, const CRGB *overlay, uint16_t count,
140 fract8 amountOfOverlay);
141
144void nblend(CHSV *existing, const CHSV *overlay, uint16_t count,
145 fract8 amountOfOverlay,
146 TGradientDirectionCode directionCode = SHORTEST_HUES);
147
149
152
158CRGB HeatColor(uint8_t temperature);
159
162
230
237
238class CRGBPalette16;
239class CRGBPalette32;
240class CRGBPalette256;
241class CHSVPalette16;
242class CHSVPalette32;
243class CHSVPalette256;
244
249typedef union {
250 struct {
251 uint8_t index;
252 uint8_t r;
253 uint8_t g;
254 uint8_t b;
255 };
256 uint32_t dword;
257 uint8_t bytes[4];
258} TRGBGradientPaletteEntryUnion;
259
260typedef uint8_t
261 TDynamicRGBGradientPalette_byte;
263typedef const TDynamicRGBGradientPalette_byte
264 *TDynamicRGBGradientPalette_bytes;
266typedef TDynamicRGBGradientPalette_bytes
267 TDynamicRGBGradientPaletteRef;
269
271
275
279void UpscalePalette(const class CRGBPalette16 &srcpal16,
280 class CRGBPalette256 &destpal256);
282void UpscalePalette(const class CHSVPalette16 &srcpal16,
283 class CHSVPalette256 &destpal256);
284
288void UpscalePalette(const class CRGBPalette16 &srcpal16,
289 class CRGBPalette32 &destpal32);
291void UpscalePalette(const class CHSVPalette16 &srcpal16,
292 class CHSVPalette32 &destpal32);
293
297void UpscalePalette(const class CRGBPalette32 &srcpal32,
298 class CRGBPalette256 &destpal256);
300void UpscalePalette(const class CHSVPalette32 &srcpal32,
301 class CHSVPalette256 &destpal256);
302
304
307
309class CHSVPalette16 {
310 public:
311 CHSV entries[16];
312
314 CHSVPalette16() {};
315
317 CHSVPalette16(const CHSV &c00, const CHSV &c01, const CHSV &c02,
318 const CHSV &c03, const CHSV &c04, const CHSV &c05,
319 const CHSV &c06, const CHSV &c07, const CHSV &c08,
320 const CHSV &c09, const CHSV &c10, const CHSV &c11,
321 const CHSV &c12, const CHSV &c13, const CHSV &c14,
322 const CHSV &c15) {
323 entries[0] = c00;
324 entries[1] = c01;
325 entries[2] = c02;
326 entries[3] = c03;
327 entries[4] = c04;
328 entries[5] = c05;
329 entries[6] = c06;
330 entries[7] = c07;
331 entries[8] = c08;
332 entries[9] = c09;
333 entries[10] = c10;
334 entries[11] = c11;
335 entries[12] = c12;
336 entries[13] = c13;
337 entries[14] = c14;
338 entries[15] = c15;
339 };
340
342 CHSVPalette16(const CHSVPalette16 &rhs) {
343 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
344 }
345
347 CHSVPalette16 &operator=(const CHSVPalette16 &rhs) {
348 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
349 return *this;
350 }
351
353 CHSVPalette16(const TProgmemHSVPalette16 &rhs) {
354 for (uint8_t i = 0; i < 16; ++i) {
355 CRGB xyz(FL_PGM_READ_DWORD_NEAR(rhs + i));
356 entries[i].hue = xyz.red;
357 entries[i].sat = xyz.green;
358 entries[i].val = xyz.blue;
359 }
360 }
361
363 CHSVPalette16 &operator=(const TProgmemHSVPalette16 &rhs) {
364 for (uint8_t i = 0; i < 16; ++i) {
365 CRGB xyz(FL_PGM_READ_DWORD_NEAR(rhs + i));
366 entries[i].hue = xyz.red;
367 entries[i].sat = xyz.green;
368 entries[i].val = xyz.blue;
369 }
370 return *this;
371 }
372
379 inline CHSV &operator[](uint8_t x) __attribute__((always_inline)) {
380 return entries[x];
381 }
382
384 inline const CHSV &operator[](uint8_t x) const
385 __attribute__((always_inline)) {
386 return entries[x];
387 }
388
390 inline CHSV &operator[](int x) __attribute__((always_inline)) {
391 return entries[(uint8_t)x];
392 }
393
395 inline const CHSV &operator[](int x) const __attribute__((always_inline)) {
396 return entries[(uint8_t)x];
397 }
398
400 operator CHSV *() { return &(entries[0]); }
401
403 bool operator==(const CHSVPalette16 &rhs) const {
404 const uint8_t *p = (const uint8_t *)(&(this->entries[0]));
405 const uint8_t *q = (const uint8_t *)(&(rhs.entries[0]));
406 if (p == q)
407 return true;
408 for (uint8_t i = 0; i < (sizeof(entries)); ++i) {
409 if (*p != *q)
410 return false;
411 ++p;
412 ++q;
413 }
414 return true;
415 }
416
418 bool operator!=(const CHSVPalette16 &rhs) const { return !(*this == rhs); }
419
422 CHSVPalette16(const CHSV &c1) { fill_solid(&(entries[0]), 16, c1); }
423
427 CHSVPalette16(const CHSV &c1, const CHSV &c2) {
428 fill_gradient(&(entries[0]), 16, c1, c2);
429 }
430
435 CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
436 fill_gradient(&(entries[0]), 16, c1, c2, c3);
437 }
438
444 CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3,
445 const CHSV &c4) {
446 fill_gradient(&(entries[0]), 16, c1, c2, c3, c4);
447 }
448};
449
451class CHSVPalette256 {
452 public:
453 CHSV entries[256];
454
456 CHSVPalette256() {};
457
462 CHSVPalette256(const CHSV &c00, const CHSV &c01, const CHSV &c02,
463 const CHSV &c03, const CHSV &c04, const CHSV &c05,
464 const CHSV &c06, const CHSV &c07, const CHSV &c08,
465 const CHSV &c09, const CHSV &c10, const CHSV &c11,
466 const CHSV &c12, const CHSV &c13, const CHSV &c14,
467 const CHSV &c15) {
468 CHSVPalette16 p16(c00, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10,
469 c11, c12, c13, c14, c15);
470 *this = p16;
471 };
472
474 CHSVPalette256(const CHSVPalette256 &rhs) {
475 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
476 }
478 CHSVPalette256 &operator=(const CHSVPalette256 &rhs) {
479 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
480 return *this;
481 }
482
484 CHSVPalette256(const CHSVPalette16 &rhs16) { UpscalePalette(rhs16, *this); }
486 CHSVPalette256 &operator=(const CHSVPalette16 &rhs16) {
487 UpscalePalette(rhs16, *this);
488 return *this;
489 }
490
492 CHSVPalette256(const TProgmemRGBPalette16 &rhs) {
493 CHSVPalette16 p16(rhs);
494 *this = p16;
495 }
497 CHSVPalette256 &operator=(const TProgmemRGBPalette16 &rhs) {
498 CHSVPalette16 p16(rhs);
499 *this = p16;
500 return *this;
501 }
502
504 inline CHSV &operator[](uint8_t x) __attribute__((always_inline)) {
505 return entries[x];
506 }
508 inline const CHSV &operator[](uint8_t x) const
509 __attribute__((always_inline)) {
510 return entries[x];
511 }
512
514 inline CHSV &operator[](int x) __attribute__((always_inline)) {
515 return entries[(uint8_t)x];
516 }
518 inline const CHSV &operator[](int x) const __attribute__((always_inline)) {
519 return entries[(uint8_t)x];
520 }
521
523 operator CHSV *() { return &(entries[0]); }
524
526 bool operator==(const CHSVPalette256 &rhs) const {
527 const uint8_t *p = (const uint8_t *)(&(this->entries[0]));
528 const uint8_t *q = (const uint8_t *)(&(rhs.entries[0]));
529 if (p == q)
530 return true;
531 for (uint16_t i = 0; i < (sizeof(entries)); ++i) {
532 if (*p != *q)
533 return false;
534 ++p;
535 ++q;
536 }
537 return true;
538 }
539
541 bool operator!=(const CHSVPalette256 &rhs) const { return !(*this == rhs); }
542
544 CHSVPalette256(const CHSV &c1) { fill_solid(&(entries[0]), 256, c1); }
546 CHSVPalette256(const CHSV &c1, const CHSV &c2) {
547 fill_gradient(&(entries[0]), 256, c1, c2);
548 }
551 CHSVPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
552 fill_gradient(&(entries[0]), 256, c1, c2, c3);
553 }
556 CHSVPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3,
557 const CHSV &c4) {
558 fill_gradient(&(entries[0]), 256, c1, c2, c3, c4);
559 }
560};
561
563class CRGBPalette16 {
564 public:
565 CRGB entries[16];
566
568 CRGBPalette16() {};
569
571 CRGBPalette16(const CRGB &c00, const CRGB &c01, const CRGB &c02,
572 const CRGB &c03, const CRGB &c04, const CRGB &c05,
573 const CRGB &c06, const CRGB &c07, const CRGB &c08,
574 const CRGB &c09, const CRGB &c10, const CRGB &c11,
575 const CRGB &c12, const CRGB &c13, const CRGB &c14,
576 const CRGB &c15) {
577 entries[0] = c00;
578 entries[1] = c01;
579 entries[2] = c02;
580 entries[3] = c03;
581 entries[4] = c04;
582 entries[5] = c05;
583 entries[6] = c06;
584 entries[7] = c07;
585 entries[8] = c08;
586 entries[9] = c09;
587 entries[10] = c10;
588 entries[11] = c11;
589 entries[12] = c12;
590 entries[13] = c13;
591 entries[14] = c14;
592 entries[15] = c15;
593 };
594
596 CRGBPalette16(const CRGBPalette16 &rhs) {
597 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
598 }
600 CRGBPalette16(const CRGB rhs[16]) {
601 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
602 }
604 CRGBPalette16 &operator=(const CRGBPalette16 &rhs) {
605 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
606 return *this;
607 }
609 CRGBPalette16 &operator=(const CRGB rhs[16]) {
610 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
611 return *this;
612 }
613
615 CRGBPalette16(const CHSVPalette16 &rhs) {
616 for (uint8_t i = 0; i < 16; ++i) {
617 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
618 }
619 }
621 CRGBPalette16(const CHSV rhs[16]) {
622 for (uint8_t i = 0; i < 16; ++i) {
623 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
624 }
625 }
627 CRGBPalette16 &operator=(const CHSVPalette16 &rhs) {
628 for (uint8_t i = 0; i < 16; ++i) {
629 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
630 }
631 return *this;
632 }
634 CRGBPalette16 &operator=(const CHSV rhs[16]) {
635 for (uint8_t i = 0; i < 16; ++i) {
636 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
637 }
638 return *this;
639 }
640
642 CRGBPalette16(const TProgmemRGBPalette16 &rhs) {
643 for (uint8_t i = 0; i < 16; ++i) {
644 entries[i] = FL_PGM_READ_DWORD_NEAR(rhs + i);
645 }
646 }
648 CRGBPalette16 &operator=(const TProgmemRGBPalette16 &rhs) {
649 for (uint8_t i = 0; i < 16; ++i) {
650 entries[i] = FL_PGM_READ_DWORD_NEAR(rhs + i);
651 }
652 return *this;
653 }
654
656 bool operator==(const CRGBPalette16 &rhs) const {
657 const uint8_t *p = (const uint8_t *)(&(this->entries[0]));
658 const uint8_t *q = (const uint8_t *)(&(rhs.entries[0]));
659 if (p == q)
660 return true;
661 for (uint8_t i = 0; i < (sizeof(entries)); ++i) {
662 if (*p != *q)
663 return false;
664 ++p;
665 ++q;
666 }
667 return true;
668 }
670 bool operator!=(const CRGBPalette16 &rhs) const { return !(*this == rhs); }
672 inline CRGB &operator[](uint8_t x) __attribute__((always_inline)) {
673 return entries[x];
674 }
676 inline const CRGB &operator[](uint8_t x) const
677 __attribute__((always_inline)) {
678 return entries[x];
679 }
680
682 inline CRGB &operator[](int x) __attribute__((always_inline)) {
683 return entries[(uint8_t)x];
684 }
686 inline const CRGB &operator[](int x) const __attribute__((always_inline)) {
687 return entries[(uint8_t)x];
688 }
689
691 operator CRGB *() { return &(entries[0]); }
692
694 CRGBPalette16(const CHSV &c1) { fill_solid(&(entries[0]), 16, c1); }
696 CRGBPalette16(const CHSV &c1, const CHSV &c2) {
697 fill_gradient(&(entries[0]), 16, c1, c2);
698 }
701 CRGBPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
702 fill_gradient(&(entries[0]), 16, c1, c2, c3);
703 }
706 CRGBPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3,
707 const CHSV &c4) {
708 fill_gradient(&(entries[0]), 16, c1, c2, c3, c4);
709 }
710
712 CRGBPalette16(const CRGB &c1) { fill_solid(&(entries[0]), 16, c1); }
714 CRGBPalette16(const CRGB &c1, const CRGB &c2) {
715 fill_gradient_RGB(&(entries[0]), 16, c1, c2);
716 }
719 CRGBPalette16(const CRGB &c1, const CRGB &c2, const CRGB &c3) {
720 fill_gradient_RGB(&(entries[0]), 16, c1, c2, c3);
721 }
724 CRGBPalette16(const CRGB &c1, const CRGB &c2, const CRGB &c3,
725 const CRGB &c4) {
726 fill_gradient_RGB(&(entries[0]), 16, c1, c2, c3, c4);
727 }
728
758 CRGBPalette16(TProgmemRGBGradientPalette_bytes progpal) { *this = progpal; }
760 CRGBPalette16 &operator=(TProgmemRGBGradientPalette_bytes progpal) {
761 TRGBGradientPaletteEntryUnion *progent =
762 (TRGBGradientPaletteEntryUnion *)(progpal);
763 TRGBGradientPaletteEntryUnion u;
764
765 // Count entries
766 uint16_t count = 0;
767 do {
768 u.dword = FL_PGM_READ_DWORD_NEAR(progent + count);
769 ++count;
770 } while (u.index != 255);
771
772 int8_t lastSlotUsed = -1;
773
774 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
775 CRGB rgbstart(u.r, u.g, u.b);
776
777 int indexstart = 0;
778 uint8_t istart8 = 0;
779 uint8_t iend8 = 0;
780 while (indexstart < 255) {
781 ++progent;
782 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
783 int indexend = u.index;
784 CRGB rgbend(u.r, u.g, u.b);
785 istart8 = indexstart / 16;
786 iend8 = indexend / 16;
787 if (count < 16) {
788 if ((istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) {
789 istart8 = lastSlotUsed + 1;
790 if (iend8 < istart8) {
791 iend8 = istart8;
792 }
793 }
794 lastSlotUsed = iend8;
795 }
796 fill_gradient_RGB(&(entries[0]), istart8, rgbstart, iend8, rgbend);
797 indexstart = indexend;
798 rgbstart = rgbend;
799 }
800 return *this;
801 }
805 CRGBPalette16 &
806 loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal) {
807 TRGBGradientPaletteEntryUnion *ent =
808 (TRGBGradientPaletteEntryUnion *)(gpal);
809 TRGBGradientPaletteEntryUnion u;
810
811 // Count entries
812 uint16_t count = 0;
813 do {
814 u = *(ent + count);
815 ++count;
816 } while (u.index != 255);
817
818 int8_t lastSlotUsed = -1;
819
820 u = *ent;
821 CRGB rgbstart(u.r, u.g, u.b);
822
823 int indexstart = 0;
824 uint8_t istart8 = 0;
825 uint8_t iend8 = 0;
826 while (indexstart < 255) {
827 ++ent;
828 u = *ent;
829 int indexend = u.index;
830 CRGB rgbend(u.r, u.g, u.b);
831 istart8 = indexstart / 16;
832 iend8 = indexend / 16;
833 if (count < 16) {
834 if ((istart8 <= lastSlotUsed) && (lastSlotUsed < 15)) {
835 istart8 = lastSlotUsed + 1;
836 if (iend8 < istart8) {
837 iend8 = istart8;
838 }
839 }
840 lastSlotUsed = iend8;
841 }
842 fill_gradient_RGB(&(entries[0]), istart8, rgbstart, iend8, rgbend);
843 indexstart = indexend;
844 rgbstart = rgbend;
845 }
846 return *this;
847 }
848};
849
851class CHSVPalette32 {
852 public:
853 CHSV entries[32];
854
856 CHSVPalette32() {};
857
862 CHSVPalette32(const CHSV &c00, const CHSV &c01, const CHSV &c02,
863 const CHSV &c03, const CHSV &c04, const CHSV &c05,
864 const CHSV &c06, const CHSV &c07, const CHSV &c08,
865 const CHSV &c09, const CHSV &c10, const CHSV &c11,
866 const CHSV &c12, const CHSV &c13, const CHSV &c14,
867 const CHSV &c15) {
868 for (uint8_t i = 0; i < 2; ++i) {
869 entries[0 + i] = c00;
870 entries[2 + i] = c01;
871 entries[4 + i] = c02;
872 entries[6 + i] = c03;
873 entries[8 + i] = c04;
874 entries[10 + i] = c05;
875 entries[12 + i] = c06;
876 entries[14 + i] = c07;
877 entries[16 + i] = c08;
878 entries[18 + i] = c09;
879 entries[20 + i] = c10;
880 entries[22 + i] = c11;
881 entries[24 + i] = c12;
882 entries[26 + i] = c13;
883 entries[28 + i] = c14;
884 entries[30 + i] = c15;
885 }
886 };
887
889 CHSVPalette32(const CHSVPalette32 &rhs) {
890 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
891 }
893 CHSVPalette32 &operator=(const CHSVPalette32 &rhs) {
894 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
895 return *this;
896 }
897
899 CHSVPalette32(const TProgmemHSVPalette32 &rhs) {
900 for (uint8_t i = 0; i < 32; ++i) {
901 CRGB xyz(FL_PGM_READ_DWORD_NEAR(rhs + i));
902 entries[i].hue = xyz.red;
903 entries[i].sat = xyz.green;
904 entries[i].val = xyz.blue;
905 }
906 }
908 CHSVPalette32 &operator=(const TProgmemHSVPalette32 &rhs) {
909 for (uint8_t i = 0; i < 32; ++i) {
910 CRGB xyz(FL_PGM_READ_DWORD_NEAR(rhs + i));
911 entries[i].hue = xyz.red;
912 entries[i].sat = xyz.green;
913 entries[i].val = xyz.blue;
914 }
915 return *this;
916 }
917
919 inline CHSV &operator[](uint8_t x) __attribute__((always_inline)) {
920 return entries[x];
921 }
923 inline const CHSV &operator[](uint8_t x) const
924 __attribute__((always_inline)) {
925 return entries[x];
926 }
927
929 inline CHSV &operator[](int x) __attribute__((always_inline)) {
930 return entries[(uint8_t)x];
931 }
933 inline const CHSV &operator[](int x) const __attribute__((always_inline)) {
934 return entries[(uint8_t)x];
935 }
936
938 operator CHSV *() { return &(entries[0]); }
939
941 bool operator==(const CHSVPalette32 &rhs) const {
942 const uint8_t *p = (const uint8_t *)(&(this->entries[0]));
943 const uint8_t *q = (const uint8_t *)(&(rhs.entries[0]));
944 if (p == q)
945 return true;
946 for (uint8_t i = 0; i < (sizeof(entries)); ++i) {
947 if (*p != *q)
948 return false;
949 ++p;
950 ++q;
951 }
952 return true;
953 }
955 bool operator!=(const CHSVPalette32 &rhs) const { return !(*this == rhs); }
956
958 CHSVPalette32(const CHSV &c1) { fill_solid(&(entries[0]), 32, c1); }
960 CHSVPalette32(const CHSV &c1, const CHSV &c2) {
961 fill_gradient(&(entries[0]), 32, c1, c2);
962 }
965 CHSVPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
966 fill_gradient(&(entries[0]), 32, c1, c2, c3);
967 }
970 CHSVPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3,
971 const CHSV &c4) {
972 fill_gradient(&(entries[0]), 32, c1, c2, c3, c4);
973 }
974};
975
977class CRGBPalette32 {
978 public:
979 CRGB entries[32];
980
982 CRGBPalette32() {};
983
989 CRGBPalette32(const CRGB &c00, const CRGB &c01, const CRGB &c02,
990 const CRGB &c03, const CRGB &c04, const CRGB &c05,
991 const CRGB &c06, const CRGB &c07, const CRGB &c08,
992 const CRGB &c09, const CRGB &c10, const CRGB &c11,
993 const CRGB &c12, const CRGB &c13, const CRGB &c14,
994 const CRGB &c15) {
995 for (uint8_t i = 0; i < 2; ++i) {
996 entries[0 + i] = c00;
997 entries[2 + i] = c01;
998 entries[4 + i] = c02;
999 entries[6 + i] = c03;
1000 entries[8 + i] = c04;
1001 entries[10 + i] = c05;
1002 entries[12 + i] = c06;
1003 entries[14 + i] = c07;
1004 entries[16 + i] = c08;
1005 entries[18 + i] = c09;
1006 entries[20 + i] = c10;
1007 entries[22 + i] = c11;
1008 entries[24 + i] = c12;
1009 entries[26 + i] = c13;
1010 entries[28 + i] = c14;
1011 entries[30 + i] = c15;
1012 }
1013 };
1014
1016 CRGBPalette32(const CRGBPalette32 &rhs) {
1017 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
1018 }
1020 CRGBPalette32(const CRGB rhs[32]) {
1021 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
1022 }
1024 CRGBPalette32 &operator=(const CRGBPalette32 &rhs) {
1025 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
1026 return *this;
1027 }
1029 CRGBPalette32 &operator=(const CRGB rhs[32]) {
1030 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
1031 return *this;
1032 }
1033
1035 CRGBPalette32(const CHSVPalette32 &rhs) {
1036 for (uint8_t i = 0; i < 32; ++i) {
1037 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1038 }
1039 }
1041 CRGBPalette32(const CHSV rhs[32]) {
1042 for (uint8_t i = 0; i < 32; ++i) {
1043 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1044 }
1045 }
1047 CRGBPalette32 &operator=(const CHSVPalette32 &rhs) {
1048 for (uint8_t i = 0; i < 32; ++i) {
1049 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1050 }
1051 return *this;
1052 }
1054 CRGBPalette32 &operator=(const CHSV rhs[32]) {
1055 for (uint8_t i = 0; i < 32; ++i) {
1056 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1057 }
1058 return *this;
1059 }
1060
1062 CRGBPalette32(const TProgmemRGBPalette32 &rhs) {
1063 for (uint8_t i = 0; i < 32; ++i) {
1064 entries[i] = FL_PGM_READ_DWORD_NEAR(rhs + i);
1065 }
1066 }
1068 CRGBPalette32 &operator=(const TProgmemRGBPalette32 &rhs) {
1069 for (uint8_t i = 0; i < 32; ++i) {
1070 entries[i] = FL_PGM_READ_DWORD_NEAR(rhs + i);
1071 }
1072 return *this;
1073 }
1074
1076 bool operator==(const CRGBPalette32 &rhs) const {
1077 const uint8_t *p = (const uint8_t *)(&(this->entries[0]));
1078 const uint8_t *q = (const uint8_t *)(&(rhs.entries[0]));
1079 if (p == q)
1080 return true;
1081 for (uint8_t i = 0; i < (sizeof(entries)); ++i) {
1082 if (*p != *q)
1083 return false;
1084 ++p;
1085 ++q;
1086 }
1087 return true;
1088 }
1090 bool operator!=(const CRGBPalette32 &rhs) const { return !(*this == rhs); }
1091
1093 inline CRGB &operator[](uint8_t x) __attribute__((always_inline)) {
1094 return entries[x];
1095 }
1097 inline const CRGB &operator[](uint8_t x) const
1098 __attribute__((always_inline)) {
1099 return entries[x];
1100 }
1101
1103 inline CRGB &operator[](int x) __attribute__((always_inline)) {
1104 return entries[(uint8_t)x];
1105 }
1107 inline const CRGB &operator[](int x) const __attribute__((always_inline)) {
1108 return entries[(uint8_t)x];
1109 }
1110
1112 operator CRGB *() { return &(entries[0]); }
1113
1115 CRGBPalette32(const CHSV &c1) { fill_solid(&(entries[0]), 32, c1); }
1117 CRGBPalette32(const CHSV &c1, const CHSV &c2) {
1118 fill_gradient(&(entries[0]), 32, c1, c2);
1119 }
1122 CRGBPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
1123 fill_gradient(&(entries[0]), 32, c1, c2, c3);
1124 }
1127 CRGBPalette32(const CHSV &c1, const CHSV &c2, const CHSV &c3,
1128 const CHSV &c4) {
1129 fill_gradient(&(entries[0]), 32, c1, c2, c3, c4);
1130 }
1131
1133 CRGBPalette32(const CRGB &c1) { fill_solid(&(entries[0]), 32, c1); }
1135 CRGBPalette32(const CRGB &c1, const CRGB &c2) {
1136 fill_gradient_RGB(&(entries[0]), 32, c1, c2);
1137 }
1140 CRGBPalette32(const CRGB &c1, const CRGB &c2, const CRGB &c3) {
1141 fill_gradient_RGB(&(entries[0]), 32, c1, c2, c3);
1142 }
1145 CRGBPalette32(const CRGB &c1, const CRGB &c2, const CRGB &c3,
1146 const CRGB &c4) {
1147 fill_gradient_RGB(&(entries[0]), 32, c1, c2, c3, c4);
1148 }
1149
1151 CRGBPalette32(const CRGBPalette16 &rhs16) { UpscalePalette(rhs16, *this); }
1153 CRGBPalette32 &operator=(const CRGBPalette16 &rhs16) {
1154 UpscalePalette(rhs16, *this);
1155 return *this;
1156 }
1157
1159 CRGBPalette32(const TProgmemRGBPalette16 &rhs) {
1160 CRGBPalette16 p16(rhs);
1161 *this = p16;
1162 }
1164 CRGBPalette32 &operator=(const TProgmemRGBPalette16 &rhs) {
1165 CRGBPalette16 p16(rhs);
1166 *this = p16;
1167 return *this;
1168 }
1169
1171 CRGBPalette32(TProgmemRGBGradientPalette_bytes progpal) { *this = progpal; }
1173 CRGBPalette32 &operator=(TProgmemRGBGradientPalette_bytes progpal) {
1174 TRGBGradientPaletteEntryUnion *progent =
1175 (TRGBGradientPaletteEntryUnion *)(progpal);
1176 TRGBGradientPaletteEntryUnion u;
1177
1178 // Count entries
1179 uint16_t count = 0;
1180 do {
1181 u.dword = FL_PGM_READ_DWORD_NEAR(progent + count);
1182 ++count;
1183 } while (u.index != 255);
1184
1185 int8_t lastSlotUsed = -1;
1186
1187 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
1188 CRGB rgbstart(u.r, u.g, u.b);
1189
1190 int indexstart = 0;
1191 uint8_t istart8 = 0;
1192 uint8_t iend8 = 0;
1193 while (indexstart < 255) {
1194 ++progent;
1195 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
1196 int indexend = u.index;
1197 CRGB rgbend(u.r, u.g, u.b);
1198 istart8 = indexstart / 8;
1199 iend8 = indexend / 8;
1200 if (count < 16) {
1201 if ((istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) {
1202 istart8 = lastSlotUsed + 1;
1203 if (iend8 < istart8) {
1204 iend8 = istart8;
1205 }
1206 }
1207 lastSlotUsed = iend8;
1208 }
1209 fill_gradient_RGB(&(entries[0]), istart8, rgbstart, iend8, rgbend);
1210 indexstart = indexend;
1211 rgbstart = rgbend;
1212 }
1213 return *this;
1214 }
1217 CRGBPalette32 &
1218 loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal) {
1219 TRGBGradientPaletteEntryUnion *ent =
1220 (TRGBGradientPaletteEntryUnion *)(gpal);
1221 TRGBGradientPaletteEntryUnion u;
1222
1223 // Count entries
1224 uint16_t count = 0;
1225 do {
1226 u = *(ent + count);
1227 ++count;
1228 } while (u.index != 255);
1229
1230 int8_t lastSlotUsed = -1;
1231
1232 u = *ent;
1233 CRGB rgbstart(u.r, u.g, u.b);
1234
1235 int indexstart = 0;
1236 uint8_t istart8 = 0;
1237 uint8_t iend8 = 0;
1238 while (indexstart < 255) {
1239 ++ent;
1240 u = *ent;
1241 int indexend = u.index;
1242 CRGB rgbend(u.r, u.g, u.b);
1243 istart8 = indexstart / 8;
1244 iend8 = indexend / 8;
1245 if (count < 16) {
1246 if ((istart8 <= lastSlotUsed) && (lastSlotUsed < 31)) {
1247 istart8 = lastSlotUsed + 1;
1248 if (iend8 < istart8) {
1249 iend8 = istart8;
1250 }
1251 }
1252 lastSlotUsed = iend8;
1253 }
1254 fill_gradient_RGB(&(entries[0]), istart8, rgbstart, iend8, rgbend);
1255 indexstart = indexend;
1256 rgbstart = rgbend;
1257 }
1258 return *this;
1259 }
1260};
1261
1263class CRGBPalette256 {
1264 public:
1265 CRGB entries[256];
1266
1268 CRGBPalette256() {};
1269
1275 CRGBPalette256(const CRGB &c00, const CRGB &c01, const CRGB &c02,
1276 const CRGB &c03, const CRGB &c04, const CRGB &c05,
1277 const CRGB &c06, const CRGB &c07, const CRGB &c08,
1278 const CRGB &c09, const CRGB &c10, const CRGB &c11,
1279 const CRGB &c12, const CRGB &c13, const CRGB &c14,
1280 const CRGB &c15) {
1281 CRGBPalette16 p16(c00, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10,
1282 c11, c12, c13, c14, c15);
1283 *this = p16;
1284 };
1285
1287 CRGBPalette256(const CRGBPalette256 &rhs) {
1288 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
1289 }
1291 CRGBPalette256(const CRGB rhs[256]) {
1292 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
1293 }
1295 CRGBPalette256 &operator=(const CRGBPalette256 &rhs) {
1296 memmove8((void *)&(entries[0]), &(rhs.entries[0]), sizeof(entries));
1297 return *this;
1298 }
1300 CRGBPalette256 &operator=(const CRGB rhs[256]) {
1301 memmove8((void *)&(entries[0]), &(rhs[0]), sizeof(entries));
1302 return *this;
1303 }
1304
1306 CRGBPalette256(const CHSVPalette256 &rhs) {
1307 for (int i = 0; i < 256; ++i) {
1308 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1309 }
1310 }
1312 CRGBPalette256(const CHSV rhs[256]) {
1313 for (int i = 0; i < 256; ++i) {
1314 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1315 }
1316 }
1318 CRGBPalette256 &operator=(const CHSVPalette256 &rhs) {
1319 for (int i = 0; i < 256; ++i) {
1320 entries[i] = rhs.entries[i]; // implicit HSV-to-RGB conversion
1321 }
1322 return *this;
1323 }
1325 CRGBPalette256 &operator=(const CHSV rhs[256]) {
1326 for (int i = 0; i < 256; ++i) {
1327 entries[i] = rhs[i]; // implicit HSV-to-RGB conversion
1328 }
1329 return *this;
1330 }
1331
1333 CRGBPalette256(const CRGBPalette16 &rhs16) { UpscalePalette(rhs16, *this); }
1335 CRGBPalette256 &operator=(const CRGBPalette16 &rhs16) {
1336 UpscalePalette(rhs16, *this);
1337 return *this;
1338 }
1339
1341 CRGBPalette256(const TProgmemRGBPalette16 &rhs) {
1342 CRGBPalette16 p16(rhs);
1343 *this = p16;
1344 }
1346 CRGBPalette256 &operator=(const TProgmemRGBPalette16 &rhs) {
1347 CRGBPalette16 p16(rhs);
1348 *this = p16;
1349 return *this;
1350 }
1351
1353 bool operator==(const CRGBPalette256 &rhs) const {
1354 const uint8_t *p = (const uint8_t *)(&(this->entries[0]));
1355 const uint8_t *q = (const uint8_t *)(&(rhs.entries[0]));
1356 if (p == q)
1357 return true;
1358 for (uint16_t i = 0; i < (sizeof(entries)); ++i) {
1359 if (*p != *q)
1360 return false;
1361 ++p;
1362 ++q;
1363 }
1364 return true;
1365 }
1367 bool operator!=(const CRGBPalette256 &rhs) const { return !(*this == rhs); }
1368
1370 inline CRGB &operator[](uint8_t x) __attribute__((always_inline)) {
1371 return entries[x];
1372 }
1374 inline const CRGB &operator[](uint8_t x) const
1375 __attribute__((always_inline)) {
1376 return entries[x];
1377 }
1378
1380 inline CRGB &operator[](int x) __attribute__((always_inline)) {
1381 return entries[(uint8_t)x];
1382 }
1384 inline const CRGB &operator[](int x) const __attribute__((always_inline)) {
1385 return entries[(uint8_t)x];
1386 }
1387
1389 operator CRGB *() { return &(entries[0]); }
1390
1392 CRGBPalette256(const CHSV &c1) { fill_solid(&(entries[0]), 256, c1); }
1394 CRGBPalette256(const CHSV &c1, const CHSV &c2) {
1395 fill_gradient(&(entries[0]), 256, c1, c2);
1396 }
1399 CRGBPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3) {
1400 fill_gradient(&(entries[0]), 256, c1, c2, c3);
1401 }
1404 CRGBPalette256(const CHSV &c1, const CHSV &c2, const CHSV &c3,
1405 const CHSV &c4) {
1406 fill_gradient(&(entries[0]), 256, c1, c2, c3, c4);
1407 }
1408
1410 CRGBPalette256(const CRGB &c1) { fill_solid(&(entries[0]), 256, c1); }
1412 CRGBPalette256(const CRGB &c1, const CRGB &c2) {
1413 fill_gradient_RGB(&(entries[0]), 256, c1, c2);
1414 }
1417 CRGBPalette256(const CRGB &c1, const CRGB &c2, const CRGB &c3) {
1418 fill_gradient_RGB(&(entries[0]), 256, c1, c2, c3);
1419 }
1422 CRGBPalette256(const CRGB &c1, const CRGB &c2, const CRGB &c3,
1423 const CRGB &c4) {
1424 fill_gradient_RGB(&(entries[0]), 256, c1, c2, c3, c4);
1425 }
1426
1428 CRGBPalette256(TProgmemRGBGradientPalette_bytes progpal) {
1429 *this = progpal;
1430 }
1432 CRGBPalette256 &operator=(TProgmemRGBGradientPalette_bytes progpal) {
1433 TRGBGradientPaletteEntryUnion *progent =
1434 (TRGBGradientPaletteEntryUnion *)(progpal);
1435 TRGBGradientPaletteEntryUnion u;
1436 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
1437 CRGB rgbstart(u.r, u.g, u.b);
1438
1439 int indexstart = 0;
1440 while (indexstart < 255) {
1441 ++progent;
1442 u.dword = FL_PGM_READ_DWORD_NEAR(progent);
1443 int indexend = u.index;
1444 CRGB rgbend(u.r, u.g, u.b);
1445 fill_gradient_RGB(&(entries[0]), indexstart, rgbstart, indexend,
1446 rgbend);
1447 indexstart = indexend;
1448 rgbstart = rgbend;
1449 }
1450 return *this;
1451 }
1454 CRGBPalette256 &
1455 loadDynamicGradientPalette(TDynamicRGBGradientPalette_bytes gpal) {
1456 TRGBGradientPaletteEntryUnion *ent =
1457 (TRGBGradientPaletteEntryUnion *)(gpal);
1458 TRGBGradientPaletteEntryUnion u;
1459 u = *ent;
1460 CRGB rgbstart(u.r, u.g, u.b);
1461
1462 int indexstart = 0;
1463 while (indexstart < 255) {
1464 ++ent;
1465 u = *ent;
1466 int indexend = u.index;
1467 CRGB rgbend(u.r, u.g, u.b);
1468 fill_gradient_RGB(&(entries[0]), indexstart, rgbstart, indexend,
1469 rgbend);
1470 indexstart = indexend;
1471 rgbstart = rgbend;
1472 }
1473 return *this;
1474 }
1475};
1476
1478
1482
1484typedef enum {
1485 NOBLEND = 0,
1486 BLEND = 1,
1487 LINEARBLEND = 1,
1489 LINEARBLEND_NOWRAP =
1490 2
1491} TBlendType;
1492
1503CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index,
1504 uint8_t brightness = 255,
1505 TBlendType blendType = LINEARBLEND);
1506
1513CRGB ColorFromPaletteExtended(const CRGBPalette16 &pal, uint16_t index,
1514 uint8_t brightness, TBlendType blendType);
1515
1521CRGB ColorFromPaletteExtended(const CRGBPalette32 &pal, uint16_t index,
1522 uint8_t brightness, TBlendType blendType);
1523
1526CRGB ColorFromPalette(const TProgmemRGBPalette16 &pal, uint8_t index,
1527 uint8_t brightness = 255,
1528 TBlendType blendType = LINEARBLEND);
1529
1532CRGB ColorFromPalette(const CRGBPalette256 &pal, uint8_t index,
1533 uint8_t brightness = 255, TBlendType blendType = NOBLEND);
1534
1535// @author https://github.com/generalelectrix
1536CRGB ColorFromPaletteExtended(const CRGBPalette256 &pal, uint16_t index,
1537 uint8_t brightness = 255,
1538 TBlendType blendType = LINEARBLEND);
1539
1542CHSV ColorFromPalette(const CHSVPalette16 &pal, uint8_t index,
1543 uint8_t brightness = 255,
1544 TBlendType blendType = LINEARBLEND);
1545
1548CHSV ColorFromPalette(const CHSVPalette256 &pal, uint8_t index,
1549 uint8_t brightness = 255, TBlendType blendType = NOBLEND);
1550
1553CRGB ColorFromPalette(const CRGBPalette32 &pal, uint8_t index,
1554 uint8_t brightness = 255,
1555 TBlendType blendType = LINEARBLEND);
1556
1559CRGB ColorFromPalette(const TProgmemRGBPalette32 &pal, uint8_t index,
1560 uint8_t brightness = 255,
1561 TBlendType blendType = LINEARBLEND);
1562
1565CHSV ColorFromPalette(const CHSVPalette32 &pal, uint8_t index,
1566 uint8_t brightness = 255,
1567 TBlendType blendType = LINEARBLEND);
1568
1579template <typename PALETTE>
1580void fill_palette(CRGB *L, uint16_t N, uint8_t startIndex, uint8_t incIndex,
1581 const PALETTE &pal, uint8_t brightness = 255,
1582 TBlendType blendType = LINEARBLEND) {
1583 uint8_t colorIndex = startIndex;
1584 for (uint16_t i = 0; i < N; ++i) {
1585 L[i] = ColorFromPalette(pal, colorIndex, brightness, blendType);
1586 colorIndex += incIndex;
1587 }
1588}
1589
1601template <typename PALETTE>
1602void fill_palette_circular(CRGB *L, uint16_t N, uint8_t startIndex,
1603 const PALETTE &pal, uint8_t brightness = 255,
1604 TBlendType blendType = LINEARBLEND,
1605 bool reversed = false) {
1606 if (N == 0)
1607 return; // avoiding div/0
1608
1609 const uint16_t colorChange =
1610 65535 / N; // color change for each LED, * 256 for precision
1611 uint16_t colorIndex = ((uint16_t)startIndex)
1612 << 8; // offset for color index, with precision (*256)
1613
1614 for (uint16_t i = 0; i < N; ++i) {
1615 L[i] = ColorFromPalette(pal, (colorIndex >> 8), brightness, blendType);
1616 if (reversed)
1617 colorIndex -= colorChange;
1618 else
1619 colorIndex += colorChange;
1620 }
1621}
1622
1642template <typename PALETTE>
1643void map_data_into_colors_through_palette(
1644 uint8_t *dataArray, uint16_t dataCount, CRGB *targetColorArray,
1645 const PALETTE &pal, uint8_t brightness = 255, uint8_t opacity = 255,
1646 TBlendType blendType = LINEARBLEND) {
1647 for (uint16_t i = 0; i < dataCount; ++i) {
1648 uint8_t d = dataArray[i];
1649 CRGB rgb = ColorFromPalette(pal, d, brightness, blendType);
1650 if (opacity == 255) {
1651 targetColorArray[i] = rgb;
1652 } else {
1653 targetColorArray[i].nscale8(256 - opacity);
1654 rgb.nscale8_video(opacity);
1655 targetColorArray[i] += rgb;
1656 }
1657 }
1658}
1659
1698void nblendPaletteTowardPalette(CRGBPalette16 &currentPalette,
1699 CRGBPalette16 &targetPalette,
1700 uint8_t maxChanges = 24);
1701
1703
1705
1737
1742uint8_t applyGamma_video(uint8_t brightness, float gamma);
1743
1748CRGB applyGamma_video(const CRGB &orig, float gamma);
1749
1756CRGB applyGamma_video(const CRGB &orig, float gammaR, float gammaG,
1757 float gammaB);
1758
1762CRGB &napplyGamma_video(CRGB &rgb, float gamma);
1763
1769CRGB &napplyGamma_video(CRGB &rgb, float gammaR, float gammaG, float gammaB);
1770
1776void napplyGamma_video(CRGB *rgbarray, uint16_t count, float gamma);
1777
1785void napplyGamma_video(CRGB *rgbarray, uint16_t count, float gammaR,
1786 float gammaG, float gammaB);
1787
1789
1790} // namespace fl
1791
1792#pragma GCC diagnostic pop
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
CRGBPalette16 currentPalette
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
UISlider brightness("Brightness", 255, 0, 255, 1)
TGradientDirectionCode
Hue direction for calculating fill gradients.
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 fill.h:77
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
uint32_t TProgmemRGBPalette32[32]
CRGBPalette32 entries stored in PROGMEM memory.
uint32_t TProgmemRGBPalette16[16]
CRGBPalette16 entries stored in PROGMEM memory.
uint32_t TProgmemHSVPalette32[32]
CHSVPalette32 entries stored in PROGMEM memory.
const TProgmemRGBGradientPalette_byte * TProgmemRGBGradientPalette_bytes
Pointer to bytes of an RGB gradient, stored in PROGMEM memory.
uint32_t TProgmemHSVPalette16[16]
CHSVPalette16 entries stored in PROGMEM memory.
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.
uint8_t fract8
ANSI: unsigned short _Fract.
Definition types.h:36
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:665
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
Definition crgb.h:659
void fadeUsingColor(CRGB *leds, uint16_t numLeds, const CRGB &colormask)
@ SHORTEST_HUES
Hue goes whichever way is shortest.
void UpscalePalette(const class CRGBPalette16 &srcpal16, class CRGBPalette256 &destpal256)
CRGB ColorFromPaletteExtended(const CRGBPalette32 &pal, uint16_t index, uint8_t brightness, TBlendType blendType)
uint8_t applyGamma_video(uint8_t brightness, float gamma)
CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index, uint8_t brightness, TBlendType blendType)
CRGB HeatColor(uint8_t temperature)
void fadeToBlackBy(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
void nblendPaletteTowardPalette(CRGBPalette16 &current, CRGBPalette16 &target, uint8_t maxChanges)
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)
void fade_raw(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
void fadeLightBy(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
void nscale8(CRGB *leds, uint16_t num_leds, uint8_t scale)
CRGB & napplyGamma_video(CRGB &rgb, float gamma)
void fade_video(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
void nscale8_video(CRGB *leds, uint16_t num_leds, uint8_t scale)
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
static FASTLED_NAMESPACE_BEGIN uint8_t const p[]
Definition noise.cpp:30
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:16
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:69
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:88
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55