Skip to content

Commit

Permalink
Further prep for multiple fx, refactor genHTML and changeHTML
Browse files Browse the repository at this point in the history
index.js: generateHTML:
- swap parameters
- if then else uniform (WIP)

index.js: processVarNode:
- rename to changeHTML
- remove key parameter (=node.id)

AppEffects: setEffect: support multiple fx

AppLedsV: add fx parameter (prepare for multiple fx)

AppModLeds: init fx: support multiple effects
  • Loading branch information
ewowi committed Dec 17, 2023
1 parent 6182310 commit a7f9b38
Show file tree
Hide file tree
Showing 8 changed files with 1,640 additions and 1,726 deletions.
471 changes: 240 additions & 231 deletions data/index.js

Large diffs are not rendered by default.

65 changes: 34 additions & 31 deletions src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -955,32 +955,32 @@ class Effects {
// for (Effect *effect:effects) {
// USER_PRINTF("Size of %s is %d\n", effect->name(), sizeof(*effect));
// }
USER_PRINTF("Size of %s is %d\n", "RainbowEffect", sizeof(RainbowEffect));
USER_PRINTF("Size of %s is %d\n", "RainbowWithGlitterEffect", sizeof(RainbowWithGlitterEffect));
USER_PRINTF("Size of %s is %d\n", "SinelonEffect", sizeof(SinelonEffect));
USER_PRINTF("Size of %s is %d\n", "RunningEffect", sizeof(RunningEffect));
USER_PRINTF("Size of %s is %d\n", "ConfettiEffect", sizeof(ConfettiEffect));
USER_PRINTF("Size of %s is %d\n", "BPMEffect", sizeof(BPMEffect));
USER_PRINTF("Size of %s is %d\n", "JuggleEffect", sizeof(JuggleEffect));
USER_PRINTF("Size of %s is %d\n", "Ripples3DEffect", sizeof(Ripples3DEffect));
USER_PRINTF("Size of %s is %d\n", "SphereMove3DEffect", sizeof(SphereMove3DEffect));
USER_PRINTF("Size of %s is %d\n", "Frizzles2D", sizeof(Frizzles2D));
USER_PRINTF("Size of %s is %d\n", "Lines2D", sizeof(Lines2D));
USER_PRINTF("Size of %s is %d\n", "DistortionWaves2D", sizeof(DistortionWaves2D));
USER_PRINTF("Size of %s is %d\n", "Octopus2D", sizeof(Octopus2D));
USER_PRINTF("Size of %s is %d\n", "Lissajous2D", sizeof(Lissajous2D));
USER_PRINTF("Size of %s is %d\n", "BouncingBalls1D", sizeof(BouncingBalls1D));
USER_PRINTF("Size of %s is %d\n", "RingRandomFlow", sizeof(RingRandomFlow));
#ifdef USERMOD_WLEDAUDIO
USER_PRINTF("Size of %s is %d\n", "GEQEffect", sizeof(GEQEffect));
USER_PRINTF("Size of %s is %d\n", "AudioRings", sizeof(AudioRings));
#endif
}

void loop(size_t index) {
// USER_PRINTF("Size of %s is %d\n", "RainbowEffect", sizeof(RainbowEffect));
// USER_PRINTF("Size of %s is %d\n", "RainbowWithGlitterEffect", sizeof(RainbowWithGlitterEffect));
// USER_PRINTF("Size of %s is %d\n", "SinelonEffect", sizeof(SinelonEffect));
// USER_PRINTF("Size of %s is %d\n", "RunningEffect", sizeof(RunningEffect));
// USER_PRINTF("Size of %s is %d\n", "ConfettiEffect", sizeof(ConfettiEffect));
// USER_PRINTF("Size of %s is %d\n", "BPMEffect", sizeof(BPMEffect));
// USER_PRINTF("Size of %s is %d\n", "JuggleEffect", sizeof(JuggleEffect));
// USER_PRINTF("Size of %s is %d\n", "Ripples3DEffect", sizeof(Ripples3DEffect));
// USER_PRINTF("Size of %s is %d\n", "SphereMove3DEffect", sizeof(SphereMove3DEffect));
// USER_PRINTF("Size of %s is %d\n", "Frizzles2D", sizeof(Frizzles2D));
// USER_PRINTF("Size of %s is %d\n", "Lines2D", sizeof(Lines2D));
// USER_PRINTF("Size of %s is %d\n", "DistortionWaves2D", sizeof(DistortionWaves2D));
// USER_PRINTF("Size of %s is %d\n", "Octopus2D", sizeof(Octopus2D));
// USER_PRINTF("Size of %s is %d\n", "Lissajous2D", sizeof(Lissajous2D));
// USER_PRINTF("Size of %s is %d\n", "BouncingBalls1D", sizeof(BouncingBalls1D));
// USER_PRINTF("Size of %s is %d\n", "RingRandomFlow", sizeof(RingRandomFlow));
// #ifdef USERMOD_WLEDAUDIO
// USER_PRINTF("Size of %s is %d\n", "GEQEffect", sizeof(GEQEffect));
// USER_PRINTF("Size of %s is %d\n", "AudioRings", sizeof(AudioRings));
// #endif
}

