1#define FASTLED_INTERNAL
2#define __PROG_TYPES_COMPAT__
21 if (amountOfOverlay == 0) {
25 if (amountOfOverlay == 255) {
32 fract8 amountOfKeep = 255 - amountOfOverlay;
44 existing.red =
blend8(existing.red, overlay.red, amountOfOverlay);
45 existing.green =
blend8(existing.green, overlay.green, amountOfOverlay);
46 existing.blue =
blend8(existing.blue, overlay.blue, amountOfOverlay);
54 for (fl::u16 i = count; i; --i) {
55 nblend(*existing, *overlay, amountOfOverlay);
63 nblend(nu, p2, amountOfP2);
69 for (fl::u16 i = 0; i < count; ++i) {
70 dest[i] =
blend(src1[i], src2[i], amountOfsrc2);
77 if (amountOfOverlay == 0) {
81 if (amountOfOverlay == 255) {
86 fract8 amountOfKeep = 255 - amountOfOverlay;
88 fl::u8 huedelta8 = overlay.hue - existing.hue;
92 if (huedelta8 > 127) {
99 if (huedelta8 < 128) {
105 existing.hue = existing.hue +
scale8(huedelta8, amountOfOverlay);
108 huedelta8 = -huedelta8;
109 existing.hue = existing.hue -
scale8(huedelta8, amountOfOverlay);
124 if (existing == overlay)
126 for (fl::u16 i = count; i; --i) {
127 nblend(*existing, *overlay, amountOfOverlay, directionCode);
136 nblend(nu, p2, amountOfP2, directionCode);
142 for (fl::u16 i = 0; i < count; ++i) {
143 dest[i] =
blend(src1[i], src2[i], amountOfsrc2, directionCode);
149 for (fl::u16 i = 0; i < num_leds; ++i) {
171 for (fl::u16 i = 0; i < num_leds; ++i) {
182 for (fl::u16 i = 0; i < numLeds; ++i) {
210 fl::u8 heatramp = t192 & 0x3F;
218 heatcolor.b = heatramp;
220 }
else if (t192 & 0x40) {
223 heatcolor.g = heatramp;
228 heatcolor.r = heatramp;
256 fl::u8 index_5bit = (index >> 11);
260 const CRGB *entry = &(pal[0]) + index_5bit;
262 fl::u8 green1 = entry->green;
263 fl::u8 blue1 = entry->blue;
267 if (index_5bit == 31) {
282 fl::u8 green2 = entry->green;
283 fl::u8 blue2 = entry->blue;
297 return CRGB(red1, green1, blue1);
302 if (blendType == LINEARBLEND_NOWRAP) {
303 index =
map8(index, 0, 239);
309 fl::u8 lo4 = index & 0x0F;
317 const CRGB *entry = (
CRGB *)((
fl::u8 *)(&(pal[0])) + hi4XsizeofCRGB);
322 fl::u8 green1 = entry->green;
323 fl::u8 blue1 = entry->blue;
342 fl::u8 green2 = entry->green;
347 fl::u8 blue2 = entry->blue;
363#if !(FASTLED_SCALE8_FIXED == 1)
369#if !(FASTLED_SCALE8_FIXED == 1)
375#if !(FASTLED_SCALE8_FIXED == 1)
387 return CRGB(red1, green1, blue1);
393 fl::u8 index_4bit = index >> 12;
397 const CRGB *entry = &(pal[0]) + index_4bit;
399 fl::u8 green1 = entry->green;
400 fl::u8 blue1 = entry->blue;
404 if (index_4bit == 15) {
419 fl::u8 green2 = entry->green;
420 fl::u8 blue2 = entry->blue;
435 return CRGB(red1, green1, blue1);
440 if (blendType == LINEARBLEND_NOWRAP) {
441 index =
map8(index, 0, 239);
447 fl::u8 lo4 = index & 0x0F;
452 fl::u8 green1 = entry.green;
453 fl::u8 blue1 = entry.blue;
473 fl::u8 green2 = entry.green;
478 fl::u8 blue2 = entry.blue;
494#if !(FASTLED_SCALE8_FIXED == 1)
500#if !(FASTLED_SCALE8_FIXED == 1)
506#if !(FASTLED_SCALE8_FIXED == 1)
518 return CRGB(red1, green1, blue1);
523 if (blendType == LINEARBLEND_NOWRAP) {
524 index =
map8(index, 0, 247);
536 fl::u8 lo3 = index & 0x07;
544 const CRGB *entry = (
CRGB *)((
fl::u8 *)(&(pal[0])) + hi5XsizeofCRGB);
547 fl::u8 green1 = entry->green;
548 fl::u8 blue1 = entry->blue;
568 fl::u8 green2 = entry->green;
573 fl::u8 blue2 = entry->blue;
589#if !(FASTLED_SCALE8_FIXED == 1)
595#if !(FASTLED_SCALE8_FIXED == 1)
601#if !(FASTLED_SCALE8_FIXED == 1)
613 return CRGB(red1, green1, blue1);
618 if (blendType == LINEARBLEND_NOWRAP) {
619 index =
map8(index, 0, 247);
631 fl::u8 lo3 = index & 0x07;
636 fl::u8 green1 = entry.green;
637 fl::u8 blue1 = entry.blue;
657 fl::u8 green2 = entry.green;
662 fl::u8 blue2 = entry.blue;
678#if !(FASTLED_SCALE8_FIXED == 1)
684#if !(FASTLED_SCALE8_FIXED == 1)
690#if !(FASTLED_SCALE8_FIXED == 1)
702 return CRGB(red1, green1, blue1);
707 const CRGB *entry = &(pal[0]) + index;
710 fl::u8 green = entry->green;
711 fl::u8 blue = entry->blue;
721 return CRGB(red, green, blue);
727 fl::u8 index_8bit = index >> 8;
731 const CRGB *entry = &(pal[0]) + index_8bit;
733 fl::u8 green1 = entry->green;
734 fl::u8 blue1 = entry->blue;
738 if (index_8bit == 255) {
753 fl::u8 green2 = entry->green;
754 fl::u8 blue2 = entry->blue;
769 return CRGB(red1, green1, blue1);
774 if (blendType == LINEARBLEND_NOWRAP) {
775 index =
map8(index, 0, 239);
781 fl::u8 lo4 = index & 0x0F;
784 const CHSV *entry = &(pal[0]) + hi4;
818 if (sat1 == 0 || val1 == 0) {
824 if (sat2 == 0 || val2 == 0) {
841 if (deltaHue & 0x80) {
843 hue1 -=
scale8(256 - deltaHue, f2);
846 hue1 +=
scale8(deltaHue, f2);
856 return CHSV(hue1, sat1, val1);
861 if (blendType == LINEARBLEND_NOWRAP) {
862 index =
map8(index, 0, 247);
874 fl::u8 lo3 = index & 0x07;
877 const CHSV *entry = (
CHSV *)((
fl::u8 *)(&(pal[0])) + hi5XsizeofCHSV);
911 if (sat1 == 0 || val1 == 0) {
917 if (sat2 == 0 || val2 == 0) {
934 if (deltaHue & 0x80) {
936 hue1 -=
scale8(256 - deltaHue, f2);
939 hue1 +=
scale8(deltaHue, f2);
949 return CHSV(hue1, sat1, val1);
954 CHSV hsv = *(&(pal[0]) + index);
964 class CRGBPalette256 &destpal256) {
965 for (
int i = 0; i < 256; ++i) {
971 class CHSVPalette256 &destpal256) {
972 for (
int i = 0; i < 256; ++i) {
978 class CRGBPalette32 &destpal32) {
979 for (
fl::u8 i = 0; i < 16; ++i) {
981 destpal32[j + 0] = srcpal16[i];
982 destpal32[j + 1] = srcpal16[i];
987 class CHSVPalette32 &destpal32) {
988 for (
fl::u8 i = 0; i < 16; ++i) {
990 destpal32[j + 0] = srcpal16[i];
991 destpal32[j + 1] = srcpal16[i];
996 class CRGBPalette256 &destpal256) {
997 for (
int i = 0; i < 256; ++i) {
1003 class CHSVPalette256 &destpal256) {
1004 for (
int i = 0; i < 256; ++i) {
1011void SetupPartyColors(CRGBPalette16& pal)
1024 p1 = (
fl::u8 *)current.entries;
1025 p2 = (
fl::u8 *)target.entries;
1027 const fl::u8 totalChannels =
sizeof(CRGBPalette16);
1028 for (
fl::u8 i = 0; i < totalChannels; ++i) {
1030 if (p1[i] == p2[i]) {
1035 if (p1[i] < p2[i]) {
1042 if (p1[i] > p2[i]) {
1045 if (p1[i] > p2[i]) {
1051 if (changes >= maxChanges) {
1061 adj = pow(orig, gamma) * (255.0);
1097 for (fl::u16 i = 0; i < count; ++i) {
1103 float gammaG,
float gammaB) {
1104 for (fl::u16 i = 0; i < count; ++i) {
central include file for FastLED, defines the CFastLED class/object
UISlider brightness("Brightness", 128, 0, 255, 1)
@ HUE_PURPLE
Purple (270°)
Result type for promise operations.
@ FORWARD_HUES
Hue always goes clockwise around the color wheel.
@ BACKWARD_HUES
Hue always goes counter-clockwise around the color wheel.
fl::u32 TProgmemRGBPalette32[32]
CRGBPalette32 entries stored in PROGMEM memory.
fl::u32 TProgmemRGBPalette16[16]
CRGBPalette16 entries stored in PROGMEM memory.
UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
#define FL_PGM_READ_DWORD_NEAR(x)
Read a double word (32-bit) from PROGMEM memory.
Utility functions for color fill, palettes, blending, and more.
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.
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.
LIB8STATIC uint8_t blend8(uint8_t a, uint8_t b, uint8_t amountOfB)
Blend a variable proportion (0-255) of one byte to another.
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.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_video_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8_video() does not clean up the R1 register on AVR.
LIB8STATIC void nscale8x3(uint8_t &r, uint8_t &g, uint8_t &b, fract8 scale)
Scale three one-byte values by a fourth one, which is treated as the numerator of a fraction whose de...
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_video(uint8_t i, fract8 scale)
The "video" version of scale8() guarantees that the output will be only be zero if one or both of the...
LIB8STATIC void nscale8x3_video(uint8_t &r, uint8_t &g, uint8_t &b, fract8 scale)
Scale three one-byte values by a fourth one, which is treated as the numerator of a fraction whose de...
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
TGradientDirectionCode
Hue direction for calculating fill gradients.
@ SHORTEST_HUES
Hue goes whichever way is shortest.
@ LONGEST_HUES
Hue goes whichever way is longest.
@ FORWARD_HUES
Hue always goes clockwise around the color wheel.
@ BACKWARD_HUES
Hue always goes counter-clockwise around the color wheel.
void fadeUsingColor(CRGB *leds, fl::u16 numLeds, const CRGB &colormask)
void UpscalePalette(const class CRGBPalette16 &srcpal16, class CRGBPalette256 &destpal256)
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.
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)
fl::u8 lsrX4(fl::u8 dividend)
Helper function to divide a number by 16, aka four logical shift right (LSR)'s.
void fadeLightBy(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy)
CRGB & napplyGamma_video(CRGB &rgb, float gamma)
void nblendPaletteTowardPalette(CRGBPalette16 ¤t, CRGBPalette16 &target, fl::u8 maxChanges)
void nscale8_video(CRGB *leds, fl::u16 num_leds, fl::u8 scale)
Representation of an RGB pixel (Red, Green, Blue)
Representation of an HSV pixel (hue, saturation, value (aka brightness)).