diff --git a/src/App/AppEffects.h b/src/App/AppEffects.h index d672ca9b..d7219061 100644 --- a/src/App/AppEffects.h +++ b/src/App/AppEffects.h @@ -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"); @@ -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); @@ -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; } @@ -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!"); }); @@ -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; } }; @@ -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; } @@ -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); @@ -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; @@ -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; @@ -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); @@ -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); @@ -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; @@ -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"); @@ -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; } @@ -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); @@ -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()) { - // 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()) { + if (var["value"].is()) { + var["value"][rowNr] = -99; + } else { + var["value"].to(); + 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... @@ -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) diff --git a/src/App/AppFixture.cpp b/src/App/AppFixture.cpp index 1ef54dcf..6384f7a8 100644 --- a/src/App/AppFixture.cpp +++ b/src/App/AppFixture.cpp @@ -29,7 +29,6 @@ physMap->clear(); leds->mappingTable.clear(); } - ledCounter = 0; //deallocate all led pins uint8_t pinNr = 0; @@ -39,25 +38,9 @@ pinNr++; } - prevLeds = 0; - - // //pre-processing - // switch(projectionNr) { - // case p_None: - // break; - // case p_Random: - // break; - // case p_DistanceFromPoint: - // // startPos.x = 0; - // // startPos.y = 0; - // // startPos.z = 0; - // break; - // case p_DistanceFromCenter: - // // startPos.x = size.x / 2; - // // startPos.y = size.y / 2; - // // startPos.z = size.z / 2; - // break; - // } + uint16_t indexP = 0; + uint16_t prevIndexP = 0; + uint8_t currPin; //what to deserialize jrdws.lookFor("width", &size.x); @@ -67,7 +50,7 @@ jrdws.lookFor("pin", &currPin); //lookFor leds array and for each item in array call lambdo to make a projection - jrdws.lookFor("leds", [this](std::vector uint16CollectList) { //this will be called for each tuple of coordinates! + jrdws.lookFor("leds", [this, &prevIndexP, &indexP, &currPin](std::vector uint16CollectList) { //this will be called for each tuple of coordinates! // USER_PRINTF("funList "); // for (uint16_t num:uint16CollectList) // USER_PRINTF(" %d", num); @@ -90,14 +73,17 @@ // for (Leds leds:ledsList) { //vector iterator needed to get the pointer to leds as we need to update leds, also vector iteration on classes is faster!!! //search: ^(?=.*\bfor\b)(?=.*\b:\b).*$ - for (std::vector::iterator leds=ledsList.begin(); leds!=ledsList.end(); leds++) { + for (std::vector::iterator leds=ledsList.begin(); leds!=ledsList.end(); ++leds) { if (pixel >= leds->startPos && pixel <=leds->endPos) { - // USER_PRINTF(" XXX %d %d %d", leds->projectionNr, leds->effectDimension, fixtureDimension); + // if (leds->fx == 11) { //lines2D + // // USER_PRINTF(" XXX %d %d %d %d, %d, %d", leds->projectionNr, leds->effectDimension, fixtureDimension, pixel.x, pixel.y, pixel.z); + // USER_PRINTF(" %d: %d,%d,%d", indexP, pixel.x, pixel.y, pixel.z); + // } // USER_PRINTF("projectionNr p:%d f:%d s:%d, %d-%d-%d %d-%d-%d %d-%d-%d\n", projectionNr, effectDimension, fixtureDimension, x, y, z, uint16CollectList[0], uint16CollectList[1], uint16CollectList[2], size.x, size.y, size.z); - //calculate the bucket to add to current physical led to - uint16_t bucket = UINT16_MAX; + //calculate the indexV to add to current physical led to + uint16_t indexV = UINT16_MAX; switch(leds->projectionNr) { case p_None: break; @@ -107,24 +93,24 @@ case p_DistanceFromCenter: if (leds->effectDimension == _1D) { if (fixtureDimension == _1D) - bucket = distance(pixel.x,0, 0, leds->startPos.x,0,0); + indexV = distance(pixel.x,0, 0, leds->startPos.x,0,0); else if (fixtureDimension == _2D) { - bucket = distance(pixel.x,pixel.y,0, leds->startPos.x, leds->startPos.y,0); - // USER_PRINTF("bucket %d-%d %d-%d %d\n", x,y, startPos.x, startPos.y, bucket); + indexV = distance(pixel.x,pixel.y,0, leds->startPos.x, leds->startPos.y,0); + // USER_PRINTF("indexV %d-%d %d-%d %d\n", x,y, startPos.x, startPos.y, indexV); } else if (fixtureDimension == _3D) - bucket = distance(pixel, leds->startPos); + indexV = distance(pixel, leds->startPos); } else if (leds->effectDimension == _2D) { leds->size.z = 1; //no 3D if (fixtureDimension == _1D) - bucket = pixel.x; + indexV = pixel.x; else if (fixtureDimension == _2D) { leds->size.x = abs(leds->endPos.x - leds->startPos.x + 1); leds->size.y = abs(leds->endPos.y - leds->startPos.y + 1); leds->size.z = 1; - pixel -= leds->startPos; + Coord3D newPixel = pixel - leds->startPos; //scaling (check rounding errors) //1024 crash in makebuffer... @@ -133,19 +119,19 @@ scale = (sqrt((float)256.0 / (leds->size.x * leds->size.y))); //avoid high virtual resolutions leds->size.x *= scale; leds->size.y *= scale; - pixel.x = (pixel.x+1) * scale - 1; - pixel.y = (pixel.y+1) * scale - 1; - pixel.z = 0; + newPixel.x = (newPixel.x+1) * scale - 1; + newPixel.y = (newPixel.y+1) * scale - 1; + newPixel.z = 0; - bucket = leds->XYZ(pixel); - // USER_PRINTF("2D to 2D bucket %f %d %d x %d %d x %d\n", scale, bucket, x, y, size.x, size.y); + indexV = leds->XYZ(newPixel); + // USER_PRINTF("2D to 2D indexV %f %d %d x %d %d x %d\n", scale, indexV, x, y, size.x, size.y); } else if (fixtureDimension == _3D) { leds->size.x = size.x + size.y; leds->size.y = size.z; leds->size.z = 1; - bucket = leds->XY(pixel.x + pixel.y + 1, pixel.z); - // USER_PRINTF("2D to 3D bucket %d %d\n", bucket, size.x); + indexV = leds->XY(pixel.x + pixel.y + 1, pixel.z); + // USER_PRINTF("2D to 3D indexV %d %d\n", indexV, size.x); } } //tbd: effect is 3D @@ -168,22 +154,20 @@ yNew = round(((size.y-1.0-pixel.y)/(size.y-1.0) * yNew + size.y) / 2.0); USER_PRINTF(" %d,%d->%f,%f->%f,%f", pixel.x, pixel.y, sin(pixel.x * TWO_PI / (float)(size.x-1)), cos(pixel.x * TWO_PI / (float)(size.x-1)), xNew, yNew); - pixel.x = xNew; - pixel.y = yNew; - pixel.z = 0; + Coord3D newPixel = {xNew, yNew, 0}; leds->size.x = size.x; leds->size.y = size.y; leds->size.z = 1; - bucket = leds->XYZ(pixel); - // USER_PRINTF("2D to 2D bucket %f %d %d x %d %d x %d\n", scale, bucket, x, y, size.x, size.y); + indexV = leds->XYZ(newPixel); + // USER_PRINTF("2D to 2D indexV %f %d %d x %d %d x %d\n", scale, indexV, x, y, size.x, size.y); } } break; } - if (bucket != UINT16_MAX) { + if (indexV != UINT16_MAX) { //post processing: inverse mapping switch(leds->projectionNr) { case p_DistanceFromCenter: @@ -192,7 +176,7 @@ switch (fixtureDimension) { case _2D: float minDistance = 10; - // USER_PRINTF("checking bucket %d\n", bucket); + // USER_PRINTF("checking indexV %d\n", indexV); for (uint16_t y=0; y 0.5; y++) for (uint16_t x=0; x 0.5; x++) { @@ -204,21 +188,21 @@ // USER_PRINTF(" %d,%d->%f,%f->%f,%f", x, y, sin(x * TWO_PI / (float)(size.x-1)), cos(x * TWO_PI / (float)(size.x-1)), xNew, yNew); - float distance = abs(bucket - xNew - yNew * size.x); + float distance = abs(indexV - xNew - yNew * size.x); //this should work (better) but needs more testing // if (distance < minDistance) { // minDistance = distance; - // bucket = x+y*size.x; + // indexV = x+y*size.x; // } - if (bucket == (uint8_t)xNew + (uint8_t)yNew * size.x) { - // USER_PRINTF(" found one %d => %d=%d+%d*%d (%f+%f*%d) [%f]\n", bucket, x+y*size.x, x,y, size.x, xNew, yNew, size.x, distance); - bucket = leds->XY(x, y); + if (indexV == (uint8_t)xNew + (uint8_t)yNew * size.x) { + // USER_PRINTF(" found one %d => %d=%d+%d*%d (%f+%f*%d) [%f]\n", indexV, x+y*size.x, x,y, size.x, xNew, yNew, size.x, distance); + indexV = leds->XY(x, y); minDistance = 0; // stop looking further } } - if (minDistance > 0.5) bucket = -1; + if (minDistance > 0.5) indexV = -1; break; } break; @@ -226,30 +210,31 @@ break; } - if (bucket != UINT16_MAX) { //can be nulled by inverse mapping + if (indexV != UINT16_MAX) { //can be nulled by inverse mapping //add physical tables if not present - if (bucket >= NUM_LEDS_Max) { - USER_PRINTF("mapping add physMap %d>=%d (%d) too big %d\n", bucket, NUM_LEDS_Max, leds->mappingTable.size(), UINT16_MAX); + if (indexV >= NUM_LEDS_Max) { + USER_PRINTF("mapping add physMap %d>=%d (%d) too big %d\n", indexV, NUM_LEDS_Max, leds->mappingTable.size(), UINT16_MAX); } else { //create new physMaps if needed - if (bucket >= leds->mappingTable.size()) { - for (int i = leds->mappingTable.size(); i<=bucket;i++) { - // USER_PRINTF("mapping add physMap %d %d\n", bucket, mappingTable.size()); + if (indexV >= leds->mappingTable.size()) { + for (int i = leds->mappingTable.size(); i<=indexV;i++) { + // USER_PRINTF("mapping add physMap %d %d\n", indexV, mappingTable.size()); std::vector physMap; leds->mappingTable.push_back(physMap); } } - leds->mappingTable[bucket].push_back(ledCounter); //add the current led in the right physMap + //indexV is within the square + leds->mappingTable[indexV].push_back(indexP); //add the current led in the right physMap } } - // USER_PRINTF("mapping b:%d t:%d V:%d\n", bucket, ledCounter, leds->mappingTable.size()); - } //bucket + // USER_PRINTF("mapping b:%d t:%d V:%d\n", indexV, indexP, leds->mappingTable.size()); + } //indexV // delay(1); //feed the watchdog } //if x,y,z between start and endpos } //ledsList - ledCounter++; //also increase if no buffer created + indexP++; //also increase if no buffer created } //if 1D-3D else { // end of leds array @@ -265,7 +250,7 @@ after = strtok(NULL, " "); uint16_t startLed = atoi(before); uint16_t nrOfLeds = atoi(after) - atoi(before) + 1; - print->fFormat(details, sizeof(details)-1, "%d-%d", min(prevLeds, startLed), max((uint16_t)(ledCounter - 1), nrOfLeds)); //careful: AppModLeds:loop uses this to assign to FastLed + print->fFormat(details, sizeof(details)-1, "%d-%d", min(prevIndexP, startLed), max((uint16_t)(indexP - 1), nrOfLeds)); //careful: AppModLeds:loop uses this to assign to FastLed USER_PRINTF("pins extend leds %d: %s\n", currPin, details); //tbd: more check @@ -274,12 +259,12 @@ } else {//allocate new pin //tbd: check if free - print->fFormat(details, sizeof(details)-1, "%d-%d", prevLeds, ledCounter - 1); //careful: AppModLeds:loop uses this to assign to FastLed + print->fFormat(details, sizeof(details)-1, "%d-%d", prevIndexP, indexP - 1); //careful: AppModLeds:loop uses this to assign to FastLed USER_PRINTF("pins %d: %s\n", currPin, details); pins->allocatePin(currPin, "Leds", details); } - prevLeds = ledCounter; + prevIndexP = indexP; } }); //create the right type, otherwise crash @@ -296,8 +281,9 @@ if (leds->projectionNr > p_Random) { leds->nrOfLeds = leds->mappingTable.size(); - // uint16_t x=0; + // uint16_t x=0; //indexV // uint16_t y=0; + // // for (std::vector> ::iterator physMap=leds->mappingTable.begin(); physMap!=leds->mappingTable.end(); physMap++) { // for (std::vectorphysMap:leds->mappingTable) { // if (physMap.size()) { // USER_PRINTF("ledV %d mapping: firstLedP: %d #ledsP: %d", x, physMap[0], physMap.size()); @@ -324,5 +310,4 @@ } //if fileName else USER_PRINTF("projectAndMap: Filename for fixture %d not found\n", fixtureNr); - } - + } \ No newline at end of file diff --git a/src/App/AppFixture.h b/src/App/AppFixture.h index ed81a143..eb80ab45 100644 --- a/src/App/AppFixture.h +++ b/src/App/AppFixture.h @@ -63,11 +63,9 @@ class Fixture { Coord3D head = {0,0,0}; //variables for json Scan - uint16_t prevLeds; + // uint16_t prevIndexP; //track pins and leds - uint8_t currPin; - uint16_t ledCounter; - + //load fixture json file, parse it and depending on the projection, create a mapping for it void projectAndMap(); diff --git a/src/App/AppLeds.cpp b/src/App/AppLeds.cpp index 6df18894..a82c2ca4 100644 --- a/src/App/AppLeds.cpp +++ b/src/App/AppLeds.cpp @@ -17,11 +17,11 @@ void Leds::setPixelColor(uint16_t indexV, CRGB color) { if (indexV >= mappingTable.size()) return; for (uint16_t indexP:mappingTable[indexV]) { if (indexP < NUM_LEDS_Max) - fixture->ledsP[indexP] = color; + fixture->ledsP[indexP] = blend(color, getPixelColor(indexV), 128); } } else //no projection - fixture->ledsP[projectionNr==p_Random?random(fixture->nrOfLeds):indexV] = color; + fixture->ledsP[projectionNr==p_Random?random(fixture->nrOfLeds):indexVinitAppMod(parentVar, name); if (parentVar["o"] > -1000) parentVar["o"] = -1000; //set default order. Don't use auto generated order as order can be changed in the ui (WIP) + JsonObject currentVar = ui->initCheckBox(parentVar, "on", true, false, [](JsonObject var) { //uiFun + web->addResponse(var["id"], "label", "On/Off"); + }); + currentVar["stage"] = true; + + //logarithmic slider (10) + currentVar = ui->initSlider(parentVar, "bri", 10, 0, 255, false, [](JsonObject var) { //uiFun + web->addResponse(var["id"], "label", "Brightness"); + }, [](JsonObject var, uint8_t) { //chFun + uint8_t bri = var["value"]; + + uint8_t result = linearToLogarithm(var, bri); + + FastLED.setBrightness(result); + + USER_PRINTF("Set Brightness to %d -> b:%d r:%d\n", var["value"].as(), bri, result); + }); + currentVar["log"] = true; //logarithmic: not needed when using FastLED setCorrection + currentVar["stage"] = true; //these values override model.json??? + ui->initCanvas(parentVar, "pview", UINT16_MAX, false, [](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "Preview"); web->addResponse(var["id"], "comment", "Shows the fixture"); @@ -98,6 +118,16 @@ class AppModFixture:public SysModule { web->addResponseV(var["id"], "comment", "f(%d leds)", lds->fixture.nrOfLeds); }); + #ifdef USERMOD_WLEDAUDIO + ui->initCheckBox(parentVar, "mHead", false, false, [](JsonObject var) { //uiFun + web->addResponse(var["id"], "label", "Moving heads"); + web->addResponse(var["id"], "comment", "Move on GEQ"); + }, [this](JsonObject var, uint8_t) { //chFun + if (!var["value"]) + lds->fixture.head = {0,0,0}; + }); + #endif + } }; diff --git a/src/App/AppModLeds.h b/src/App/AppModLeds.h index bae1eed0..004cf6a7 100644 --- a/src/App/AppModLeds.h +++ b/src/App/AppModLeds.h @@ -58,11 +58,11 @@ class AppModLeds:public SysModule { leds.fx = 13; leds.projectionNr = 2; fixture.ledsList.push_back(leds); - // leds = Leds(); - // leds.fixture = &fixture; - // leds.projectionNr = 2; - // leds.fx = 14; - // fixture.ledsList.push_back(leds); + leds = Leds(); + leds.fixture = &fixture; + leds.projectionNr = 2; + leds.fx = 14; + fixture.ledsList.push_back(leds); }; void setup() { @@ -73,32 +73,12 @@ class AppModLeds:public SysModule { JsonObject currentVar; - currentVar = ui->initCheckBox(parentVar, "on", true, false, [](JsonObject var) { //uiFun - web->addResponse(var["id"], "label", "On/Off"); - }); - currentVar["stage"] = true; - - //logarithmic slider (10) - currentVar = ui->initSlider(parentVar, "bri", 10, 0, 255, false, [](JsonObject var) { //uiFun - web->addResponse(var["id"], "label", "Brightness"); - }, [](JsonObject var, uint8_t) { //chFun - uint8_t bri = var["value"]; - - uint8_t result = linearToLogarithm(var, bri); - - FastLED.setBrightness(result); - - USER_PRINTF("Set Brightness to %d -> b:%d r:%d\n", var["value"].as(), bri, result); - }); - currentVar["log"] = true; //logarithmic: not needed when using FastLED setCorrection - currentVar["stage"] = true; //these values override model.json??? - JsonObject tableVar = ui->initTable(parentVar, "fxTbl", nullptr, false, [this](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "Effects"); web->addResponse(var["id"], "comment", "List of effects"); }); - currentVar = ui->initSelect(parentVar, "fx", 0, false, [this](JsonObject var) { //uiFun + currentVar = ui->initSelect(tableVar, "fx", 0, false, [this](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "Effect"); web->addResponse(var["id"], "comment", "Effect to show"); JsonArray select = web->addResponseA(var["id"], "options"); @@ -106,10 +86,15 @@ class AppModLeds:public SysModule { select.add(effect->name()); } }, [this](JsonObject var, uint8_t rowNr) { //chFun - // if (rowNr < fixture.ledsList.size()) { - doMap = effects.setEffect(fixture.ledsList[0], var, UINT8_MAX); + if (rowNr < fixture.ledsList.size()) { + doMap |= effects.setEffect(fixture.ledsList[rowNr], var, rowNr); // doMap = effects.setEffect(fixture.ledsList[1], var, UINT8_MAX); - // } + } + }, nullptr, fixture.ledsList.size(), [this](JsonObject var, uint8_t rowNr) { //valueFun + if (rowNr != UINT8_MAX && rowNr < fixture.ledsList.size()) { + mdl->setValue(var, fixture.ledsList[rowNr].fx, rowNr); + } + }); currentVar["stage"] = true; @@ -159,6 +144,11 @@ class AppModLeds:public SysModule { } doMap = true; + }, nullptr, fixture.ledsList.size(), [this](JsonObject var, uint8_t rowNr) { //valueFun + if (rowNr != UINT8_MAX && rowNr < fixture.ledsList.size()) { + mdl->setValue(var, fixture.ledsList[rowNr].startPos, rowNr); + } + }); ui->initCoord3D(tableVar, "fxEnd", fixture.ledsList[0].endPos, 0, UINT16_MAX, false, [](JsonObject var) { //uiFun @@ -176,6 +166,11 @@ class AppModLeds:public SysModule { } doMap = true; + }, nullptr, fixture.ledsList.size(), [this](JsonObject var, uint8_t rowNr) { //valueFun + if (rowNr != UINT8_MAX && rowNr < fixture.ledsList.size()) { + mdl->setValue(var, fixture.ledsList[rowNr].endPos, rowNr); + } + }); ui->initCoord3D(tableVar, "fxSize", fixture.ledsList[0].size, 0, UINT16_MAX, true, [this](JsonObject var) { //uiFun @@ -196,16 +191,6 @@ class AppModLeds:public SysModule { }, [this](JsonObject var, uint8_t) { //chFun }); //fixtureGen - #ifdef USERMOD_WLEDAUDIO - ui->initCheckBox(parentVar, "mHead", false, false, [](JsonObject var) { //uiFun - web->addResponse(var["id"], "label", "Moving heads"); - web->addResponse(var["id"], "comment", "Move on GEQ"); - }, [this](JsonObject var, uint8_t) { //chFun - if (!var["value"]) - fixture.head = {0,0,0}; - }); - #endif - #ifdef USERMOD_E131 // if (e131mod->isEnabled) { e131mod->patchChannel(0, "bri", 255); //should be 256?? @@ -239,8 +224,10 @@ class AppModLeds:public SysModule { //for each programmed effect // run the next frame of the effect // vector iteration on classes is faster!!! (22 vs 30 fps !!!!) - for (std::vector::iterator leds=fixture.ledsList.begin(); leds!=fixture.ledsList.end(); leds++) + for (std::vector::iterator leds=fixture.ledsList.begin(); leds!=fixture.ledsList.end(); leds++) { + // USER_PRINTF(" %d", leds->fx); effects.loop(*leds); + } FastLED.show(); diff --git a/src/Sys/SysModModel.h b/src/Sys/SysModModel.h index ab5a6c17..6904f966 100644 --- a/src/Sys/SysModModel.h +++ b/src/Sys/SysModModel.h @@ -52,25 +52,19 @@ struct Coord3D { //assignments Coord3D operator=(Coord3D rhs) { - USER_PRINTF("Coord3D assign %d %d %d\n", rhs.x, rhs.y, rhs.z); this->x = rhs.x; this->y = rhs.y; this->z = rhs.z; return *this; } Coord3D operator-=(Coord3D rhs) { - USER_PRINTF("Coord3D assign %d %d %d\n", rhs.x, rhs.y, rhs.z); this->x -= rhs.x; this->y -= rhs.y; this->z -= rhs.z; return *this; } Coord3D operator-(Coord3D rhs) { - USER_PRINTF("Coord3D assign %d %d %d\n", rhs.x, rhs.y, rhs.z); - this->x - rhs.x; - this->y - rhs.y; - this->z - rhs.z; - return *this; + return Coord3D{uint16_t(x - rhs.x), uint16_t(y - rhs.y), uint16_t(z- rhs.z)}; } }; @@ -245,7 +239,7 @@ class SysModModel:public SysModule { return getValue(var, rowNr); } else { - USER_PRINTF("getValue: Var %s does not exist!!\n", id); + // USER_PRINTF("getValue: Var %s does not exist!!\n", id); return JsonVariant(); } } diff --git a/tools/misc.txt b/tools/misc.txt index b60c3ecb..bd63082a 100644 --- a/tools/misc.txt +++ b/tools/misc.txt @@ -2,4 +2,5 @@ -~/Applications/ffmpeg -f concat -safe 0 -i <(for f in (*.png|sort -n) ; do echo "file '$PWD/$f'"; done) -pix_fmt yuv420p out.mp4 +~/Applications/ffmpeg -f concat -safe 0 -i <(for f in (*.png|sort -n) ; do echo "file '$PWD/$f'"; echo duration 0.03333; done) -pix_fmt yuv420p out.mp4 +