Skip to content

Commit

Permalink
Add Waverly2D effect + default 50% blending of effects
Browse files Browse the repository at this point in the history
  • Loading branch information
ewowi committed Feb 15, 2024
1 parent 7f3d047 commit b22e0b2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
46 changes: 46 additions & 0 deletions src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,51 @@ class ScrollingText2D: public Effect {
};


class Waverly2D: public Effect {
public:
const char * name() {
return "Waverly 2D";
}

void loop(Leds &leds) {
CRGBPalette16 pal = getPalette(leds.rowNr);
uint8_t amplification = mdl->getValue("Amplification", leds.rowNr);
uint8_t sensitivity = mdl->getValue("Sensitivity", leds.rowNr);
bool noClouds = mdl->getValue("No Clouds", leds.rowNr);
// bool soundPressure = mdl->getValue("Sound Pressure", leds.rowNr);
// bool agcDebug = mdl->getValue("AGC debug", leds.rowNr);

leds.fadeToBlackBy(amplification);
// if (agcDebug && soundPressure) soundPressure = false; // only one of the two at any time
// if ((soundPressure) && (wledAudioMod->sync.volumeSmth > 0.5f)) wledAudioMod->sync.volumeSmth = wledAudioMod->sync.soundPressure; // show sound pressure instead of volume
// if (agcDebug) wledAudioMod->sync.volumeSmth = 255.0 - wledAudioMod->sync.agcSensitivity; // show AGC level instead of volume

long t = now / 2;
Coord3D pos;
for (pos.x = 0; pos.x < leds.size.x; pos.x++) {
uint16_t thisVal = wledAudioMod->sync.volumeSmth*sensitivity/64 * inoise8(pos.x * 45 , t , t)/64; // WLEDMM back to SR code
uint16_t thisMax = min(map(thisVal, 0, 512, 0, leds.size.y), (long)leds.size.x);

for (pos.y = 0; pos.y < thisMax; pos.y++) {
if (!noClouds)
leds.addPixelColor(pos, ColorFromPalette(pal, map(pos.y, 0, thisMax, 250, 0), 255, LINEARBLEND));
leds.addPixelColor(leds.XY((leds.size.x - 1) - pos.x, (leds.size.y - 1) - pos.y), ColorFromPalette(pal, map(pos.y, 0, thisMax, 250, 0), 255, LINEARBLEND));
}
}
leds.blur2d(16);

}
void controls(JsonObject parentVar, Leds &leds) {
addPalette(parentVar, 4);
ui->initSlider(parentVar, "Amplification", 128);
ui->initSlider(parentVar, "Sensitivity", 128);
ui->initCheckBox(parentVar, "No Clouds");
// ui->initCheckBox(parentVar, "Sound Pressure");
// ui->initCheckBox(parentVar, "AGC debug");
}
};


#ifdef STARMOD_USERMOD_WLEDAUDIO

class GEQEffect:public Effect {
Expand Down Expand Up @@ -973,6 +1018,7 @@ class Effects {
effects.push_back(new BouncingBalls1D);
effects.push_back(new RingRandomFlow);
effects.push_back(new ScrollingText2D);
effects.push_back(new Waverly2D);
#ifdef STARMOD_USERMOD_WLEDAUDIO
effects.push_back(new GEQEffect);
effects.push_back(new AudioRings);
Expand Down
10 changes: 5 additions & 5 deletions src/App/AppLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ class Leds {


// maps the virtual led to the physical led(s) and assign a color to it
void setPixelColor(uint16_t indexV, CRGB color, uint8_t blendAmount = 0);
void setPixelColor(Coord3D pixel, CRGB color, uint8_t blendAmount = 0) {setPixelColor(XYZ(pixel), color, blendAmount);}
void setPixelColor(uint16_t indexV, CRGB color, uint8_t blendAmount = 128);
void setPixelColor(Coord3D pixel, CRGB color, uint8_t blendAmount = 128) {setPixelColor(XYZ(pixel), color, blendAmount);}

CRGB getPixelColor(uint16_t indexV);
CRGB getPixelColor(Coord3D pixel) {return getPixelColor(XYZ(pixel));}

void addPixelColor(uint16_t indexV, CRGB color) {
setPixelColor(indexV, getPixelColor(indexV) + color);
}
void addPixelColor(uint16_t indexV, CRGB color) {setPixelColor(indexV, getPixelColor(indexV) + color);}
void addPixelColor(Coord3D pixel, CRGB color) {setPixelColor(pixel, getPixelColor(pixel) + color);}

void fadeToBlackBy(uint8_t fadeBy = 255);
void fill_solid(const struct CRGB& color);
Expand Down

0 comments on commit b22e0b2

Please sign in to comment.