void loop(uint8_t fx) {
now = millis(); //tbd timebase

effects[index%effects.size()]->loop();
effects[fx%effects.size()]->loop();

call++;

Expand All @@ -991,23 +991,26 @@ class Effects {
return effects.size();
}

bool setEffect(JsonObject parentVar) {
bool setEffect(JsonObject parentVar, uint8_t rowNr) {
bool doMap = false;

uint8_t fx = parentVar["value"];
if (rowNr == uint8Max)
ledsV.fx = parentVar["value"];
else
ledsV.fx = parentVar["value"][rowNr];

USER_PRINTF("setEffect %d %d %d \n", fx, effects.size(), size());
USER_PRINTF("setEffect %d\n", ledsV.fx);

if (fx < size()) {
if (ledsV.fx < size()) {

//tbd: make property of effects
if (strstr(effects[fx]->name(), "2D")) {
if (strstr(effects[ledsV.fx]->name(), "2D")) {
if (ledsV.effectDimension != 2) {
ledsV.effectDimension = 2;
doMap = true;
}
}
else if (strstr(effects[fx]->name(), "3D")) {
else if (strstr(effects[ledsV.fx]->name(), "3D")) {
if (ledsV.effectDimension != 3) {
ledsV.effectDimension = 3;
doMap = true;
Expand All @@ -1024,7 +1027,7 @@ class Effects {

parentVar.remove("n"); //tbd: we should also remove the uiFun and chFun !!

Effect* effect = effects[fx];
Effect* effect = effects[ledsV.fx];
effect->controls(parentVar);

effect->setup(); //if changed then run setup once (like call==0 in WLED)
Expand Down
1 change: 1 addition & 0 deletions src/App/AppLedsV.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class LedsV {
uint16_t heightV = 8;
uint16_t depthV = 1;

uint8_t fx = -1;
uint8_t projectionNr = -1;
uint8_t fixtureNr = -1;
uint8_t effectDimension = -1;
Expand Down
6 changes: 3 additions & 3 deletions src/App/AppModLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class AppModLeds:public SysModule {
for (Effect *effect:effects.effects) {
select.add(effect->name());
}
}, [this](JsonObject var, uint8_t) { //chFun
doMap = effects.setEffect(var);
}, [this](JsonObject var, uint8_t rowNr) { //chFun
doMap = effects.setEffect(var, rowNr);
});
currentVar["stage"] = true;

Expand Down Expand Up @@ -232,7 +232,7 @@ class AppModLeds:public SysModule {
//for each programmed effect
// run the next frame of the effect

effects.loop(mdl->getValue("fx"));
effects.loop(ledsV.fx);

FastLED.show();

Expand Down
6 changes: 3 additions & 3 deletions src/Sys/SysModUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ JsonObject SysModUI::initVar(JsonObject parent, const char * id, const char * ty
}
var["id"] = (char *)id; //create a copy!
}
else {
USER_PRINTF("initVar Var %s->%s already defined\n", modelParentId, id);
}
// else {
// USER_PRINTF("initVar Var %s->%s already defined\n", modelParentId, id);
// }

if (!var.isNull()) {
if (var["type"] != type)
Expand Down
4 changes: 2 additions & 2 deletions src/User/UserModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ class UserModInstances:public SysModule {
}

node->app.setVar("bri", wledSyncMessage.bri);
node->app.setVar("fx", wledSyncMessage.mainsegMode);
node->app.setVar("pal", wledSyncMessage.palette);
node->app.setVar("fx", wledSyncMessage.mainsegMode); //tbd: rowNr
node->app.setVar("pal", wledSyncMessage.palette); //tbd: rowNr

// for (size_t x = 0; x < packetSize; x++) {
// char xx = (char)udpIn[x];
Expand Down
Loading

0 comments on commit a7f9b38

Please sign in to comment.