From c80b22ac413fd043f94a360cf1be1de180a65cd6 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Wed, 26 Jun 2024 13:30:40 +0200 Subject: [PATCH] Rename fxTbl to ledsTbl - 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) --- src/App/LedFixture.cpp | 8 ++++---- src/App/LedModEffects.h | 38 +++++++++++++++++++------------------- src/App/LedModFixture.h | 10 ++-------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/App/LedFixture.cpp b/src/App/LedFixture.cpp index 74cd7d8b..cddb2cf4 100644 --- a/src/App/LedFixture.cpp +++ b/src/App/LedFixture.cpp @@ -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 @@ -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 diff --git a/src/App/LedModEffects.h b/src/App/LedModEffects.h index 24b047c6..1108aae9 100644 --- a/src/App/LedModEffects.h +++ b/src/App/LedModEffects.h @@ -121,14 +121,14 @@ 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; @@ -136,7 +136,7 @@ class LedModEffects:public SysModule { 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 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; @@ -275,23 +275,23 @@ class LedModEffects:public SysModule { if (rowNr < fixture.listOfLeds.size()) { fixture.listOfLeds[rowNr]->startPos = mdl->getValue(var, rowNr).as(); - 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; @@ -303,23 +303,23 @@ class LedModEffects:public SysModule { if (rowNr < fixture.listOfLeds.size()) { fixture.listOfLeds[rowNr]->midPos = mdl->getValue(var, rowNr).as(); - 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; @@ -331,27 +331,27 @@ class LedModEffects:public SysModule { if (rowNr < fixture.listOfLeds.size()) { fixture.listOfLeds[rowNr]->endPos = mdl->getValue(var, rowNr).as(); - 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::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++; } @@ -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 @@ -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; diff --git a/src/App/LedModFixture.h b/src/App/LedModFixture.h index 644d6cba..6d5a9d0e 100644 --- a/src/App/LedModFixture.h +++ b/src/App/LedModFixture.h @@ -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);