Feature/scale palette fallback (#1484)

* scale color_from_palette fallback by brightnes

* reuse `crgb_to_col` function

Co-authored-by: Florian Baumann <derflob@derflob.de>
pull/1485/head
Florian Baumann 2020-12-13 18:36:18 +01:00 zatwierdzone przez GitHub
rodzic 35998df05c
commit 153e6b56ba
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 13 dodań i 2 usunięć

Wyświetl plik

@ -912,13 +912,24 @@ void WS2812FX::handle_palette(void)
*/
uint32_t WS2812FX::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri)
{
if (SEGMENT.palette == 0 && mcol < 3) return SEGCOLOR(mcol); //WS2812FX default
if (SEGMENT.palette == 0 && mcol < 3) {
uint32_t color = SEGCOLOR(mcol);
if (pbri != 255) {
CRGB crgb_color = col_to_crgb(color);
crgb_color.nscale8_video(pbri);
return crgb_to_col(crgb_color);
} else {
return color;
}
}
uint8_t paletteIndex = i;
if (mapping) paletteIndex = (i*255)/(SEGLEN -1);
if (!wrap) paletteIndex = scale8(paletteIndex, 240); //cut off blend at palette "end"
CRGB fastled_col;
fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND);
return fastled_col.r*65536 + fastled_col.g*256 + fastled_col.b;
return crgb_to_col(fastled_col);
}
//@returns `true` if color, mode, speed, intensity and palette match