diff --git a/wled00/FX.h b/wled00/FX.h index ff8fc22f..bd9ae438 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -633,7 +633,7 @@ typedef struct Segment { void drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w, uint8_t h, CRGB color) {} void wu_pixel(uint32_t x, uint32_t y, CRGB c) {} #endif - CRGBPalette16 getAudioPalette(int pal); //WLEDMM netmindz ar palette + uint8_t * getAudioPalette(int pal); //WLEDMM netmindz ar palette } segment; //static int segSize = sizeof(Segment); diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 8a4b3209..c7ad5967 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -280,7 +280,7 @@ CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) { targetPalette = RainbowStripeColors_p; break; case 71: //WLEDMM netmindz ar palette +1 case 72: //WLEDMM netmindz ar palette +1 - targetPalette = getAudioPalette(pal); break; + targetPalette.loadDynamicGradientPalette(getAudioPalette(pal)); break; default: //progmem palettes if (pal>245) { targetPalette = strip.customPalettes[255-pal]; // we checked bounds above @@ -1141,14 +1141,17 @@ uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_ } //WLEDMM netmindz ar palette -CRGBPalette16 Segment::getAudioPalette(int pal) { +uint8_t * Segment::getAudioPalette(int pal) { + // https://forum.makerforums.info/t/hi-is-it-possible-to-define-a-gradient-palette-at-runtime-the-define-gradient-palette-uses-the/63339 + um_data_t *um_data; if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) { um_data = simulateSound(SEGMENT.soundSim); } uint8_t *fftResult = (uint8_t*)um_data->u_data[2]; - uint8_t xyz[12]; // Needs to be 4 times however many colors are being used. - // 3 colors = 12, 4 colors = 16, etc. + + static uint8_t xyz[12]; // Needs to be 4 times however many colors are being used. + // 3 colors = 12, 4 colors = 16, etc. CRGB rgb = getCRGBForBand(0, fftResult, pal); @@ -1169,7 +1172,7 @@ CRGBPalette16 Segment::getAudioPalette(int pal) { xyz[10] = rgb.g; xyz[11] = rgb.b; - return CRGBPalette16(xyz); + return xyz; }