Skip to content

Commit

Permalink
Post merge
Browse files Browse the repository at this point in the history
Use Variable x = Variable(x)
  • Loading branch information
ewoudwijma committed Sep 12, 2024
1 parent 1101f3e commit 0af2d33
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
20 changes: 12 additions & 8 deletions src/App/LedModEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class LedModEffects:public SysModule {
return true;
case onAddRow: {
rowNr = fixture.layers.size();
// ppf("layerTbl addRow %s[%d]\n", mdl->varID(var), rowNr);
// ppf("layerTbl addRow %s[%d]\n", Variable(var).id(), rowNr);

web->getResponseObject()["addRow"]["rowNr"] = rowNr;

Expand All @@ -175,7 +175,7 @@ class LedModEffects:public SysModule {
}
return true; }
case onDeleteRow: {
// ppf("layerTbl delrow %s[%d]\n", mdl->varID(var), rowNr);
// ppf("layerTbl delrow %s[%d]\n", Variable(var).id(), rowNr);
//tbd: fade to black
if (rowNr <fixture.layers.size()) {
LedsLayer *leds = fixture.layers[rowNr];
Expand Down Expand Up @@ -211,7 +211,7 @@ class LedModEffects:public SysModule {

//create a new leds instance if a new row is created
if (rowNr >= fixture.layers.size()) {
ppf("layers fx[%d] onChange %d %s\n", rowNr, fixture.layers.size(), mdl->findVar("fx")["value"].as<String>().c_str());
ppf("layers fx[%d] onChange %d %s\n", rowNr, fixture.layers.size(), Variable(mdl->findVar("fx")).valueString());
ppf("fx creating new LedsLayer instance %d\n", rowNr);
LedsLayer *leds = new LedsLayer(fixture);
fixture.layers.push_back(leds);
Expand Down Expand Up @@ -249,9 +249,11 @@ class LedModEffects:public SysModule {
leds->effectData.clear(); //delete effectData memory so it can be rebuild
effect->loop(*leds); leds->effectData.begin(); //do a loop to set effectData right

mdl->varPreDetails(var, rowNr);
Variable(var).preDetails();
mdl->setValueRowNr = rowNr;
effect->controls(*leds, var); //set all defaults in effectData
mdl->varPostDetails(var, rowNr);
Variable(var).postDetails(rowNr);
mdl->setValueRowNr = UINT8_MAX;

leds->effectData.alertIfChanged = true; //find out when it is changing, eg when projections change, in that case controls are lost...solution needed for that...

Expand Down Expand Up @@ -311,9 +313,11 @@ class LedModEffects:public SysModule {

leds->projectionData.clear(); //delete effectData memory so it can be rebuild

mdl->varPreDetails(var, rowNr); //set all positive var N orders to negative
Variable(var).preDetails(); //set all positive var N orders to negative
mdl->setValueRowNr = rowNr;
projection->controls(*leds, var);
mdl->varPostDetails(var, rowNr);
Variable(var).postDetails(rowNr);
mdl->setValueRowNr = UINT8_MAX;

leds->projectionData.alertIfChanged = true; //find out when it is changing, eg when projections change, in that case controls are lost...solution needed for that...
}
Expand Down Expand Up @@ -452,7 +456,7 @@ class LedModEffects:public SysModule {

// ui->dashVarChanged = true;
// //rebuild the table
for (JsonObject childVar: mdl->varChildren("e131Tbl"))
for (JsonObject childVar: Variable(mdl->findVar("e131Tbl")).children())
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)

// }
Expand Down
2 changes: 1 addition & 1 deletion src/App/LedModFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LedModFixture:public SysModule {
return true;
case onChange: {
//bri set by StarMod during onChange
stackUnsigned8 result = mdl->getValue("on").as<bool>()?mdl->varLinearToLogarithm(var, bri):0;
stackUnsigned8 result = mdl->getValue("on").as<bool>()?Variable(var).linearToLogarithm(bri):0;

#ifdef STARLIGHT_CLOCKLESS_LED_DRIVER
eff->driver.setBrightness(result * eff->fixture.setMaxPowerBrightness / 256);
Expand Down
7 changes: 4 additions & 3 deletions src/App/LedModFixtureGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ class LedModFixtureGen:public SysModule {
default: return false;
}});

// mdl->varPreDetails(fixtureVar);
// Variable(fixtureVar).preDetails();

bool showTable = true;
JsonObject parentVar = fixtureVar;
Expand Down Expand Up @@ -812,7 +812,7 @@ class LedModFixtureGen:public SysModule {
return true; }
case onChange: {
//set remaining rows to same pin
JsonArray valArray = mdl->varValArray(var);
JsonArray valArray = Variable(var).valArray();

stackUnsigned8 thisVal = var["value"];
stackUnsigned8 rowNrL = 0;
Expand Down Expand Up @@ -866,7 +866,8 @@ class LedModFixtureGen:public SysModule {
}
}

mdl->varPostDetails(fixtureVar, UINT8_MAX);
Variable(fixtureVar).postDetails(UINT8_MAX);
mdl->setValueRowNr = UINT8_MAX;
}

//tbd: move to utility functions
Expand Down

0 comments on commit 0af2d33

Please sign in to comment.