Skip to content

Commit e4d832f

Browse files
committed
Merge fix
1 parent 5a67fc7 commit e4d832f

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

wled00/colors.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -119,33 +119,33 @@ IRAM_ATTR_YN __attribute__((hot)) uint32_t color_fade(uint32_t c1, uint8_t amoun
119119

120120

121121
// 1:1 replacement of fastled function optimized for ESP, slightly faster, more accurate and uses less flash (~ -200bytes)
122-
CRGB ColorFromPaletteWLED(const CRGBPalette16& pal, unsigned index, uint8_t brightness, TBlendType blendType)
123-
{
124-
if (blendType == LINEARBLEND_NOWRAP) {
125-
index = (index*240) >> 8; // Blend range is affected by lo4 blend of values, remap to avoid wrapping
126-
}
127-
unsigned hi4 = byte(index) >> 4;
128-
const CRGB* entry = (CRGB*)( (uint8_t*)(&(pal[0])) + (hi4 * sizeof(CRGB)));
129-
unsigned red1 = entry->r;
130-
unsigned green1 = entry->g;
131-
unsigned blue1 = entry->b;
132-
if (blendType != NOBLEND) {
133-
if (hi4 == 15) entry = &(pal[0]);
134-
else ++entry;
135-
unsigned f2 = ((index & 0x0F) << 4) + 1; // +1 so we scale by 256 as a max value, then result can just be shifted by 8
136-
unsigned f1 = (257 - f2); // f2 is 1 minimum, so this is 256 max
137-
red1 = (red1 * f1 + (unsigned)entry->r * f2) >> 8;
138-
green1 = (green1 * f1 + (unsigned)entry->g * f2) >> 8;
139-
blue1 = (blue1 * f1 + (unsigned)entry->b * f2) >> 8;
140-
}
141-
if (brightness < 255) { // note: zero checking could be done to return black but that is hardly ever used so it is omitted
142-
uint32_t scale = brightness + 1; // adjust for rounding (bitshift)
143-
red1 = (red1 * scale) >> 8;
144-
green1 = (green1 * scale) >> 8;
145-
blue1 = (blue1 * scale) >> 8;
146-
}
147-
return CRGB(red1,green1,blue1);
148-
}
122+
// CRGB ColorFromPaletteWLED(const CRGBPalette16& pal, unsigned index, uint8_t brightness, TBlendType blendType)
123+
// {
124+
// if (blendType == LINEARBLEND_NOWRAP) {
125+
// index = (index*240) >> 8; // Blend range is affected by lo4 blend of values, remap to avoid wrapping
126+
// }
127+
// unsigned hi4 = byte(index) >> 4;
128+
// const CRGB* entry = (CRGB*)( (uint8_t*)(&(pal[0])) + (hi4 * sizeof(CRGB)));
129+
// unsigned red1 = entry->r;
130+
// unsigned green1 = entry->g;
131+
// unsigned blue1 = entry->b;
132+
// if (blendType != NOBLEND) {
133+
// if (hi4 == 15) entry = &(pal[0]);
134+
// else ++entry;
135+
// unsigned f2 = ((index & 0x0F) << 4) + 1; // +1 so we scale by 256 as a max value, then result can just be shifted by 8
136+
// unsigned f1 = (257 - f2); // f2 is 1 minimum, so this is 256 max
137+
// red1 = (red1 * f1 + (unsigned)entry->r * f2) >> 8;
138+
// green1 = (green1 * f1 + (unsigned)entry->g * f2) >> 8;
139+
// blue1 = (blue1 * f1 + (unsigned)entry->b * f2) >> 8;
140+
// }
141+
// if (brightness < 255) { // note: zero checking could be done to return black but that is hardly ever used so it is omitted
142+
// uint32_t scale = brightness + 1; // adjust for rounding (bitshift)
143+
// red1 = (red1 * scale) >> 8;
144+
// green1 = (green1 * scale) >> 8;
145+
// blue1 = (blue1 * scale) >> 8;
146+
// }
147+
// return CRGB(red1,green1,blue1);
148+
// }
149149

150150
void setRandomColor(byte* rgb)
151151
{

0 commit comments

Comments
 (0)