updated setPixelColor() and getPixelColor() functions

uint16_t to unsigned to make it consisten throughout the hand-down.
colorFromPaletteWLED now returns uint32_t which saves the conversion to CRGB and back to uint32_t (in most uses at least).
also added (preliminary) CRGBW struct. I tried to use it in place of uint32_t colors but it adds a lot of overhead when passing the struct so reverted to uint32_t in most places.
updated a few FX to use the CRGBW struct and also cleaned some code to improve flash useage.
This commit is contained in:
Damian Schneider
2024-09-28 15:26:14 +02:00
parent a76a895f1d
commit 7c0fe1285a
8 changed files with 129 additions and 86 deletions

View File

@@ -96,7 +96,7 @@ uint32_t color_fade(uint32_t c1, uint8_t amount, bool video)
}
// 1:1 replacement of fastled function optimized for ESP, slightly faster, more accurate and uses less flash (~ -200bytes)
CRGB ColorFromPaletteWLED(const CRGBPalette16& pal, unsigned index, uint8_t brightness, TBlendType blendType)
uint32_t ColorFromPaletteWLED(const CRGBPalette16& pal, unsigned index, uint8_t brightness, TBlendType blendType)
{
if (blendType == LINEARBLEND_NOWRAP) {
index = (index*240) >> 8; // Blend range is affected by lo4 blend of values, remap to avoid wrapping
@@ -121,7 +121,7 @@ CRGB ColorFromPaletteWLED(const CRGBPalette16& pal, unsigned index, uint8_t brig
green1 = (green1 * scale) >> 8;
blue1 = (blue1 * scale) >> 8;
}
return CRGB((uint8_t)red1, (uint8_t)green1, (uint8_t)blue1);
return RGBW32(red1,green1,blue1,0);
}
void setRandomColor(byte* rgb)