Add second audio responsive palette
This commit is contained in:
@@ -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 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) {}
|
void wu_pixel(uint32_t x, uint32_t y, CRGB c) {}
|
||||||
#endif
|
#endif
|
||||||
CRGBPalette16 getAudioPalette(); //WLEDMM netmindz ar palette
|
CRGBPalette16 getAudioPalette(int pal); //WLEDMM netmindz ar palette
|
||||||
} segment;
|
} segment;
|
||||||
//static int segSize = sizeof(Segment);
|
//static int segSize = sizeof(Segment);
|
||||||
|
|
||||||
|
|||||||
@@ -279,7 +279,8 @@ CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
|
|||||||
case 12: //Rainbow stripe colors
|
case 12: //Rainbow stripe colors
|
||||||
targetPalette = RainbowStripeColors_p; break;
|
targetPalette = RainbowStripeColors_p; break;
|
||||||
case 71: //WLEDMM netmindz ar palette +1
|
case 71: //WLEDMM netmindz ar palette +1
|
||||||
targetPalette = getAudioPalette(); break;
|
case 72: //WLEDMM netmindz ar palette +1
|
||||||
|
targetPalette = getAudioPalette(pal); break;
|
||||||
default: //progmem palettes
|
default: //progmem palettes
|
||||||
if (pal>245) {
|
if (pal>245) {
|
||||||
targetPalette = strip.customPalettes[255-pal]; // we checked bounds above
|
targetPalette = strip.customPalettes[255-pal]; // we checked bounds above
|
||||||
@@ -1140,7 +1141,7 @@ uint32_t Segment::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_
|
|||||||
}
|
}
|
||||||
|
|
||||||
//WLEDMM netmindz ar palette
|
//WLEDMM netmindz ar palette
|
||||||
CRGBPalette16 Segment::getAudioPalette() {
|
CRGBPalette16 Segment::getAudioPalette(int pal) {
|
||||||
um_data_t *um_data;
|
um_data_t *um_data;
|
||||||
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
if (!usermods.getUMData(&um_data, USERMOD_ID_AUDIOREACTIVE)) {
|
||||||
um_data = simulateSound(SEGMENT.soundSim);
|
um_data = simulateSound(SEGMENT.soundSim);
|
||||||
@@ -1149,20 +1150,20 @@ CRGBPalette16 Segment::getAudioPalette() {
|
|||||||
uint8_t xyz[12]; // Needs to be 4 times however many colors are being used.
|
uint8_t xyz[12]; // Needs to be 4 times however many colors are being used.
|
||||||
// 3 colors = 12, 4 colors = 16, etc.
|
// 3 colors = 12, 4 colors = 16, etc.
|
||||||
|
|
||||||
CRGB rgb = getCRGBForBand(0, fftResult);
|
CRGB rgb = getCRGBForBand(0, fftResult, pal);
|
||||||
|
|
||||||
xyz[0] = 0; // anchor of first color - must be zero
|
xyz[0] = 0; // anchor of first color - must be zero
|
||||||
xyz[1] = rgb.r;
|
xyz[1] = rgb.r;
|
||||||
xyz[2] = rgb.g;
|
xyz[2] = rgb.g;
|
||||||
xyz[3] = rgb.b;
|
xyz[3] = rgb.b;
|
||||||
|
|
||||||
rgb = getCRGBForBand(4, fftResult);
|
rgb = getCRGBForBand(4, fftResult, pal);
|
||||||
xyz[4] = 128;
|
xyz[4] = 128;
|
||||||
xyz[5] = rgb.r;
|
xyz[5] = rgb.r;
|
||||||
xyz[6] = rgb.g;
|
xyz[6] = rgb.g;
|
||||||
xyz[7] = rgb.b;
|
xyz[7] = rgb.b;
|
||||||
|
|
||||||
rgb = getCRGBForBand(8, fftResult);
|
rgb = getCRGBForBand(8, fftResult, pal);
|
||||||
xyz[8] = 255; // anchor of last color - must be 255
|
xyz[8] = 255; // anchor of last color - must be 255
|
||||||
xyz[9] = rgb.r;
|
xyz[9] = rgb.r;
|
||||||
xyz[10] = rgb.g;
|
xyz[10] = rgb.g;
|
||||||
@@ -1883,5 +1884,5 @@ const char JSON_palette_names[] PROGMEM = R"=====([
|
|||||||
"Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura",
|
"Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura",
|
||||||
"Aurora","Atlantica","C9 2","C9 New","Temperature","Aurora 2","Retro Clown","Candy","Toxy Reaf","Fairy Reaf",
|
"Aurora","Atlantica","C9 2","C9 New","Temperature","Aurora 2","Retro Clown","Candy","Toxy Reaf","Fairy Reaf",
|
||||||
"Semi Blue","Pink Candy","Red Reaf","Aqua Flash","Yelblu Hot","Lite Light","Red Flash","Blink Red","Red Shift","Red Tide",
|
"Semi Blue","Pink Candy","Red Reaf","Aqua Flash","Yelblu Hot","Lite Light","Red Flash","Blink Red","Red Shift","Red Tide",
|
||||||
"Candy2","Audio Responsive"
|
"Candy2","Audio Responsive Hue","Audio Responsive Ratio"
|
||||||
])=====";
|
])=====";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Readability defines and their associated numerical values + compile-time constants
|
* Readability defines and their associated numerical values + compile-time constants
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define GRADIENT_PALETTE_COUNT 59 //WLEDMM netmindz ar palette +1
|
#define GRADIENT_PALETTE_COUNT 60 //WLEDMM netmindz ar palette +2
|
||||||
|
|
||||||
//Defaults
|
//Defaults
|
||||||
#define DEFAULT_CLIENT_SSID "Your_Network"
|
#define DEFAULT_CLIENT_SSID "Your_Network"
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ int16_t extractModeDefaults(uint8_t mode, const char *segVar);
|
|||||||
uint16_t crc16(const unsigned char* data_p, size_t length);
|
uint16_t crc16(const unsigned char* data_p, size_t length);
|
||||||
um_data_t* simulateSound(uint8_t simulationId);
|
um_data_t* simulateSound(uint8_t simulationId);
|
||||||
void enumerateLedmaps();
|
void enumerateLedmaps();
|
||||||
CRGB getCRGBForBand(int x, uint8_t *fftResult); //WLEDMM netmindz ar palette
|
CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal); //WLEDMM netmindz ar palette
|
||||||
|
|
||||||
#ifdef WLED_ADD_EEPROM_SUPPORT
|
#ifdef WLED_ADD_EEPROM_SUPPORT
|
||||||
//wled_eeprom.cpp
|
//wled_eeprom.cpp
|
||||||
|
|||||||
@@ -915,7 +915,9 @@ const byte* const gGradientPalettes[] PROGMEM = {
|
|||||||
red_shift_gp, //68-55 Red Shift
|
red_shift_gp, //68-55 Red Shift
|
||||||
red_tide_gp, //69-56 Red Tide
|
red_tide_gp, //69-56 Red Tide
|
||||||
candy2_gp, //70-57 Candy2
|
candy2_gp, //70-57 Candy2
|
||||||
audio_responsive_gp, //71-58 AudioResponsive WLEDMM netmindz ar palette
|
// Palette contents not actually used as built on the fly, just here to create menu option
|
||||||
|
audio_responsive_gp, //71-58 AudioResponsive WLEDMM netmindz ar palette - placeholder1
|
||||||
|
audio_responsive_gp, //72-59 AudioResponsive WLEDMM netmindz ar palette - placeholder2
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -516,17 +516,24 @@ void enumerateLedmaps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//WLEDMM netmindz ar palette
|
//WLEDMM netmindz ar palette
|
||||||
CRGB getCRGBForBand(int x, uint8_t *fftResult) {
|
CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal) {
|
||||||
CRGB value;
|
CRGB value;
|
||||||
CHSV hsv;
|
CHSV hsv;
|
||||||
if(x == 0) {
|
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
|
||||||
value = CRGB(fftResult[10]/2, fftResult[4]/2, fftResult[0]/2);
|
if(x == 0) {
|
||||||
|
value = CRGB(fftResult[10]/2, fftResult[4]/2, fftResult[0]/2);
|
||||||
|
}
|
||||||
|
else if(x == 255) {
|
||||||
|
value = CRGB(fftResult[10]/2, fftResult[0]/2, fftResult[4]/2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
value = CRGB(fftResult[0]/2, fftResult[4]/2, fftResult[10]/2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(pal == 72) {
|
||||||
|
int b = map(x, 0, 255, 0, 16); // convert palette position to freq band
|
||||||
|
hsv = CHSV(fftResult[b], 255, map(fftResult[b], 0, 255, 50, 255)); // pick hue
|
||||||
|
hsv2rgb_rainbow(hsv, value); // convert to R,G,B
|
||||||
}
|
}
|
||||||
else if(x == 255) {
|
|
||||||
value = CRGB(fftResult[10]/2, fftResult[0]/2, fftResult[4]/2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
value = CRGB(fftResult[0]/2, fftResult[4]/2, fftResult[10]/2);
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user