diff --git a/src/App/AppEffects.h b/src/App/AppEffects.h index 1c20564c..50633dd1 100644 --- a/src/App/AppEffects.h +++ b/src/App/AppEffects.h @@ -15,10 +15,10 @@ #include "../User/UserModE131.h" #endif -static uint8_t gHue = 0; // rotating "base color" used by many of the patterns -static unsigned long call = 0; //not used at the moment (don't use in effect calculations) -static unsigned long now = millis(); -static CRGBPalette16 palette = PartyColors_p; +uint8_t gHue = 0; // rotating "base color" used by many of the patterns +unsigned long call = 0; //not used at the moment (don't use in effect calculations) +unsigned long now = millis(); +CRGBPalette16 palette = PartyColors_p; class SharedData { private: @@ -85,7 +85,7 @@ class RainbowEffect: public Effect { } void loop() { // FastLED's built-in rainbow generator - fill_rainbow( ledsP, LedsV::nrOfLedsP, gHue, 7); + fill_rainbow( ledsP, ledsV.nrOfLedsP, gHue, 7); } }; @@ -99,10 +99,10 @@ class RainbowWithGlitterEffect:public RainbowEffect { RainbowEffect::loop(); addGlitter(80); } - static void addGlitter( fract8 chanceOfGlitter) + void addGlitter( fract8 chanceOfGlitter) { if( random8() < chanceOfGlitter) { - ledsP[ random16(LedsV::nrOfLedsP) ] += CRGB::White; + ledsP[ random16(ledsV.nrOfLedsP) ] += CRGB::White; } } }; @@ -114,8 +114,8 @@ class SinelonEffect: public Effect { } void loop() { // a colored dot sweeping back and forth, with fading trails - fadeToBlackBy( ledsP, LedsV::nrOfLedsP, 20); - int pos = beatsin16( mdl->getValue("BPM").as(), 0, LedsV::nrOfLedsV-1 ); + fadeToBlackBy( ledsP, ledsV.nrOfLedsP, 20); + int pos = beatsin16( mdl->getValue("BPM").as(), 0, ledsV.nrOfLedsV-1 ); // ledsV[pos] += CHSV( gHue, 255, 192); ledsV[pos] = ledsV.getPixelColor(pos) + CHSV( gHue, 255, 192); // CRGB x = ledsV[pos]; @@ -134,11 +134,11 @@ class RunningEffect: public Effect { } void loop() { // a colored dot sweeping back and forth, with fading trails - fadeToBlackBy( ledsP, LedsV::nrOfLedsP, mdl->getValue("fade").as()); //physical leds - int pos = map(beat16( mdl->getValue("BPM").as()), 0, uint16_t(-1), 0, LedsV::nrOfLedsV-1 ); //instead of call%LedsV::nrOfLedsV - // int pos2 = map(beat16( mdl->getValue("BPM").as(), 1000), 0, uint16_t(-1), 0, LedsV::nrOfLedsV-1 ); //one second later + fadeToBlackBy( ledsP, ledsV.nrOfLedsP, mdl->getValue("fade").as()); //physical leds + int pos = map(beat16( mdl->getValue("BPM").as()), 0, uint16_t(-1), 0, ledsV.nrOfLedsV-1 ); //instead of call%ledsV.nrOfLedsV + // int pos2 = map(beat16( mdl->getValue("BPM").as(), 1000), 0, uint16_t(-1), 0, ledsV.nrOfLedsV-1 ); //one second later ledsV[pos] = CHSV( gHue, 255, 192); //make sure the right physical leds get their value - // ledsV[LedsV::nrOfLedsV -1 - pos2] = CHSV( gHue, 255, 192); //make sure the right physical leds get their value + // ledsV[ledsV.nrOfLedsV -1 - pos2] = CHSV( gHue, 255, 192); //make sure the right physical leds get their value } bool controls(JsonObject parentVar) { ui->initSlider(parentVar, "BPM", 60, 0, 255, 0, false, [](JsonObject var) { //uiFun @@ -156,8 +156,8 @@ class ConfettiEffect: public Effect { } void loop() { // random colored speckles that blink in and fade smoothly - fadeToBlackBy( ledsP, LedsV::nrOfLedsP, 10); - int pos = random16(LedsV::nrOfLedsP); + fadeToBlackBy( ledsP, ledsV.nrOfLedsP, 10); + int pos = random16(ledsV.nrOfLedsP); ledsP[pos] += CHSV( gHue + random8(64), 200, 255); } }; @@ -172,7 +172,7 @@ class BPMEffect: public Effect { // colored stripes pulsing at a defined Beats-Per-Minute (BPM) uint8_t BeatsPerMinute = 62; uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); - for( int i = 0; i < LedsV::nrOfLedsV; i++) { //9948 + for( int i = 0; i < ledsV.nrOfLedsV; i++) { //9948 ledsV[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); } } @@ -188,10 +188,10 @@ class JuggleEffect: public Effect { } void loop() { // eight colored dots, weaving in and out of sync with each other - fadeToBlackBy( ledsP, LedsV::nrOfLedsP, 20); + fadeToBlackBy( ledsP, ledsV.nrOfLedsP, 20); uint8_t dothue = 0; for( int i = 0; i < 8; i++) { - ledsP[beatsin16( i+7, 0, LedsV::nrOfLedsP-1 )] |= CHSV(dothue, 200, 255); + ledsP[beatsin16( i+7, 0, ledsV.nrOfLedsP-1 )] |= CHSV(dothue, 200, 255); dothue += 32; } } @@ -207,16 +207,16 @@ class Ripples3DEffect: public Effect { float ripple_interval = 1.3 * (interval/128.0); - fill_solid(ledsP, LedsV::nrOfLedsP, CRGB::Black); + fill_solid(ledsP, ledsV.nrOfLedsP, CRGB::Black); // fill(CRGB::Black); - uint16_t mW = LedsV::widthV; - uint16_t mH = LedsV::heightV; - uint16_t mD = LedsV::depthV; + uint16_t mW = ledsV.widthV; + uint16_t mH = ledsV.heightV; + uint16_t mD = ledsV.depthV; for (int z=0; zdiameter && d 0; i--) { - uint8_t x = beatsin8(mdl->getValue("BPM").as()/8 + i, 0, LedsV::widthV - 1); - uint8_t y = beatsin8(mdl->getValue("intensity").as()/8 - i, 0, LedsV::heightV - 1); + uint8_t x = beatsin8(mdl->getValue("BPM").as()/8 + i, 0, ledsV.widthV - 1); + uint8_t y = beatsin8(mdl->getValue("intensity").as()/8 - i, 0, ledsV.heightV - 1); CRGB color = ColorFromPalette(palette, beatsin8(12, 0, 255), 255); - ledsV[x + y * LedsV::widthV] = color; + ledsV[x + y * ledsV.widthV] = color; } - blur2d(ledsP, LedsV::widthP, LedsV::heightP, mdl->getValue("blur")); //this is tricky as FastLed is not aware of our virtual + blur2d(ledsP, ledsV.widthP, ledsV.heightP, mdl->getValue("blur")); //this is tricky as FastLed is not aware of our virtual } bool controls(JsonObject parentVar) { ui->initSlider(parentVar, "BPM", 60); @@ -306,18 +306,18 @@ class Lines2D: public Effect { } void loop() { - fadeToBlackBy( ledsP, LedsV::nrOfLedsP, 100); + fadeToBlackBy( ledsP, ledsV.nrOfLedsP, 100); if (mdl->getValue("Vertical").as()) { - size_t x = map(beat16( mdl->getValue("BPM").as()), 0, uint16_t(-1), 0, LedsV::widthV-1 ); //instead of call%width + size_t x = map(beat16( mdl->getValue("BPM").as()), 0, uint16_t(-1), 0, ledsV.widthV-1 ); //instead of call%width - for (size_t y = 0; y < LedsV::heightV; y++) { - ledsV[x + y * LedsV::widthV] = CHSV( gHue, 255, 192); + for (size_t y = 0; y < ledsV.heightV; y++) { + ledsV[x + y * ledsV.widthV] = CHSV( gHue, 255, 192); } } else { - size_t y = map(beat16( mdl->getValue("BPM").as()), 0, uint16_t(-1), 0, LedsV::heightV-1 ); //instead of call%height - for (size_t x = 0; x < LedsV::widthV; x++) { - ledsV[x + y * LedsV::widthV] = CHSV( gHue, 255, 192); + size_t y = map(beat16( mdl->getValue("BPM").as()), 0, uint16_t(-1), 0, ledsV.heightV-1 ); //instead of call%height + for (size_t x = 0; x < ledsV.widthV; x++) { + ledsV[x + y * ledsV.widthV] = CHSV( gHue, 255, 192); } } } @@ -341,8 +341,8 @@ class DistortionWaves2D: public Effect { } void loop() { - const uint16_t cols = LedsV::widthV; - const uint16_t rows = LedsV::heightV; + const uint16_t cols = ledsV.widthV; + const uint16_t rows = ledsV.heightV; uint8_t speed = mdl->getValue("speed").as()/32; uint8_t scale = mdl->getValue("scale").as()/32; @@ -380,7 +380,7 @@ class DistortionWaves2D: public Effect { valueG = gamma8(cos8(valueG)); valueB = gamma8(cos8(valueB)); - ledsV[x + y * LedsV::widthV] = CRGB(valueR, valueG, valueB); + ledsV[x + y * ledsV.widthV] = CRGB(valueR, valueG, valueB); } } } @@ -406,8 +406,8 @@ class Octopus2D: public Effect { void loop() { - const uint16_t cols = LedsV::widthV; - const uint16_t rows = LedsV::heightV; + const uint16_t cols = ledsV.widthV; + const uint16_t rows = ledsV.heightV; const uint8_t mapp = 180 / max(cols,rows); uint8_t speed = mdl->getValue("speed"); @@ -451,7 +451,7 @@ class Octopus2D: public Effect { uint16_t intensity = sin8(sin8((angle * 4 - radius) / 4 + *step/2) + radius - *step + angle * legs); intensity = map(intensity*intensity, 0, 65535, 0, 255); // add a bit of non-linearity for cleaner display CRGB color = ColorFromPalette(palette, *step / 2 - radius, intensity); - ledsV[x + y * LedsV::widthV] = color; + ledsV[x + y * ledsV.widthV] = color; } } } @@ -473,15 +473,15 @@ class Lissajous2D: public Effect { void loop() { - const uint16_t cols = LedsV::widthV; - const uint16_t rows = LedsV::heightV; + const uint16_t cols = ledsV.widthV; + const uint16_t rows = ledsV.heightV; uint8_t freqX = mdl->getValue("X frequency"); uint8_t fadeRate = mdl->getValue("Fade rate"); uint8_t speed = mdl->getValue("Speed"); bool smooth = mdl->getValue("Smooth"); - fadeToBlackBy( ledsP, LedsV::nrOfLedsP, fadeRate); + fadeToBlackBy( ledsP, ledsV.nrOfLedsP, fadeRate); uint_fast16_t phase = now * speed / 256; // allow user to control rotation speed, speed between 0 and 255! @@ -494,7 +494,7 @@ class Lissajous2D: public Effect { //SEGMENT.setPixelColorXY(xlocn, ylocn, SEGMENT.color_from_palette(strip.now/100+i, false, PALETTE_SOLID_WRAP, 0)); // draw pixel with anti-aliasing unsigned palIndex = (256*ylocn) + phase/2 + (i* freqX)/64; // SEGMENT.setPixelColorXY(xlocn, ylocn, SEGMENT.color_from_palette(palIndex, false, PALETTE_SOLID_WRAP, 0)); // draw pixel with anti-aliasing - color follows rotation - ledsV[xlocn + ylocn * LedsV::widthV] = ColorFromPalette(palette, palIndex); + ledsV[xlocn + ylocn * ledsV.widthV] = ColorFromPalette(palette, palIndex); } } else for (int i=0; i < 256; i ++) { @@ -504,7 +504,7 @@ class Lissajous2D: public Effect { xlocn = (cols < 2) ? 1 : (map(2*xlocn, 0,511, 0,2*(cols-1)) +1) /2; // softhack007: "*2 +1" for proper rounding ylocn = (rows < 2) ? 1 : (map(2*ylocn, 0,511, 0,2*(rows-1)) +1) /2; // "rows > 2" is needed to avoid div/0 in map() // SEGMENT.setPixelColorXY((uint8_t)xlocn, (uint8_t)ylocn, SEGMENT.color_from_palette(strip.now/100+i, false, PALETTE_SOLID_WRAP, 0)); - ledsV[xlocn + ylocn * LedsV::widthV] = ColorFromPalette(palette, now/100+i); + ledsV[xlocn + ylocn * ledsV.widthV] = ColorFromPalette(palette, now/100+i); } } bool controls(JsonObject parentVar) { @@ -541,7 +541,7 @@ class BouncingBalls1D: public Effect { Ball *balls = sharedData.bind(maxNumBalls); //array if (!sharedData.allocated()) return; - fill_solid(ledsP, LedsV::nrOfLedsP, CRGB::Black); + fill_solid(ledsP, ledsV.nrOfLedsP, CRGB::Black); // non-chosen color is a random color const float gravity = -9.81f; // standard value of gravity @@ -581,7 +581,7 @@ class BouncingBalls1D: public Effect { // color = SEGCOLOR(i % NUM_COLORS); // } - int pos = roundf(balls[i].height * (LedsV::nrOfLedsV - 1)); + int pos = roundf(balls[i].height * (ledsV.nrOfLedsV - 1)); CRGB color = ColorFromPalette(palette, i*(256/max(numBalls, (uint8_t)8)), 255); @@ -614,15 +614,15 @@ class RingRandomFlow:public RingEffect { } void loop() { - sharedData.allocate(sizeof(uint8_t) * LedsV::nrOfLedsV); - uint8_t *hue = sharedData.bind(LedsV::nrOfLedsV); //array + sharedData.allocate(sizeof(uint8_t) * ledsV.nrOfLedsV); + uint8_t *hue = sharedData.bind(ledsV.nrOfLedsV); //array if (!sharedData.allocated()) return; hue[0] = random(0, 255); - for (int r = 0; r < LedsV::nrOfLedsV; r++) { + for (int r = 0; r < ledsV.nrOfLedsV; r++) { setRing(r, CHSV(hue[r], 255, 255)); } - for (int r = (LedsV::nrOfLedsV - 1); r >= 1; r--) { + for (int r = (ledsV.nrOfLedsV - 1); r >= 1; r--) { hue[r] = hue[(r - 1)]; // set this ruing based on the inner } // FastLED.delay(SPEED); @@ -639,18 +639,18 @@ class GEQEffect:public Effect { } void setup() { - fadeToBlackBy( ledsP, LedsV::nrOfLedsP, 16); + fadeToBlackBy( ledsP, ledsV.nrOfLedsP, 16); } void loop() { - sharedData.allocate(sizeof(uint16_t) * LedsV::widthV + sizeof(uint32_t)); - uint16_t *previousBarHeight = sharedData.bind(LedsV::widthV); //array + sharedData.allocate(sizeof(uint16_t) * ledsV.widthV + sizeof(uint32_t)); + uint16_t *previousBarHeight = sharedData.bind(ledsV.widthV); //array uint32_t *step = sharedData.bind(); if (!sharedData.allocated()) return; const int NUM_BANDS = NUM_GEQ_CHANNELS ; // map(SEGMENT.custom1, 0, 255, 1, 16); - const uint16_t cols = LedsV::widthV; - const uint16_t rows = LedsV::heightV; + const uint16_t cols = ledsV.widthV; + const uint16_t rows = ledsV.heightV; uint8_t *fftResult = wledAudioMod->fftResults; #ifdef SR_DEBUG @@ -671,7 +671,7 @@ class GEQEffect:public Effect { int fadeoutDelay = (256 - fadeOut) / 64; //256..1 -> 4..0 size_t beat = map(beat16( fadeOut), 0, uint16_t(-1), 0, fadeoutDelay-1 ); // instead of call%fadeOutDelay - if ((fadeoutDelay <= 1 ) || (beat == 0)) fadeToBlackBy( ledsP, LedsV::nrOfLedsP, fadeOut); + if ((fadeoutDelay <= 1 ) || (beat == 0)) fadeToBlackBy( ledsP, ledsV.nrOfLedsP, fadeOut); uint16_t lastBandHeight = 0; // WLEDMM: for smoothing out bars @@ -716,11 +716,11 @@ class GEQEffect:public Effect { ledColor = ColorFromPalette(palette, (uint8_t)colorIndex); - ledsV.setPixelColor(x + LedsV::widthV * (rows-1 - y), ledColor); + ledsV.setPixelColor(x + ledsV.widthV * (rows-1 - y), ledColor); } if ((ripple < 255) && (previousBarHeight[x] > 0) && (previousBarHeight[x] < rows)) // WLEDMM avoid "overshooting" into other segments - ledsV.setPixelColor(x + LedsV::widthV * (rows - previousBarHeight[x]), ledColor); + ledsV.setPixelColor(x + ledsV.widthV * (rows - previousBarHeight[x]), ledColor); if (rippleTime && previousBarHeight[x]>0) previousBarHeight[x]--; //delay/ripple effect @@ -874,20 +874,20 @@ class Effects { //tbd: make property of effects if (strstr(effects[index]->name(), "2D")) { - if (LedsV::fxDimension != 2) { - LedsV::fxDimension = 2; + if (ledsV.fxDimension != 2) { + ledsV.fxDimension = 2; doMap = true; } } else if (strstr(effects[index]->name(), "3D")) { - if (LedsV::fxDimension != 3) { - LedsV::fxDimension = 3; + if (ledsV.fxDimension != 3) { + ledsV.fxDimension = 3; doMap = true; } } else { - if (LedsV::fxDimension != 1) { - LedsV::fxDimension = 1; + if (ledsV.fxDimension != 1) { + ledsV.fxDimension = 1; doMap = true; } } diff --git a/src/App/AppLedsV.cpp b/src/App/AppLedsV.cpp index c57f5850..7eeb0dc9 100644 --- a/src/App/AppLedsV.cpp +++ b/src/App/AppLedsV.cpp @@ -17,21 +17,6 @@ #include "../Sys/SysJsonRDWS.h" #include "../Sys/SysModPins.h" -std::vector> LedsV::mappingTable; -uint16_t LedsV::mappingTableLedCounter = 0; -uint16_t LedsV::nrOfLedsP = 64; //amount of physical leds -uint16_t LedsV::nrOfLedsV = 64; //amount of virtual leds (calculated by projection) -uint16_t LedsV::widthP = 8; -uint16_t LedsV::heightP = 8; -uint16_t LedsV::depthP = 1; -uint16_t LedsV::widthV = 8; -uint16_t LedsV::heightV = 8; -uint16_t LedsV::depthV = 1; - -uint8_t LedsV::projectionNr = -1; -uint8_t LedsV::ledFixNr = -1; -uint8_t LedsV::fxDimension = -1; - //load ledfix json file, parse it and depending on the projection, create a mapping for it void LedsV::ledFixProjectAndMap() { char fileName[32] = ""; @@ -54,9 +39,6 @@ void LedsV::ledFixProjectAndMap() { pinNr++; } - //track pins and leds - static uint8_t currPin; - static uint16_t prevLeds; prevLeds = 0; //what to deserialize @@ -67,7 +49,7 @@ void LedsV::ledFixProjectAndMap() { jrdws.lookFor("pin", &currPin); //lookFor leds array and for each item in array call lambdo to make a projection - jrdws.lookFor("leds", [](std::vector uint16CollectList) { //this will be called for each tuple of coordinates! + jrdws.lookFor("leds", [this](std::vector uint16CollectList) { //this will be called for each tuple of coordinates! // USER_PRINTF("funList "); // for (uint16_t num:uint16CollectList) // USER_PRINTF(" %d", num); @@ -81,20 +63,20 @@ void LedsV::ledFixProjectAndMap() { uint16_t y = (ledFixDimension>=2)?uint16CollectList[1] / 10 : 1; uint16_t z = (ledFixDimension>=3)?uint16CollectList[2] / 10 : 1; - // USER_PRINTF("projectionNr p:%d f:%d s:%d, %d-%d-%d %d-%d-%d\n", LedsV::projectionNr, LedsV::fxDimension, ledFixDimension, x, y, z, uint16CollectList[0], uint16CollectList[1], uint16CollectList[2]); - if (LedsV::projectionNr == p_DistanceFromPoint || LedsV::projectionNr == p_DistanceFromCentre) { + // USER_PRINTF("projectionNr p:%d f:%d s:%d, %d-%d-%d %d-%d-%d\n", projectionNr, fxDimension, ledFixDimension, x, y, z, uint16CollectList[0], uint16CollectList[1], uint16CollectList[2]); + if (projectionNr == p_DistanceFromPoint || projectionNr == p_DistanceFromCentre) { uint16_t bucket;// = -1; - if (LedsV::fxDimension == 1) { //if effect is 1D + if (fxDimension == 1) { //if effect is 1D uint16_t pointX, pointY, pointZ; - if (LedsV::projectionNr == p_DistanceFromPoint) { + if (projectionNr == p_DistanceFromPoint) { pointX = 0; pointY = 0; pointZ = 0; } else { - pointX = LedsV::widthP / 2; - pointY = LedsV::heightP / 2; - pointZ = LedsV::depthP / 2; + pointX = widthP / 2; + pointY = heightP / 2; + pointZ = depthP / 2; } if (ledFixDimension == 1) //ledfix is 1D @@ -107,7 +89,7 @@ void LedsV::ledFixProjectAndMap() { bucket = distance(x,y,z,pointX, pointY, pointZ); } - else if (LedsV::fxDimension == 2) { //effect is 2D + else if (fxDimension == 2) { //effect is 2D depthV = 1; if (ledFixDimension == 1) //ledfix is 1D bucket = x; @@ -219,7 +201,7 @@ void LedsV::ledFixProjectAndMap() { } USER_PRINTF("ledFixProjectAndMap P:%dx%dx%d V:%dx%dx%d and P:%d V:%d\n", widthP, heightP, depthP, widthV, heightV, depthV, nrOfLedsP, nrOfLedsV); - mdl->setValueV("dimensions", "P:%dx%dx%d V:%dx%dx%d", LedsV::widthP, LedsV::heightP, LedsV::depthP, LedsV::widthV, LedsV::heightV, LedsV::depthV); + mdl->setValueV("dimensions", "P:%dx%dx%d V:%dx%dx%d", widthP, heightP, depthP, widthV, heightV, depthV); mdl->setValueV("nrOfLeds", "P:%d V:%d", nrOfLedsP, nrOfLedsV); } // if deserialize diff --git a/src/App/AppLedsV.h b/src/App/AppLedsV.h index 9eca0108..d8a2dcfc 100644 --- a/src/App/AppLedsV.h +++ b/src/App/AppLedsV.h @@ -14,13 +14,6 @@ #define NUM_LEDS_Preview 8192 -//keep them global for the time being as FastLed effects refer to them and want to keep that code as unchanged as possible -//(so maybe move there?) - -static float distance(uint16_t x1, uint16_t y1, uint16_t z1, uint16_t x2, uint16_t y2, uint16_t z2) { - return sqrtf((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2)); -} - enum Projections { p_None, @@ -49,19 +42,27 @@ class LedsV { // leds = (CRGB*)malloc(nrOfLeds * sizeof(CRGB)); // leds = (CRGB*)reallocarray - static uint16_t nrOfLedsP; //amount of physical leds - static uint16_t nrOfLedsV; //amount of virtual leds (calculated by projection) + uint16_t nrOfLedsP = 64; //amount of physical leds + uint16_t nrOfLedsV = 64; //amount of virtual leds (calculated by projection) - static uint16_t widthP; - static uint16_t heightP; - static uint16_t depthP; - static uint16_t widthV; - static uint16_t heightV; - static uint16_t depthV; + uint16_t widthP = 8; + uint16_t heightP = 8; + uint16_t depthP = 1; + uint16_t widthV = 8; + uint16_t heightV = 8; + uint16_t depthV = 1; - static uint8_t projectionNr; - static uint8_t ledFixNr; - static uint8_t fxDimension; + uint8_t projectionNr = -1; + uint8_t ledFixNr = -1; + uint8_t fxDimension = -1; + + //track pins and leds + uint8_t currPin; + uint16_t prevLeds; + + float distance(uint16_t x1, uint16_t y1, uint16_t z1, uint16_t x2, uint16_t y2, uint16_t z2) { + return sqrtf((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2)); + } void ledFixProjectAndMap(); @@ -100,9 +101,8 @@ class LedsV { // } private: - //need to make these static as they are called in lambda functions - static std::vector> mappingTable; - static uint16_t mappingTableLedCounter; + std::vector> mappingTable; + uint16_t mappingTableLedCounter; }; //Global vars! diff --git a/src/App/AppModLedFixGen.h b/src/App/AppModLedFixGen.h index e5e6fc31..74ae1db5 100644 --- a/src/App/AppModLedFixGen.h +++ b/src/App/AppModLedFixGen.h @@ -484,7 +484,7 @@ class GenFix { //https://opengl.org.ru/docs/pg/0208.html void geodesicDome3D (uint16_t startX, uint16_t startY, uint16_t startZ) { - static uint8_t tindices[20][3] = { {0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1}, {8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3}, {7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6}, {6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11} }; + uint8_t tindices[20][3] = { {0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1}, {8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3}, {7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6}, {6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11} }; openPin(); @@ -764,17 +764,17 @@ class AppModLedFixGen:public Module { ui->processUiFun("ledFix"); } - static File openFile(const char * name) { - char fileName[30] = "/"; - strncat(fileName, name, sizeof(fileName)-1); - strncat(fileName, ".json", sizeof(fileName)-1); + // File openFile(const char * name) { + // char fileName[30] = "/"; + // strncat(fileName, name, sizeof(fileName)-1); + // strncat(fileName, ".json", sizeof(fileName)-1); - File f = files->open(fileName, "w"); - if (!f) - USER_PRINTF("ledFixGen Could not open file %s for writing\n", fileName); + // File f = files->open(fileName, "w"); + // if (!f) + // USER_PRINTF("ledFixGen Could not open file %s for writing\n", fileName); - return f; - } + // return f; + // } }; diff --git a/src/App/AppModLeds.h b/src/App/AppModLeds.h index 165babcf..33b2d2cf 100644 --- a/src/App/AppModLeds.h +++ b/src/App/AppModLeds.h @@ -81,9 +81,9 @@ class AppModLeds:public Module { buffer[i*3+4+2] = ledsP[i].blue; } //new values - buffer[0] = LedsV::nrOfLedsP/256; - buffer[1] = LedsV::nrOfLedsP%256; - buffer[3] = max(LedsV::nrOfLedsP * SysModWeb::ws->count()/200, 16U); //interval in ms * 10, not too fast + buffer[0] = ledsV.nrOfLedsP/256; + buffer[1] = ledsV.nrOfLedsP%256; + buffer[3] = max(ledsV.nrOfLedsP * SysModWeb::ws->count()/200, 16U); //interval in ms * 10, not too fast }); ui->initSelect(parentVar, "fx", 0, false, [this](JsonObject var) { //uiFun @@ -138,7 +138,7 @@ class AppModLeds:public Module { }, [this](JsonObject var) { //chFun USER_PRINTF("%s Change %s to %d\n", "initSelect chFun", var["id"].as(), var["value"].as()); - LedsV::projectionNr = var["value"]; + ledsV.projectionNr = var["value"]; doMap = true; ui->valChangedForInstancesTemp = true; }); @@ -157,11 +157,11 @@ class AppModLeds:public Module { }, [this](JsonObject var) { //chFun USER_PRINTF("%s Change %s to %d\n", "initSelect chFun", var["id"].as(), var["value"].as()); - LedsV::ledFixNr = var["value"]; + ledsV.ledFixNr = var["value"]; doMap = true; char fileName[32] = ""; - if (files->seqNrToName(fileName, LedsV::ledFixNr)) { + if (files->seqNrToName(fileName, ledsV.ledFixNr)) { //send to pview a message to get file filename JsonDocument *responseDoc = web->getResponseDoc(); responseDoc->clear(); //needed for deserializeJson? @@ -175,13 +175,13 @@ class AppModLeds:public Module { ui->initText(parentVar, "dimensions", nullptr, 32, true, [](JsonObject var) { //uiFun char details[32] = ""; - print->fFormat(details, sizeof(details)-1, "P:%dx%dx%d V:%dx%dx%d", LedsV::widthP, LedsV::heightP, LedsV::depthP, LedsV::widthV, LedsV::heightV, LedsV::depthV); + print->fFormat(details, sizeof(details)-1, "P:%dx%dx%d V:%dx%dx%d", ledsV.widthP, ledsV.heightP, ledsV.depthP, ledsV.widthV, ledsV.heightV, ledsV.depthV); web->addResponse(var["id"], "value", details); }); ui->initText(parentVar, "nrOfLeds", nullptr, 32, true, [](JsonObject var) { //uiFun char details[32] = ""; - print->fFormat(details, sizeof(details)-1, "P:%d V:%d", LedsV::nrOfLedsP, LedsV::nrOfLedsV); + print->fFormat(details, sizeof(details)-1, "P:%d V:%d", ledsV.nrOfLedsP, ledsV.nrOfLedsV); web->addResponse(var["id"], "value", details); web->addResponseV(var["id"], "comment", "Max %d", NUM_LEDS_Preview); }); diff --git a/src/Sys/SysJsonRDWS.h b/src/Sys/SysJsonRDWS.h index 623f94da..1d0d46ea 100644 --- a/src/Sys/SysJsonRDWS.h +++ b/src/Sys/SysJsonRDWS.h @@ -57,7 +57,7 @@ class JsonRDWS { } //look for array of integers - void lookFor(const char * id, void(*fun)(std::vector)) { + void lookFor(const char * id, std::function)> fun) { funList.push_back(fun); addToVars(id, "fun", funList.size()-1); } @@ -89,7 +89,7 @@ class JsonRDWS { std::vector uint8List; //pointer of uint8 to assign found values to (index of list stored in varDetails) std::vector uint16List; //same for uint16 std::vector charList; //same for char - std::vector)> funList; //same for function calls + std::vector)>> funList; //same for function calls std::vector varStack; //objects and arrays store their names in a stack bool collectNumbers = false; //array can ask to store all numbers found in array (now used for x,y,z coordinates) std::vector uint16CollectList; //collected numbers