Skip to content

Commit

Permalink
Rename fxTbl to ledsTbl
Browse files Browse the repository at this point in the history
- rename fxTbl to ledsTbl
- rename fxStart to ledsStart
- rename fxEnd to ledsEnd
- rename fxSize to ledsSize

LedModFixture
- fixSize / fixCount as value by reference (remove onSetValue)
  • Loading branch information
ewoudwijma committed Jun 26, 2024
1 parent 1929652 commit c80b22a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
8 changes: 4 additions & 4 deletions src/App/LedFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void Fixture::projectAndMap() {
Coord3D endPosAdjusted = (leds->endPos).minimum(fixSize - Coord3D{1,1,1}) * 10;
Coord3D midPosAdjusted = (leds->midPos).minimum(fixSize - Coord3D{1,1,1}); //not * 10

// mdl->setValue("fxStart", startPosAdjusted/10, rowNr); //rowNr
// mdl->setValue("fxEnd", endPosAdjusted/10, rowNr); //rowNr
// mdl->setValue("ledsStart", startPosAdjusted/10, rowNr); //rowNr
// mdl->setValue("ledsEnd", endPosAdjusted/10, rowNr); //rowNr

if (pixel >= startPosAdjusted && pixel <= endPosAdjusted ) { //if pixel between start and end pos

Expand Down Expand Up @@ -413,10 +413,10 @@ void Fixture::projectAndMap() {

ppf("projectAndMap leds[%d] V:%d x %d x %d -> %d (v:%d - p:%d)\n", rowNr, leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds, nrOfMappings, nrOfPixels);

// mdl->setValueV("fxSize", rowNr, "%d x %d x %d = %d", leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds);
// mdl->setValueV("ledsSize", rowNr, "%d x %d x %d = %d", leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds);
char buf[32];
print->fFormat(buf, sizeof(buf)-1,"%d x %d x %d -> %d", leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds);
mdl->setValue("fxSize", JsonString(buf, JsonString::Copied), rowNr);
mdl->setValue("ledsSize", JsonString(buf, JsonString::Copied), rowNr);
// web->sendResponseObject();

ppf("projectAndMap leds[%d].size = %d + %d\n", rowNr, sizeof(Leds), leds->mappingTable.size()); //44
Expand Down
38 changes: 19 additions & 19 deletions src/App/LedModEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,22 @@ class LedModEffects:public SysModule {

JsonObject currentVar;

JsonObject tableVar = ui->initTable(parentVar, "fxTbl", nullptr, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
JsonObject tableVar = ui->initTable(parentVar, "ledsTbl", nullptr, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onUI:
ui->setLabel(var, "Effects");
ui->setComment(var, "List of effects");
return true;
case onAddRow: {
rowNr = fixture.listOfLeds.size();
// ppf("fxTbl addRow %s[%d]\n", mdl->varID(var), rowNr);
// ppf("ledsTbl addRow %s[%d]\n", mdl->varID(var), rowNr);

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

if (rowNr >= fixture.listOfLeds.size())
fixture.listOfLeds.push_back(new Leds(fixture));
return true; }
case onDeleteRow: {
// ppf("fxTbl delrow %s[%d]\n", mdl->varID(var), rowNr);
// ppf("ledsTbl delrow %s[%d]\n", mdl->varID(var), rowNr);
//tbd: fade to black
if (rowNr <fixture.listOfLeds.size()) {
Leds *leds = fixture.listOfLeds[rowNr];
Expand Down Expand Up @@ -260,10 +260,10 @@ class LedModEffects:public SysModule {
}});
currentVar["dash"] = true;

ui->initCoord3D(tableVar, "fxStart", {0,0,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
ui->initCoord3D(tableVar, "ledsStart", {0,0,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
for (forUnsigned8 rowNr = 0; rowNr < fixture.listOfLeds.size(); rowNr++) {
ppf("fxStart[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->startPos.x, fixture.listOfLeds[rowNr]->startPos.y, fixture.listOfLeds[rowNr]->startPos.z);
ppf("ledsStart[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->startPos.x, fixture.listOfLeds[rowNr]->startPos.y, fixture.listOfLeds[rowNr]->startPos.z);
mdl->setValue(var, fixture.listOfLeds[rowNr]->startPos, rowNr);
}
return true;
Expand All @@ -275,23 +275,23 @@ class LedModEffects:public SysModule {
if (rowNr < fixture.listOfLeds.size()) {
fixture.listOfLeds[rowNr]->startPos = mdl->getValue(var, rowNr).as<Coord3D>();

ppf("fxStart[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->startPos.x, fixture.listOfLeds[rowNr]->startPos.y, fixture.listOfLeds[rowNr]->startPos.z);
ppf("ledsStart[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->startPos.x, fixture.listOfLeds[rowNr]->startPos.y, fixture.listOfLeds[rowNr]->startPos.z);

fixture.listOfLeds[rowNr]->fadeToBlackBy();
fixture.listOfLeds[rowNr]->doMap = true;
fixture.doMap = true;
}
else {
ppf("fxStart[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
ppf("ledsStart[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
}
return true;
default: return false;
}});

ui->initCoord3D(tableVar, "fxMiddle", {0,0,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
ui->initCoord3D(tableVar, "ledsMid", {0,0,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
for (forUnsigned8 rowNr = 0; rowNr < fixture.listOfLeds.size(); rowNr++) {
ppf("fxMiddle[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->midPos.x, fixture.listOfLeds[rowNr]->midPos.y, fixture.listOfLeds[rowNr]->midPos.z);
ppf("ledsMid[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->midPos.x, fixture.listOfLeds[rowNr]->midPos.y, fixture.listOfLeds[rowNr]->midPos.z);
mdl->setValue(var, fixture.listOfLeds[rowNr]->midPos, rowNr);
}
return true;
Expand All @@ -303,23 +303,23 @@ class LedModEffects:public SysModule {
if (rowNr < fixture.listOfLeds.size()) {
fixture.listOfLeds[rowNr]->midPos = mdl->getValue(var, rowNr).as<Coord3D>();

ppf("fxStart[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->midPos.x, fixture.listOfLeds[rowNr]->midPos.y, fixture.listOfLeds[rowNr]->midPos.z);
ppf("ledsMid[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->midPos.x, fixture.listOfLeds[rowNr]->midPos.y, fixture.listOfLeds[rowNr]->midPos.z);

fixture.listOfLeds[rowNr]->fadeToBlackBy();
fixture.listOfLeds[rowNr]->doMap = true;
fixture.doMap = true;
}
else {
ppf("fxStart[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
ppf("ledsMid[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
}
return true;
default: return false;
}});

ui->initCoord3D(tableVar, "fxEnd", {8,8,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
ui->initCoord3D(tableVar, "ledsEnd", {8,8,0}, 0, NUM_LEDS_Max, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
for (forUnsigned8 rowNr = 0; rowNr < fixture.listOfLeds.size(); rowNr++) {
ppf("fxEnd[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->endPos.x, fixture.listOfLeds[rowNr]->endPos.y, fixture.listOfLeds[rowNr]->endPos.z);
ppf("ledsEnd[%d] onSetValue %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->endPos.x, fixture.listOfLeds[rowNr]->endPos.y, fixture.listOfLeds[rowNr]->endPos.z);
mdl->setValue(var, fixture.listOfLeds[rowNr]->endPos, rowNr);
}
return true;
Expand All @@ -331,27 +331,27 @@ class LedModEffects:public SysModule {
if (rowNr < fixture.listOfLeds.size()) {
fixture.listOfLeds[rowNr]->endPos = mdl->getValue(var, rowNr).as<Coord3D>();

ppf("fxEnd[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->endPos.x, fixture.listOfLeds[rowNr]->endPos.y, fixture.listOfLeds[rowNr]->endPos.z);
ppf("ledsEnd[%d] onChange %d,%d,%d\n", rowNr, fixture.listOfLeds[rowNr]->endPos.x, fixture.listOfLeds[rowNr]->endPos.y, fixture.listOfLeds[rowNr]->endPos.z);

fixture.listOfLeds[rowNr]->fadeToBlackBy();
fixture.listOfLeds[rowNr]->doMap = true;
fixture.doMap = true;
}
else {
ppf("fxEnd[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
ppf("ledsEnd[%d] onChange rownr not in range > %d\n", rowNr, fixture.listOfLeds.size());
}
return true;
default: return false;
}});

ui->initText(tableVar, "fxSize", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
ui->initText(tableVar, "ledsSize", nullptr, 32, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue: {
// for (std::vector<Leds *>::iterator leds=fixture.listOfLeds.begin(); leds!=fixture.listOfLeds.end(); ++leds) {
stackUnsigned8 rowNr = 0;
for (Leds *leds:fixture.listOfLeds) {
char message[32];
print->fFormat(message, sizeof(message)-1, "%d x %d x %d -> %d", leds->size.x, leds->size.y, leds->size.z, leds->nrOfLeds);
ppf("onSetValue fxSize[%d] = %s\n", rowNr, message);
ppf("onSetValue ledsSize[%d] = %s\n", rowNr, message);
mdl->setValue(var, JsonString(message, JsonString::Copied), rowNr); //rowNr
rowNr++;
}
Expand Down Expand Up @@ -390,7 +390,7 @@ class LedModEffects:public SysModule {
// ui->dashVarChanged = true;
// //rebuild the table
for (JsonObject childVar: mdl->varChildren("e131Tbl"))
ui->callVarFun(childVar);
ui->callVarFun(childVar, UINT8_MAX, onSetValue); //set the value (WIP)

// }
// else
Expand Down Expand Up @@ -472,7 +472,7 @@ class LedModEffects:public SysModule {
token = strtok(NULL, ",");
if (token != NULL) newCoord->z = atoi(token) / 10; else newCoord->z = 0;

mdl->setValue(isStart?"fxStart":isEnd?"fxEnd":"fxMiddle", *newCoord, 0); //assuming row 0 for the moment
mdl->setValue(isStart?"ledsStart":isEnd?"ledsEnd":"ledsMid", *newCoord, 0); //assuming row 0 for the moment

fixture.listOfLeds[rowNr]->doMap = true; //recalc projection
fixture.doMap = true;
Expand Down
10 changes: 2 additions & 8 deletions src/App/LedModFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,14 @@ class LedModFixture:public SysModule {
default: return false;
}}); //fixture

ui->initCoord3D(currentVar, "fixSize", eff->fixture.fixSize, 0, NUM_LEDS_Max, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
mdl->setValue(var, eff->fixture.fixSize);
return true;
ui->initCoord3D(currentVar, "fixSize", &eff->fixture.fixSize, 0, NUM_LEDS_Max, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onUI:
ui->setLabel(var, "Size");
return true;
default: return false;
}});

ui->initNumber(currentVar, "fixCount", eff->fixture.nrOfLeds, 0, UINT16_MAX, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onSetValue:
mdl->setValue(var, eff->fixture.nrOfLeds);
return true;
ui->initNumber(currentVar, "fixCount", &eff->fixture.nrOfLeds, 0, UINT16_MAX, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case onUI:
ui->setLabel(var, "Count");
web->addResponseV(var["id"], "comment", "Max %d", NUM_LEDS_Max);
Expand Down

0 comments on commit c80b22a

Please sign in to comment.