mirror of
https://github.com/wled/WLED.git
synced 2025-07-13 22:06:31 +00:00
consolidated colorwaves and pride into one base function
the two FX are almost identical in code with just a few lines difference.
This commit is contained in:
parent
566c5057f9
commit
aab29cb0ab
@ -1893,22 +1893,20 @@ uint16_t mode_lightning(void) {
|
|||||||
}
|
}
|
||||||
static const char _data_FX_MODE_LIGHTNING[] PROGMEM = "Lightning@!,!,,,,,Overlay;!,!;!";
|
static const char _data_FX_MODE_LIGHTNING[] PROGMEM = "Lightning@!,!,,,,,Overlay;!,!;!";
|
||||||
|
|
||||||
|
// combined function from original pride and colorwaves
|
||||||
// Pride2015
|
uint16_t mode_colorwaves_pride_base(bool isPride2015) {
|
||||||
// Animated, ever-changing rainbows.
|
|
||||||
// by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5
|
|
||||||
uint16_t mode_pride_2015(void) {
|
|
||||||
unsigned duration = 10 + SEGMENT.speed;
|
unsigned duration = 10 + SEGMENT.speed;
|
||||||
unsigned sPseudotime = SEGENV.step;
|
unsigned sPseudotime = SEGENV.step;
|
||||||
unsigned sHue16 = SEGENV.aux0;
|
unsigned sHue16 = SEGENV.aux0;
|
||||||
|
|
||||||
uint8_t sat8 = beatsin88_t( 87, 220, 250);
|
uint8_t sat8 = isPride2015 ? beatsin88_t(87, 220, 250) : 255;
|
||||||
uint8_t brightdepth = beatsin88_t( 341, 96, 224);
|
unsigned brightdepth = beatsin88_t(341, 96, 224);
|
||||||
unsigned brightnessthetainc16 = beatsin88_t(203, (25 * 256), (40 * 256));
|
unsigned brightnessthetainc16 = beatsin88_t(203, (25 * 256), (40 * 256));
|
||||||
unsigned msmultiplier = beatsin88_t(147, 23, 60);
|
unsigned msmultiplier = beatsin88_t(147, 23, 60);
|
||||||
|
|
||||||
unsigned hue16 = sHue16;//gHue * 256;
|
unsigned hue16 = sHue16;
|
||||||
unsigned hueinc16 = beatsin88_t(113, 1, 3000);
|
unsigned hueinc16 = isPride2015 ? beatsin88_t(113, 1, 3000) :
|
||||||
|
beatsin88_t(113, 60, 300) * SEGMENT.intensity * 10 / 255;
|
||||||
|
|
||||||
sPseudotime += duration * msmultiplier;
|
sPseudotime += duration * msmultiplier;
|
||||||
sHue16 += duration * beatsin88_t(400, 5, 9);
|
sHue16 += duration * beatsin88_t(400, 5, 9);
|
||||||
@ -1916,25 +1914,51 @@ uint16_t mode_pride_2015(void) {
|
|||||||
|
|
||||||
for (unsigned i = 0; i < SEGLEN; i++) {
|
for (unsigned i = 0; i < SEGLEN; i++) {
|
||||||
hue16 += hueinc16;
|
hue16 += hueinc16;
|
||||||
uint8_t hue8 = hue16 >> 8;
|
uint8_t hue8;
|
||||||
|
|
||||||
|
if (isPride2015) {
|
||||||
|
hue8 = hue16 >> 8;
|
||||||
|
} else {
|
||||||
|
unsigned h16_128 = hue16 >> 7;
|
||||||
|
hue8 = (h16_128 & 0x100) ? (255 - (h16_128 >> 1)) : (h16_128 >> 1);
|
||||||
|
}
|
||||||
|
|
||||||
brightnesstheta16 += brightnessthetainc16;
|
brightnesstheta16 += brightnessthetainc16;
|
||||||
unsigned b16 = sin16_t(brightnesstheta16) + 32768;
|
unsigned b16 = sin16_t(brightnesstheta16) + 32768;
|
||||||
|
|
||||||
unsigned bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
unsigned bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
||||||
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
||||||
bri8 += (255 - brightdepth);
|
bri8 += (255 - brightdepth);
|
||||||
|
|
||||||
|
if (isPride2015) {
|
||||||
CRGB newcolor = CHSV(hue8, sat8, bri8);
|
CRGB newcolor = CHSV(hue8, sat8, bri8);
|
||||||
SEGMENT.blendPixelColor(i, newcolor, 64);
|
SEGMENT.blendPixelColor(i, newcolor, 64);
|
||||||
|
} else {
|
||||||
|
SEGMENT.blendPixelColor(i, SEGMENT.color_from_palette(hue8, false, PALETTE_SOLID_WRAP, 0, bri8), 128);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SEGENV.step = sPseudotime;
|
SEGENV.step = sPseudotime;
|
||||||
SEGENV.aux0 = sHue16;
|
SEGENV.aux0 = sHue16;
|
||||||
|
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pride2015
|
||||||
|
// Animated, ever-changing rainbows.
|
||||||
|
// by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5
|
||||||
|
uint16_t mode_pride_2015(void) {
|
||||||
|
return mode_colorwaves_pride_base(true);
|
||||||
|
}
|
||||||
static const char _data_FX_MODE_PRIDE_2015[] PROGMEM = "Pride 2015@!;;";
|
static const char _data_FX_MODE_PRIDE_2015[] PROGMEM = "Pride 2015@!;;";
|
||||||
|
|
||||||
|
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
|
||||||
|
// This function draws color waves with an ever-changing,
|
||||||
|
// widely-varying set of parameters, using a color palette.
|
||||||
|
uint16_t mode_colorwaves() {
|
||||||
|
return mode_colorwaves_pride_base(false);
|
||||||
|
}
|
||||||
|
static const char _data_FX_MODE_COLORWAVES[] PROGMEM = "Colorwaves@!,Hue;!;!;;pal=26";
|
||||||
|
|
||||||
|
|
||||||
//eight colored dots, weaving in and out of sync with each other
|
//eight colored dots, weaving in and out of sync with each other
|
||||||
uint16_t mode_juggle(void) {
|
uint16_t mode_juggle(void) {
|
||||||
@ -2141,53 +2165,6 @@ uint16_t mode_fire_2012() {
|
|||||||
}
|
}
|
||||||
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate,,2D Blur,Boost;;!;1;pal=35,sx=64,ix=160,m12=1,c2=128"; // bars
|
static const char _data_FX_MODE_FIRE_2012[] PROGMEM = "Fire 2012@Cooling,Spark rate,,2D Blur,Boost;;!;1;pal=35,sx=64,ix=160,m12=1,c2=128"; // bars
|
||||||
|
|
||||||
|
|
||||||
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
|
|
||||||
// This function draws color waves with an ever-changing,
|
|
||||||
// widely-varying set of parameters, using a color palette.
|
|
||||||
uint16_t mode_colorwaves() {
|
|
||||||
unsigned duration = 10 + SEGMENT.speed;
|
|
||||||
unsigned sPseudotime = SEGENV.step;
|
|
||||||
unsigned sHue16 = SEGENV.aux0;
|
|
||||||
|
|
||||||
unsigned brightdepth = beatsin88_t(341, 96, 224);
|
|
||||||
unsigned brightnessthetainc16 = beatsin88_t( 203, (25 * 256), (40 * 256));
|
|
||||||
unsigned msmultiplier = beatsin88_t(147, 23, 60);
|
|
||||||
|
|
||||||
unsigned hue16 = sHue16;//gHue * 256;
|
|
||||||
unsigned hueinc16 = beatsin88_t(113, 60, 300)*SEGMENT.intensity*10/255; // Use the Intensity Slider for the hues
|
|
||||||
|
|
||||||
sPseudotime += duration * msmultiplier;
|
|
||||||
sHue16 += duration * beatsin88_t(400, 5, 9);
|
|
||||||
unsigned brightnesstheta16 = sPseudotime;
|
|
||||||
|
|
||||||
for (unsigned i = 0 ; i < SEGLEN; i++) {
|
|
||||||
hue16 += hueinc16;
|
|
||||||
uint8_t hue8 = hue16 >> 8;
|
|
||||||
unsigned h16_128 = hue16 >> 7;
|
|
||||||
if ( h16_128 & 0x100) {
|
|
||||||
hue8 = 255 - (h16_128 >> 1);
|
|
||||||
} else {
|
|
||||||
hue8 = h16_128 >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
brightnesstheta16 += brightnessthetainc16;
|
|
||||||
unsigned b16 = sin16_t(brightnesstheta16) + 32768;
|
|
||||||
|
|
||||||
unsigned bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
|
||||||
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
|
||||||
bri8 += (255 - brightdepth);
|
|
||||||
|
|
||||||
SEGMENT.blendPixelColor(i, SEGMENT.color_from_palette(hue8, false, PALETTE_SOLID_WRAP, 0, bri8), 128); // 50/50 mix
|
|
||||||
}
|
|
||||||
SEGENV.step = sPseudotime;
|
|
||||||
SEGENV.aux0 = sHue16;
|
|
||||||
|
|
||||||
return FRAMETIME;
|
|
||||||
}
|
|
||||||
static const char _data_FX_MODE_COLORWAVES[] PROGMEM = "Colorwaves@!,Hue;!;!;;pal=26";
|
|
||||||
|
|
||||||
|
|
||||||
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
|
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
|
||||||
uint16_t mode_bpm() {
|
uint16_t mode_bpm() {
|
||||||
uint32_t stp = (strip.now / 20) & 0xFF;
|
uint32_t stp = (strip.now / 20) & 0xFF;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user