Get a color from a palette.
These are the main functions for getting and using palette colors. Regardless of the number of entries in the base palette, this function will interpolate between entries to turn the discrete colors into a smooth gradient.
780{
782 index =
map8(index, 0, 239);
783 }
784
785
786 uint8_t hi4 =
lsrX4(index);
787 uint8_t lo4 = index & 0x0F;
788
790
791
792 uint8_t red1 = entry.red;
793 uint8_t green1 = entry.green;
794 uint8_t blue1 = entry.blue;
795
797
799
800 if( hi4 == 15 ) {
802 } else {
804 }
805
806 uint8_t f2 = lo4 << 4;
807 uint8_t f1 = 255 - f2;
808
809 uint8_t red2 = entry.red;
812 red1 += red2;
813
814 uint8_t green2 = entry.green;
817 green1 += green2;
818
819 uint8_t blue2 = entry.blue;
822 blue1 += blue2;
823
825 }
826
830
831
832 if( red1 ) {
834#if !(FASTLED_SCALE8_FIXED==1)
835 ++red1;
836#endif
837 }
838 if( green1 ) {
840#if !(FASTLED_SCALE8_FIXED==1)
841 ++green1;
842#endif
843 }
844 if( blue1 ) {
846#if !(FASTLED_SCALE8_FIXED==1)
847 ++blue1;
848#endif
849 }
851 } else {
852 red1 = 0;
853 green1 = 0;
854 blue1 = 0;
855 }
856 }
857
858 return CRGB( red1, green1, blue1);
859}
UISlider brightness("Brightness", 255, 0, 255, 1)
uint8_t lsrX4(uint8_t dividend)
Helper function to divide a number by 16, aka four logical shift right (LSR)'s.
#define FL_PGM_READ_DWORD_NEAR(x)
Read a double word (32-bit) from PROGMEM memory.
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
Computes a new color blended some fraction of the way between two other colors.
LIB8STATIC uint8_t map8(uint8_t in, uint8_t rangeStart, uint8_t rangeEnd)
Map from one full-range 8-bit value into a narrower range of 8-bit values, possibly a range of hues.
@ NOBLEND
No interpolation between palette entries.
@ LINEARBLEND_NOWRAP
Linear interpolation between palette entries, but no wrap-around.
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8() does not clean up the R1 register on AVR.
Representation of an RGB pixel (Red, Green, Blue)