From 78bc566b0640c52e06d8e2b6bbba4214ef0c7683 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 20 Jan 2023 19:04:55 +0000 Subject: [PATCH] Audio palette always start with black - fixes use of palette with Fire effect --- wled00/FX_fcn.cpp | 26 +++++++++++++++----------- wled00/util.cpp | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index a421a57b..2dd65379 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1233,27 +1233,31 @@ uint8_t * Segment::getAudioPalette(int pal) { } uint8_t *fftResult = (uint8_t*)um_data->u_data[2]; - static uint8_t xyz[12]; // Needs to be 4 times however many colors are being used. + static uint8_t xyz[16]; // Needs to be 4 times however many colors are being used. // 3 colors = 12, 4 colors = 16, etc. - CRGB rgb = getCRGBForBand(0, fftResult, pal); - xyz[0] = 0; // anchor of first color - must be zero - xyz[1] = rgb.r; - xyz[2] = rgb.g; - xyz[3] = rgb.b; - - rgb = getCRGBForBand(4, fftResult, pal); - xyz[4] = 128; + xyz[1] = 0; + xyz[2] = 0; + xyz[3] = 0; + + CRGB rgb = getCRGBForBand(1, fftResult, pal); + xyz[4] = 1; // anchor of first color xyz[5] = rgb.r; xyz[6] = rgb.g; xyz[7] = rgb.b; - rgb = getCRGBForBand(8, fftResult, pal); - xyz[8] = 255; // anchor of last color - must be 255 + rgb = getCRGBForBand(4, fftResult, pal); + xyz[8] = 128; xyz[9] = rgb.r; xyz[10] = rgb.g; xyz[11] = rgb.b; + + rgb = getCRGBForBand(8, fftResult, pal); + xyz[12] = 255; // anchor of last color - must be 255 + xyz[13] = rgb.r; + xyz[14] = rgb.g; + xyz[15] = rgb.b; return xyz; } diff --git a/wled00/util.cpp b/wled00/util.cpp index ba636821..9c0d30fc 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -520,7 +520,7 @@ CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal) { CRGB value; CHSV hsv; if(pal == 71) { // bit hacky to use palette id here, but don't want to litter the code with lots of different methods. TODO: add enum for palette creation type - if(x == 0) { + if(x == 1) { value = CRGB(fftResult[10]/2, fftResult[4]/2, fftResult[0]/2); } else if(x == 255) {