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.
958{
960 index =
map8(index, 0, 247);
961 }
962
963 uint8_t hi5 = index;
964#if defined(__AVR__)
965 hi5 /= 2;
966 hi5 /= 2;
967 hi5 /= 2;
968#else
969 hi5 >>= 3;
970#endif
971 uint8_t lo3 = index & 0x07;
972
974
975 uint8_t red1 = entry.red;
976 uint8_t green1 = entry.green;
977 uint8_t blue1 = entry.blue;
978
980
982
983 if( hi5 == 31 ) {
985 } else {
987 }
988
989 uint8_t f2 = lo3 << 5;
990 uint8_t f1 = 255 - f2;
991
992 uint8_t red2 = entry.red;
995 red1 += red2;
996
997 uint8_t green2 = entry.green;
1000 green1 += green2;
1001
1002 uint8_t blue2 = entry.blue;
1005 blue1 += blue2;
1006
1008 }
1009
1013
1014
1015 if( red1 ) {
1017#if !(FASTLED_SCALE8_FIXED==1)
1018 ++red1;
1019#endif
1020 }
1021 if( green1 ) {
1023#if !(FASTLED_SCALE8_FIXED==1)
1024 ++green1;
1025#endif
1026 }
1027 if( blue1 ) {
1029#if !(FASTLED_SCALE8_FIXED==1)
1030 ++blue1;
1031#endif
1032 }
1034 } else {
1035 red1 = 0;
1036 green1 = 0;
1037 blue1 = 0;
1038 }
1039 }
1040
1041 return CRGB( red1, green1, blue1);
1042}
UISlider brightness("Brightness", 255, 0, 255, 1)
#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)