Skip to content

Commit

Permalink
Multiple effects running (WIP)
Browse files Browse the repository at this point in the history
AppEffects
- add rowNr to controls parameters (WIP)
- setEffect: set unused controls to -99 (temp, WIP)

AppFixture
- rename ledCounter to indexP,  rename bucket to indexV, prevLeds to prevIndexP
- move these from class to projectAndMap

AppLeds
- setPixelColor, use FastLed blend so overlapping effects work nicely (WIP)

AppModFixture: move on and bri and mheads to here (from AppModLeds)

AppModLeds
- set effect in table (WIP!!)
- add valueFun to table vars

SysModModel
- correct Coord3D subtraction bug
  • Loading branch information
ewowi committed Feb 1, 2024
1 parent 26c0068 commit 61b115c
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 152 deletions.
69 changes: 39 additions & 30 deletions src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class Effect {

virtual void loop(Leds &leds) {}

virtual bool controls(JsonObject parentVar) {return false;}
virtual bool controls(JsonObject parentVar, uint8_t rowNr) {return false;}

void addPalette(JsonObject parentVar) {
void addPalette(JsonObject parentVar, uint8_t rowNr) {
JsonObject currentVar = ui->initSelect(parentVar, "pal", 4, false, [](JsonObject var) { //uiFun.
web->addResponse(var["id"], "label", "Palette");
web->addResponse(var["id"], "comment", "Colors");
Expand Down Expand Up @@ -121,7 +121,7 @@ class SolidEffect: public Effect {
CRGB color = CRGB(red, green, blue);
leds.fill_solid(color);
}
bool controls(JsonObject parentVar) {
bool controls(JsonObject parentVar, uint8_t rowNr) {
ui->initSlider(parentVar, "Red", 182);
ui->initSlider(parentVar, "Green", 15);
ui->initSlider(parentVar, "Blue", 98);
Expand Down Expand Up @@ -171,7 +171,7 @@ class SinelonEffect: public Effect {
leds[pos] = leds.getPixelColor(pos) + CHSV( gHue, 255, 192);
// CRGB x = leds[pos];
}
bool controls(JsonObject parentVar) {
bool controls(JsonObject parentVar, uint8_t rowNr) {
ui->initSlider(parentVar, "BPM", 60);
return true;
}
Expand All @@ -191,7 +191,7 @@ class RunningEffect: public Effect {
leds[pos] = CHSV( gHue, 255, 192); //make sure the right physical leds get their value
// leds[leds.nrOfLeds -1 - pos2] = CHSV( gHue, 255, 192); //make sure the right physical leds get their value
}
bool controls(JsonObject parentVar) {
bool controls(JsonObject parentVar, uint8_t rowNr) {
ui->initSlider(parentVar, "BPM", 60, 0, 255, false, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "comment", "in BPM!");
});
Expand Down Expand Up @@ -227,8 +227,8 @@ class BPMEffect: public Effect {
leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
}
}
bool controls(JsonObject parentVar) {
addPalette(parentVar);
bool controls(JsonObject parentVar, uint8_t rowNr) {
addPalette(parentVar, rowNr);
return false;
}
};
Expand Down Expand Up @@ -272,7 +272,7 @@ class Ripples3DEffect: public Effect {
}
}
}
bool controls(JsonObject parentVar) {
bool controls(JsonObject parentVar, uint8_t rowNr) {
ui->initSlider(parentVar, "interval", 128);
return true;
}
Expand Down Expand Up @@ -334,8 +334,8 @@ class Frizzles2D: public Effect {
}
leds.blur2d(mdl->getValue("blur"));
}
bool controls(JsonObject parentVar) {
addPalette(parentVar);
bool controls(JsonObject parentVar, uint8_t rowNr) {
addPalette(parentVar, rowNr);
ui->initSlider(parentVar, "BPM", 60);
ui->initSlider(parentVar, "intensity", 128);
ui->initSlider(parentVar, "blur", 128);
Expand Down Expand Up @@ -367,7 +367,7 @@ class Lines2D: public Effect {
}
}

bool controls(JsonObject parentVar) {
bool controls(JsonObject parentVar, uint8_t rowNr) {
ui->initSlider(parentVar, "BPM", 60);
ui->initCheckBox(parentVar, "Vertical");
return true;
Expand Down Expand Up @@ -428,7 +428,7 @@ class DistortionWaves2D: public Effect {
}
}
}
bool controls(JsonObject parentVar) {
bool controls(JsonObject parentVar, uint8_t rowNr) {
ui->initSlider(parentVar, "speed", 128);
ui->initSlider(parentVar, "scale", 128);
return true;
Expand Down Expand Up @@ -499,8 +499,8 @@ class Octopus2D: public Effect {
}
}
}
bool controls(JsonObject parentVar) {
addPalette(parentVar);
bool controls(JsonObject parentVar, uint8_t rowNr) {
addPalette(parentVar, rowNr);
ui->initSlider(parentVar, "speed", 128, 1, 255); //start with speed 1
ui->initSlider(parentVar, "Offset X", 128);
ui->initSlider(parentVar, "Offset Y", 128);
Expand Down Expand Up @@ -550,8 +550,8 @@ class Lissajous2D: public Effect {
leds[locn] = ColorFromPalette(palette, now/100+i);
}
}
bool controls(JsonObject parentVar) {
addPalette(parentVar);
bool controls(JsonObject parentVar, uint8_t rowNr) {
addPalette(parentVar, rowNr);
ui->initSlider(parentVar, "X frequency", 64);
ui->initSlider(parentVar, "Fade rate", 128);
ui->initSlider(parentVar, "Speed", 128);
Expand Down Expand Up @@ -635,8 +635,8 @@ class BouncingBalls1D: public Effect {
} //balls
}

bool controls(JsonObject parentVar) {
addPalette(parentVar);
bool controls(JsonObject parentVar, uint8_t rowNr) {
addPalette(parentVar, rowNr);
ui->initSlider(parentVar, "gravity", 128);
ui->initSlider(parentVar, "balls", 8, 1, 16);
return true;
Expand Down Expand Up @@ -771,8 +771,8 @@ class GEQEffect:public Effect {
}
}

bool controls(JsonObject parentVar) {
addPalette(parentVar);
bool controls(JsonObject parentVar, uint8_t rowNr) {
addPalette(parentVar, rowNr);
ui->initSlider(parentVar, "fadeOut", 255);
ui->initSlider(parentVar, "ripple", 128);
ui->initCheckBox(parentVar, "colorBars");
Expand Down Expand Up @@ -832,8 +832,8 @@ class AudioRings:public RingEffect {
setRing(leds, ring, color);
}

bool controls(JsonObject parentVar) {
addPalette(parentVar);
bool controls(JsonObject parentVar, uint8_t rowNr) {
addPalette(parentVar, rowNr);
ui->initCheckBox(parentVar, "inWards");
return true;
}
Expand Down Expand Up @@ -893,7 +893,7 @@ class FreqMatrix:public Effect {
}
}

bool controls(JsonObject parentVar) {
bool controls(JsonObject parentVar, uint8_t rowNr) {
ui->initSlider(parentVar, "Speed", 255);
ui->initSlider(parentVar, "Sound effect", 128);
ui->initSlider(parentVar, "Low bin", 18);
Expand Down Expand Up @@ -1020,12 +1020,21 @@ class Effects {
sharedData.clear(); //make sure all values are 0

// nullify values for this row
// if (rowNr != UINT8_MAX) {
// for (JsonObject var: var["n"].as<JsonArray>()) {
// mdl->setValue(var, -99, rowNr); //unused value for this row, so don't show
// }
// }
// else
if (rowNr != UINT8_MAX) {
for (JsonObject var: var["n"].as<JsonArray>()) {
if (var["value"].is<JsonArray>()) {
var["value"][rowNr] = -99;
} else {
var["value"].to<JsonArray>();
var["value"][rowNr] = -99; //unused value for this row, so don't show
}
// mdl->setValue(var, -99, rowNr); //unused value for this row, so don't show
}
// set all values null for this row

// var.remove("value");
}
else
var.remove("n"); //tbd: we should also remove the uiFun and chFun !!
//tbd: we need to reuse the values set...

Expand All @@ -1046,7 +1055,7 @@ class Effects {
// // var.remove("n"); //tbd: we should also remove the uiFun and chFun !!

Effect* effect = effects[leds.fx];
effect->controls(var); //tbd: add rowNr...
effect->controls(var, rowNr);

effect->setup(leds); //if changed then run setup once (like call==0 in WLED)

Expand Down
Loading

0 comments on commit 61b115c

Please sign in to comment.