From 2215ac21de066fdec9fa068bf579e5763eb43b0f Mon Sep 17 00:00:00 2001 From: Ewoud Date: Thu, 25 Jan 2024 16:20:25 +0100 Subject: [PATCH] Rename LedsV and ledsV to Leds and leds (max FastLed compatibiluty) --- platformio.ini | 2 +- src/App/AppEffects.h | 260 +++++++++++++------------- src/App/{AppLedsV.cpp => AppLeds.cpp} | 22 +-- src/App/{AppLedsV.h => AppLeds.h} | 18 +- src/App/AppModLeds.h | 238 +++++++++++------------ src/App/AppModPreview.h | 18 +- src/User/UserModArtNet.h | 6 +- src/User/UserModDDP.h | 6 +- 8 files changed, 285 insertions(+), 285 deletions(-) rename src/App/{AppLedsV.cpp => AppLeds.cpp} (97%) rename src/App/{AppLedsV.h => AppLeds.h} (94%) diff --git a/platformio.ini b/platformio.ini index 0df2d543..74fb5934 100644 --- a/platformio.ini +++ b/platformio.ini @@ -150,7 +150,7 @@ lib_deps = ; Compiler warnings FastLed: ; In file included from .pio/libdeps/esp32dev/FastLED/src/FastLED.h:75, -; from src/App/AppLedsV.h:11, +; from src/App/AppLeds.h:11, ; from src/App/AppModLeds.h:13, ; from src/main.cpp:25: ; .pio/libdeps/esp32dev/FastLED/src/fastspi.h:157:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output diff --git a/src/App/AppEffects.h b/src/App/AppEffects.h index 0740827b..0fef0166 100644 --- a/src/App/AppEffects.h +++ b/src/App/AppEffects.h @@ -73,9 +73,9 @@ class Effect { public: virtual const char * name() {return nullptr;} - virtual void setup(LedsV &ledsV) {} + virtual void setup(Leds &leds) {} - virtual void loop(LedsV &ledsV) {} + virtual void loop(Leds &leds) {} virtual bool controls(JsonObject parentVar) {return false;} @@ -114,12 +114,12 @@ class SolidEffect: public Effect { const char * name() { return "Solid 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { uint8_t red = mdl->getValue("Red"); uint8_t green = mdl->getValue("Green"); uint8_t blue = mdl->getValue("Blue"); CRGB color = CRGB(red, green, blue); - ledsV.fill_solid(color); + leds.fill_solid(color); } bool controls(JsonObject parentVar) { ui->initSlider(parentVar, "Red", 182); @@ -134,9 +134,9 @@ class RainbowEffect: public Effect { const char * name() { return "Rainbow 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { // FastLED's built-in rainbow generator - ledsV.fill_rainbow(gHue, 7); + leds.fill_rainbow(gHue, 7); } }; @@ -145,15 +145,15 @@ class RainbowWithGlitterEffect:public RainbowEffect { const char * name() { return "Rainbow with glitter 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { // built-in FastLED rainbow, plus some random sparkly glitter - RainbowEffect::loop(ledsV); - addGlitter(ledsV, 80); + RainbowEffect::loop(leds); + addGlitter(leds, 80); } - void addGlitter(LedsV &ledsV, fract8 chanceOfGlitter) + void addGlitter(Leds &leds, fract8 chanceOfGlitter) { if( random8() < chanceOfGlitter) { - ledsV[ random16(ledsV.nrOfLedsV) ] += CRGB::White; + leds[ random16(leds.nrOfLeds) ] += CRGB::White; } } }; @@ -163,13 +163,13 @@ class SinelonEffect: public Effect { const char * name() { return "Sinelon 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { // a colored dot sweeping back and forth, with fading trails - ledsV.fadeToBlackBy(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]; + leds.fadeToBlackBy(20); + int pos = beatsin16( mdl->getValue("BPM").as(), 0, leds.nrOfLeds-1 ); + // leds[pos] += CHSV( gHue, 255, 192); + leds[pos] = leds.getPixelColor(pos) + CHSV( gHue, 255, 192); + // CRGB x = leds[pos]; } bool controls(JsonObject parentVar) { ui->initSlider(parentVar, "BPM", 60); @@ -183,13 +183,13 @@ class RunningEffect: public Effect { const char * name() { return "Running 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { // a colored dot sweeping back and forth, with fading trails - ledsV.fadeToBlackBy(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 + leds.fadeToBlackBy(mdl->getValue("fade").as()); //physical leds + int pos = map(beat16( mdl->getValue("BPM").as()), 0, uint16_t(-1), 0, leds.nrOfLeds-1 ); //instead of call%leds.nrOfLeds + // int pos2 = map(beat16( mdl->getValue("BPM").as(), 1000), 0, uint16_t(-1), 0, leds.nrOfLeds-1 ); //one second later + 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) { ui->initSlider(parentVar, "BPM", 60, 0, 255, false, [](JsonObject var) { //uiFun @@ -205,11 +205,11 @@ class ConfettiEffect: public Effect { const char * name() { return "Confetti 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { // random colored speckles that blink in and fade smoothly - ledsV.fadeToBlackBy(10); - int pos = random16(ledsV.nrOfLedsV); - ledsV[pos] += CHSV( gHue + random8(64), 200, 255); + leds.fadeToBlackBy(10); + int pos = random16(leds.nrOfLeds); + leds[pos] += CHSV( gHue + random8(64), 200, 255); } }; @@ -219,12 +219,12 @@ class BPMEffect: public Effect { return "Beats per minute 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { // 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 - ledsV[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); + for( int i = 0; i < leds.nrOfLeds; i++) { //9948 + leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); } } bool controls(JsonObject parentVar) { @@ -238,12 +238,12 @@ class JuggleEffect: public Effect { const char * name() { return "Juggle 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { // eight colored dots, weaving in and out of sync with each other - ledsV.fadeToBlackBy(20); + leds.fadeToBlackBy(20); uint8_t dothue = 0; for( int i = 0; i < 8; i++) { - ledsV[beatsin16( i+7, 0, ledsV.nrOfLedsV-1 )] |= CHSV(dothue, 200, 255); + leds[beatsin16( i+7, 0, leds.nrOfLeds-1 )] |= CHSV(dothue, 200, 255); dothue += 32; } } @@ -254,24 +254,24 @@ class Ripples3DEffect: public Effect { const char * name() { return "Ripples 3D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { uint8_t interval = mdl->getValue("interval"); float ripple_interval = 1.3 * (interval/128.0); - ledsV.fill_solid(CRGB::Black); + leds.fill_solid(CRGB::Black); // fill(CRGB::Black); - uint16_t mW = ledsV.widthV; - uint16_t mH = ledsV.heightV; - uint16_t mD = ledsV.depthV; + uint16_t mW = leds.widthV; + uint16_t mH = leds.heightV; + uint16_t mD = leds.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, leds.widthV - 1); + uint8_t y = beatsin8(mdl->getValue("intensity").as()/8 - i, 0, leds.heightV - 1); CRGB color = ColorFromPalette(palette, beatsin8(12, 0, 255), 255); - ledsV[ledsV.XY(x,y)] = color; + leds[leds.XY(x,y)] = color; } - ledsV.blur2d(ledsV.widthV, ledsV.heightV, mdl->getValue("blur")); + leds.blur2d(leds.widthV, leds.heightV, mdl->getValue("blur")); } bool controls(JsonObject parentVar) { addPalette(parentVar); @@ -358,19 +358,19 @@ class Lines2D: public Effect { return "Lines 2D"; } - void loop(LedsV &ledsV) { - ledsV.fadeToBlackBy(100); + void loop(Leds &leds) { + leds.fadeToBlackBy(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, leds.widthV-1 ); //instead of call%width - for (size_t y = 0; y < ledsV.heightV; y++) { - ledsV[ledsV.XY(x,y)] = CHSV( gHue, 255, 192); + for (size_t y = 0; y < leds.heightV; y++) { + leds[leds.XY(x,y)] = 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[ledsV.XY(x,y)] = CHSV( gHue, 255, 192); + size_t y = map(beat16( mdl->getValue("BPM").as()), 0, uint16_t(-1), 0, leds.heightV-1 ); //instead of call%height + for (size_t x = 0; x < leds.widthV; x++) { + leds[leds.XY(x,y)] = CHSV( gHue, 255, 192); } } } @@ -393,9 +393,9 @@ class DistortionWaves2D: public Effect { return "DistortionWaves 2D"; } - void loop(LedsV &ledsV) { - const uint16_t cols = ledsV.widthV; - const uint16_t rows = ledsV.heightV; + void loop(Leds &leds) { + const uint16_t cols = leds.widthV; + const uint16_t rows = leds.heightV; uint8_t speed = mdl->getValue("speed").as()/32; uint8_t scale = mdl->getValue("scale").as()/32; @@ -433,7 +433,7 @@ class DistortionWaves2D: public Effect { valueG = gamma8(cos8(valueG)); valueB = gamma8(cos8(valueB)); - ledsV[ledsV.XY(x,y)] = CRGB(valueR, valueG, valueB); + leds[leds.XY(x,y)] = CRGB(valueR, valueG, valueB); } } } @@ -457,10 +457,10 @@ class Octopus2D: public Effect { uint8_t radius; } map_t; - void loop(LedsV &ledsV) { + void loop(Leds &leds) { - const uint16_t cols = ledsV.widthV; - const uint16_t rows = ledsV.heightV; + const uint16_t cols = leds.widthV; + const uint16_t rows = leds.heightV; const uint8_t mapp = 180 / max(cols,rows); uint8_t speed = mdl->getValue("speed"); @@ -488,8 +488,8 @@ class Octopus2D: public Effect { const uint8_t C_Y = rows / 2 + (offsetY - 128)*rows/255; for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { - rMap[ledsV.XY(x, y)].angle = 40.7436f * atan2f(y - C_Y, x - C_X); // avoid 128*atan2()/PI - rMap[ledsV.XY(x, y)].radius = hypotf(x - C_X, y - C_Y) * mapp; //thanks Sutaburosu + rMap[leds.XY(x, y)].angle = 40.7436f * atan2f(y - C_Y, x - C_X); // avoid 128*atan2()/PI + rMap[leds.XY(x, y)].radius = hypotf(x - C_X, y - C_Y) * mapp; //thanks Sutaburosu } } } @@ -498,13 +498,13 @@ class Octopus2D: public Effect { for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { - byte angle = rMap[ledsV.XY(x,y)].angle; - byte radius = rMap[ledsV.XY(x,y)].radius; + byte angle = rMap[leds.XY(x,y)].angle; + byte radius = rMap[leds.XY(x,y)].radius; //CRGB c = CHSV(SEGENV.step / 2 - radius, 255, sin8(sin8((angle * 4 - radius) / 4 + SEGENV.step) + radius - SEGENV.step * 2 + angle * (SEGMENT.custom3/3+1))); 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[ledsV.XY(x,y)] = color; + leds[leds.XY(x,y)] = color; } } } @@ -525,17 +525,17 @@ class Lissajous2D: public Effect { return "Lissajous 2D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { - const uint16_t cols = ledsV.widthV; - const uint16_t rows = ledsV.heightV; + const uint16_t cols = leds.widthV; + const uint16_t rows = leds.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"); - ledsV.fadeToBlackBy(fadeRate); + leds.fadeToBlackBy(fadeRate); uint_fast16_t phase = now * speed / 256; // allow user to control rotation speed, speed between 0 and 255! @@ -548,7 +548,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[ledsV.XY(xlocn, ylocn)] = ColorFromPalette(palette, palIndex); + leds[leds.XY(xlocn, ylocn)] = ColorFromPalette(palette, palIndex); } } else for (int i=0; i < 256; i ++) { @@ -558,7 +558,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[ledsV.XY(xlocn, ylocn)] = ColorFromPalette(palette, now/100+i); + leds[leds.XY(xlocn, ylocn)] = ColorFromPalette(palette, now/100+i); } } bool controls(JsonObject parentVar) { @@ -588,7 +588,7 @@ class BouncingBalls1D: public Effect { return "Bouncing Balls 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { uint8_t grav = mdl->getValue("gravity"); uint8_t numBalls = mdl->getValue("balls"); @@ -596,14 +596,14 @@ class BouncingBalls1D: public Effect { Ball *balls = sharedData.bind(maxNumBalls); //array if (!sharedData.allocated()) return; - ledsV.fill_solid(CRGB::Black); + leds.fill_solid(CRGB::Black); // non-chosen color is a random color const float gravity = -9.81f; // standard value of gravity // const bool hasCol2 = SEGCOLOR(2); const unsigned long time = now; - //not necessary as sharedData is cleared at setup(LedsV &ledsV) + //not necessary as sharedData is cleared at setup(Leds &leds) // if (call == 0) { // for (size_t i = 0; i < maxNumBalls; i++) balls[i].lastBounceTime = time; // } @@ -636,11 +636,11 @@ class BouncingBalls1D: public Effect { // color = SEGCOLOR(i % NUM_COLORS); // } - int pos = roundf(balls[i].height * (ledsV.nrOfLedsV - 1)); + int pos = roundf(balls[i].height * (leds.nrOfLeds - 1)); CRGB color = ColorFromPalette(palette, i*(256/max(numBalls, (uint8_t)8)), 255); - ledsV[pos] = color; + leds[pos] = color; // if (SEGLEN<32) SEGMENT.setPixelColor(indexToVStrip(pos, stripNr), color); // encode virtual strip into index // else SEGMENT.setPixelColor(balls[i].height + (stripNr+1)*10.0f, color); } //balls @@ -657,8 +657,8 @@ class BouncingBalls1D: public Effect { class RingEffect:public Effect { protected: - void setRing(LedsV &ledsV, int ring, CRGB colour) { //so britisch ;-) - ledsV[ring] = colour; + void setRing(Leds &leds, int ring, CRGB colour) { //so britisch ;-) + leds[ring] = colour; } }; @@ -669,16 +669,16 @@ class RingRandomFlow:public RingEffect { return "RingRandomFlow 1D"; } - void loop(LedsV &ledsV) { - sharedData.allocate(sizeof(uint8_t) * ledsV.nrOfLedsV); - uint8_t *hue = sharedData.bind(ledsV.nrOfLedsV); //array + void loop(Leds &leds) { + sharedData.allocate(sizeof(uint8_t) * leds.nrOfLeds); + uint8_t *hue = sharedData.bind(leds.nrOfLeds); //array if (!sharedData.allocated()) return; hue[0] = random(0, 255); - for (int r = 0; r < ledsV.nrOfLedsV; r++) { - setRing(ledsV, r, CHSV(hue[r], 255, 255)); + for (int r = 0; r < leds.nrOfLeds; r++) { + setRing(leds, r, CHSV(hue[r], 255, 255)); } - for (int r = (ledsV.nrOfLedsV - 1); r >= 1; r--) { + for (int r = (leds.nrOfLeds - 1); r >= 1; r--) { hue[r] = hue[(r - 1)]; // set this ruing based on the inner } // FastLED.delay(SPEED); @@ -694,19 +694,19 @@ class GEQEffect:public Effect { return "GEQ 2D"; } - void setup(LedsV &ledsV) { - ledsV.fadeToBlackBy(16); + void setup(Leds &leds) { + leds.fadeToBlackBy(16); } - void loop(LedsV &ledsV) { - sharedData.allocate(sizeof(uint16_t) * ledsV.widthV + sizeof(uint32_t)); - uint16_t *previousBarHeight = sharedData.bind(ledsV.widthV); //array + void loop(Leds &leds) { + sharedData.allocate(sizeof(uint16_t) * leds.widthV + sizeof(uint32_t)); + uint16_t *previousBarHeight = sharedData.bind(leds.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 = leds.widthV; + const uint16_t rows = leds.heightV; uint8_t *fftResult = wledAudioMod->fftResults; #ifdef SR_DEBUG @@ -727,7 +727,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)) ledsV.fadeToBlackBy(fadeOut); + if ((fadeoutDelay <= 1 ) || (beat == 0)) leds.fadeToBlackBy(fadeOut); uint16_t lastBandHeight = 0; // WLEDMM: for smoothing out bars @@ -772,11 +772,11 @@ class GEQEffect:public Effect { ledColor = ColorFromPalette(palette, (uint8_t)colorIndex); - ledsV.setPixelColor(ledsV.XY(x, rows - 1 - y), ledColor); + leds.setPixelColor(leds.XY(x, rows - 1 - y), ledColor); } if ((ripple > 0) && (previousBarHeight[x] > 0) && (previousBarHeight[x] < rows)) // WLEDMM avoid "overshooting" into other segments - ledsV.setPixelColor(ledsV.XY(x, rows - previousBarHeight[x]), CHSV( gHue, 255, 192)); // take gHue color for the time being + leds.setPixelColor(leds.XY(x, rows - previousBarHeight[x]), CHSV( gHue, 255, 192)); // take gHue color for the time being if (rippleTime && previousBarHeight[x]>0) previousBarHeight[x]--; //delay/ripple effect @@ -812,7 +812,7 @@ class AudioRings:public RingEffect { return "AudioRings 1D"; } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { uint8_t *fftResult = wledAudioMod->fftResults; for (int i = 0; i < 7; i++) { // 7 rings @@ -830,21 +830,21 @@ class AudioRings:public RingEffect { CRGB color = ColorFromPalette(palette, val, val); // CRGB color = ColorFromPalette(currentPalette, val, 255, currentBlending); // color.nscale8_video(val); - setRing(ledsV, i, color); + setRing(leds, i, color); // setRingFromFtt((i * 2), i); } - setRingFromFtt(ledsV, 2, 7); // set outer ring to bass - setRingFromFtt(ledsV, 0, 8); // set outer ring to bass + setRingFromFtt(leds, 2, 7); // set outer ring to bass + setRingFromFtt(leds, 0, 8); // set outer ring to bass } - void setRingFromFtt(LedsV &ledsV, int index, int ring) { + void setRingFromFtt(Leds &leds, int index, int ring) { uint8_t *fftResult = wledAudioMod->fftResults; uint8_t val = fftResult[index]; // Visualize leds to the beat CRGB color = ColorFromPalette(palette, val, 255); color.nscale8_video(val); - setRing(ledsV, ring, color); + setRing(leds, ring, color); } bool controls(JsonObject parentVar) { @@ -860,11 +860,11 @@ class FreqMatrix:public Effect { return "FreqMatrix 1D"; } - void setup(LedsV &ledsV) { - ledsV.fadeToBlackBy(16); + void setup(Leds &leds) { + leds.fadeToBlackBy(16); } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { sharedData.allocate(sizeof(uint8_t)); uint8_t *aux0 = sharedData.bind(); if (!sharedData.allocated()) return; @@ -905,8 +905,8 @@ class FreqMatrix:public Effect { } // shift the pixels one pixel up - ledsV.setPixelColor(0, color); - for (int i = ledsV.nrOfLedsV - 1; i > 0; i--) ledsV.setPixelColor(i, ledsV.getPixelColor(i-1)); + leds.setPixelColor(0, color); + for (int i = leds.nrOfLeds - 1; i > 0; i--) leds.setPixelColor(i, leds.getPixelColor(i-1)); } } @@ -980,10 +980,10 @@ class Effects { // #endif } - void loop(LedsV &ledsV) { + void loop(Leds &leds) { now = millis(); //tbd timebase - effects[ledsV.fx%effects.size()]->loop(ledsV); + effects[leds.fx%effects.size()]->loop(leds); call++; @@ -994,34 +994,34 @@ class Effects { return effects.size(); } - bool setEffect(LedsV &ledsV, JsonObject parentVar, uint8_t rowNr) { + bool setEffect(Leds &leds, JsonObject parentVar, uint8_t rowNr) { bool doMap = false; - ledsV.fx = mdl->getValue(parentVar, rowNr); + leds.fx = mdl->getValue(parentVar, rowNr); if (rowNr != UINT8_MAX) parentVar["rowNr"] = rowNr; //store the rownNr of the updated value to send back to ui - USER_PRINTF("setEffect %d\n", ledsV.fx); + USER_PRINTF("setEffect %d\n", leds.fx); - if (ledsV.fx < size()) { + if (leds.fx < size()) { //tbd: make property of effects - if (strstr(effects[ledsV.fx]->name(), "2D")) { - if (ledsV.effectDimension != 2) { - ledsV.effectDimension = 2; + if (strstr(effects[leds.fx]->name(), "2D")) { + if (leds.effectDimension != 2) { + leds.effectDimension = 2; doMap = true; } } - else if (strstr(effects[ledsV.fx]->name(), "3D")) { - if (ledsV.effectDimension != 3) { - ledsV.effectDimension = 3; + else if (strstr(effects[leds.fx]->name(), "3D")) { + if (leds.effectDimension != 3) { + leds.effectDimension = 3; doMap = true; } } else { - if (ledsV.effectDimension != 1) { - ledsV.effectDimension = 1; + if (leds.effectDimension != 1) { + leds.effectDimension = 1; doMap = true; } } @@ -1054,10 +1054,10 @@ class Effects { // // else // // parentVar.remove("n"); //tbd: we should also remove the uiFun and chFun !! - Effect* effect = effects[ledsV.fx]; + Effect* effect = effects[leds.fx]; effect->controls(parentVar); //tbd: add rowNr... - effect->setup(ledsV); //if changed then run setup once (like call==0 in WLED) + effect->setup(leds); //if changed then run setup once (like call==0 in WLED) JsonDocument *responseDoc = web->getResponseDoc(); responseDoc->clear(); //needed for deserializeJson? diff --git a/src/App/AppLedsV.cpp b/src/App/AppLeds.cpp similarity index 97% rename from src/App/AppLedsV.cpp rename to src/App/AppLeds.cpp index 4104a7f6..df679e01 100644 --- a/src/App/AppLedsV.cpp +++ b/src/App/AppLeds.cpp @@ -9,7 +9,7 @@ @license For non GPL-v3 usage, commercial licenses must be purchased. Contact moonmodules@icloud.com */ -#include "AppLedsV.h" +#include "AppLeds.h" #include "../Sys/SysModPrint.h" #include "../Sys/SysModModel.h" @@ -23,7 +23,7 @@ #define _3D 3 //load fixture json file, parse it and depending on the projection, create a mapping for it -void LedsV::fixtureProjectAndMap() { +void Leds::fixtureProjectAndMap() { char fileName[32] = ""; if (files->seqNrToName(fileName, fixtureNr)) { @@ -289,11 +289,11 @@ void LedsV::fixtureProjectAndMap() { widthV = widthP; heightV = heightP; depthV = depthP; - nrOfLedsV = nrOfLedsP; + nrOfLeds = nrOfLedsP; } if (projectionNr > p_Random) { - nrOfLedsV = mappingTable.size(); + nrOfLeds = mappingTable.size(); // uint16_t x=0; // uint16_t y=0; @@ -310,9 +310,9 @@ void LedsV::fixtureProjectAndMap() { // } } - USER_PRINTF("fixtureProjectAndMap P:%dx%dx%d V:%dx%dx%d and P:%d V:%d\n", widthP, heightP, depthP, widthV, heightV, depthV, nrOfLedsP, nrOfLedsV); + USER_PRINTF("fixtureProjectAndMap P:%dx%dx%d V:%dx%dx%d and P:%d V:%d\n", widthP, heightP, depthP, widthV, heightV, depthV, nrOfLedsP, nrOfLeds); 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); + mdl->setValueV("nrOfLeds", "P:%d V:%d", nrOfLedsP, nrOfLeds); } // if deserialize } //if fileName @@ -321,7 +321,7 @@ void LedsV::fixtureProjectAndMap() { } // indexVLocal stored to be used by other operators -LedsV& LedsV::operator[](uint16_t indexV) { +Leds& Leds::operator[](uint16_t indexV) { indexVLocal = indexV; return *this; } @@ -333,13 +333,13 @@ LedsV& LedsV::operator[](uint16_t indexV) { // } // uses indexVLocal and color to call setPixelColor -LedsV& LedsV::operator=(const CRGB color) { +Leds& Leds::operator=(const CRGB color) { setPixelColor(indexVLocal, color); return *this; } // maps the virtual led to the physical led(s) and assign a color to it -void LedsV::setPixelColor(int indexV, CRGB color) { +void Leds::setPixelColor(int indexV, CRGB color) { if (mappingTable.size()) { if (indexV >= mappingTable.size()) return; for (uint16_t indexP:mappingTable[indexV]) { @@ -351,7 +351,7 @@ void LedsV::setPixelColor(int indexV, CRGB color) { ledsPhysical[projectionNr==p_Random?random(nrOfLedsP):indexV] = color; } -CRGB LedsV::getPixelColor(int indexV) { +CRGB Leds::getPixelColor(int indexV) { if (mappingTable.size()) { if (indexV >= mappingTable.size()) return CRGB::Black; if (!mappingTable[indexV].size() || mappingTable[indexV][0] > NUM_LEDS_Max) return CRGB::Black; @@ -362,6 +362,6 @@ CRGB LedsV::getPixelColor(int indexV) { return ledsPhysical[indexV]; } -void LedsV::addPixelColor(int indexV, CRGB color) { +void Leds::addPixelColor(int indexV, CRGB color) { setPixelColor(indexV, getPixelColor(indexV) + color); } \ No newline at end of file diff --git a/src/App/AppLedsV.h b/src/App/AppLeds.h similarity index 94% rename from src/App/AppLedsV.h rename to src/App/AppLeds.h index bdb15900..ffca81e5 100644 --- a/src/App/AppLedsV.h +++ b/src/App/AppLeds.h @@ -1,6 +1,6 @@ /* @title StarMod - @file AppLedsV.h + @file AppLeds.h @date 20240114 @repo https://github.com/ewowi/StarMod @Authors https://github.com/ewowi/StarMod/commits/main @@ -38,11 +38,11 @@ enum Projections count }; -class LedsV { +class Leds { public: - //tbd: move ledsPhysical and nrOfLedsP out of ledsV + //tbd: move ledsPhysical and nrOfLedsP out of Leds // CRGB *leds = nullptr; CRGB ledsPhysical[NUM_LEDS_Max]; // if (!leds) @@ -56,7 +56,7 @@ class LedsV { uint16_t nrOfLedsP = 64; //amount of physical leds - uint16_t nrOfLedsV = 64; //amount of virtual leds (calculated by projection) + uint16_t nrOfLeds = 64; //amount of virtual leds (calculated by projection) uint16_t widthP = 8; uint16_t heightP = 8; @@ -90,7 +90,7 @@ class LedsV { uint16_t indexVLocal = 0; //set in operator[], used by operator= - LedsV& operator[](uint16_t indexV); + Leds& operator[](uint16_t indexV); // CRGB& operator[](uint16_t indexV) { // // indexVLocal = indexV; @@ -98,7 +98,7 @@ class LedsV { // return x; // } - LedsV& operator=(const CRGB color); + Leds& operator=(const CRGB color); // maps the virtual led to the physical led(s) and assign a color to it void setPixelColor(int indexV, CRGB color); @@ -107,17 +107,17 @@ class LedsV { void addPixelColor(int indexV, CRGB color); - LedsV& operator+=(const CRGB color) { + Leds& operator+=(const CRGB color) { setPixelColor(indexVLocal, getPixelColor(indexVLocal) + color); return *this; } - LedsV& operator|=(const CRGB color) { + Leds& operator|=(const CRGB color) { // setPixelColor(indexVLocal, color); setPixelColor(indexVLocal, getPixelColor(indexVLocal) | color); return *this; } - // LedsV& operator+(const CRGB color) { + // Leds& operator+(const CRGB color) { // setPixelColor(indexVLocal, getPixelColor(indexVLocal) + color); // return *this; // } diff --git a/src/App/AppModLeds.h b/src/App/AppModLeds.h index ca1d64c2..38a8c1fb 100644 --- a/src/App/AppModLeds.h +++ b/src/App/AppModLeds.h @@ -11,7 +11,7 @@ #include "SysModule.h" -#include "AppLedsV.h" +#include "AppLeds.h" #include "AppEffects.h" #ifdef USERMOD_E131 #include "../User/UserModE131.h" @@ -50,7 +50,7 @@ class AppModLeds:public SysModule { bool doMap = false; Effects effects; - LedsV ledsV = LedsV(); //virtual leds + Leds leds = Leds(); //virtual leds AppModLeds() :SysModule("Leds") {}; @@ -109,7 +109,7 @@ class AppModLeds:public SysModule { select.add(effect->name()); } }, [this](JsonObject var, uint8_t rowNr) { //chFun - doMap = effects.setEffect(ledsV, var, rowNr); + doMap = effects.setEffect(leds, var, rowNr); }); currentVar["stage"] = true; @@ -135,7 +135,7 @@ class AppModLeds:public SysModule { // } }, [this](JsonObject var, uint8_t rowNr) { //chFun - ledsV.projectionNr = mdl->getValue(var, rowNr); + leds.projectionNr = mdl->getValue(var, rowNr); doMap = true; }); @@ -145,18 +145,18 @@ class AppModLeds:public SysModule { web->addResponse(var["id"], "label", "Start"); }, [this](JsonObject var, uint8_t rowNr) { //chFun - ledsV.fadeToBlackBy(); + leds.fadeToBlackBy(); - ledsV.startPos = mdl->getValue(var, rowNr).as(); + leds.startPos = mdl->getValue(var, rowNr).as(); doMap = true; }); ui->initCoord3D(tableVar, "fxEnd", 0, 0, 127, false, [](JsonObject var) { //uiFun web->addResponse(var["id"], "label", "End"); }, [this](JsonObject var, uint8_t rowNr) { //chFun - ledsV.fadeToBlackBy(); + leds.fadeToBlackBy(); - ledsV.endPos = mdl->getValue(var, rowNr).as(); + leds.endPos = mdl->getValue(var, rowNr).as(); doMap = true; }); @@ -172,11 +172,11 @@ class AppModLeds:public SysModule { } }, [this](JsonObject var, uint8_t) { //chFun - ledsV.fixtureNr = var["value"]; + leds.fixtureNr = var["value"]; doMap = true; char fileName[32] = ""; - if (files->seqNrToName(fileName, ledsV.fixtureNr)) { + if (files->seqNrToName(fileName, leds.fixtureNr)) { //send to pview a message to get file filename JsonDocument *responseDoc = web->getResponseDoc(); responseDoc->clear(); //needed for deserializeJson? @@ -189,11 +189,11 @@ class AppModLeds:public SysModule { }); //fixture ui->initText(tableVar, "dimensions", nullptr, 32, true, [this](JsonObject var) { //uiFun - web->addResponseV(var["id"], "value", "P:%dx%dx%d V:%dx%dx%d", ledsV.widthP, ledsV.heightP, ledsV.depthP, ledsV.widthV, ledsV.heightV, ledsV.depthV); + web->addResponseV(var["id"], "value", "P:%dx%dx%d V:%dx%dx%d", leds.widthP, leds.heightP, leds.depthP, leds.widthV, leds.heightV, leds.depthV); }); ui->initText(tableVar, "nrOfLeds", nullptr, 32, true, [this](JsonObject var) { //uiFun - web->addResponseV(var["id"], "value", "P:%d V:%d", ledsV.nrOfLedsP, ledsV.nrOfLedsV); + web->addResponseV(var["id"], "value", "P:%d V:%d", leds.nrOfLedsP, leds.nrOfLeds); web->addResponseV(var["id"], "comment", "Max %d", NUM_LEDS_Max); }); @@ -242,7 +242,7 @@ class AppModLeds:public SysModule { //for each programmed effect // run the next frame of the effect - effects.loop(ledsV); + effects.loop(leds); FastLED.show(); @@ -257,12 +257,12 @@ class AppModLeds:public SysModule { const char * canvasData = var["canvasData"]; //0 - 494 - 140,150,0 USER_PRINTF("AppModLeds loop canvasData %s\n", canvasData); - ledsV.fadeToBlackBy(); + leds.fadeToBlackBy(); char * token = strtok((char *)canvasData, ":"); bool isStart = strcmp(token, "start") == 0; - Coord3D *startOrEndPos = isStart? &ledsV.startPos: &ledsV.endPos; + Coord3D *startOrEndPos = isStart? &leds.startPos: &leds.endPos; token = strtok(NULL, ","); if (token != NULL) startOrEndPos->x = atoi(token) / 10; else startOrEndPos->x = 0; //should never happen @@ -281,7 +281,7 @@ class AppModLeds:public SysModule { if (millis() - lastMappingMillis >= 1000 && doMap) { //not more then once per second (for E131) lastMappingMillis = millis(); doMap = false; - ledsV.fixtureProjectAndMap(); + leds.fixtureProjectAndMap(); //https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples @@ -302,112 +302,112 @@ class AppModLeds:public SysModule { //commented pins: error: static assertion failed: Invalid pin specified switch (pinNr) { #if CONFIG_IDF_TARGET_ESP32 - case 0: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 1: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 2: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 3: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 4: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 5: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 6: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 7: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 8: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 9: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 10: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 11: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 12: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 13: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 14: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 15: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 16: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 17: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 18: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 19: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 20: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 21: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 22: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 23: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 24: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 25: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 26: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 27: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 28: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 29: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 30: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 31: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 32: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 33: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 34: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 35: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 36: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 37: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 38: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 39: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 40: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 41: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 42: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 43: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 44: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 45: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 46: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 47: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 48: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 49: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 50: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; + case 0: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 1: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 2: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 3: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 4: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 5: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 6: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 7: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 8: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 9: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 10: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 11: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 12: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 13: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 14: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 15: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 16: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 17: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 18: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 19: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 20: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 21: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 22: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 23: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 24: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 25: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 26: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 27: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 28: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 29: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 30: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 31: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 32: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 33: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 34: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 35: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 36: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 37: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 38: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 39: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 40: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 41: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 42: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 43: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 44: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 45: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 46: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 47: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 48: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 49: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 50: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; #endif //CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32S2 - case 0: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 1: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 2: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 3: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 4: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 5: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 6: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 7: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 8: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 9: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 10: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 11: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 12: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 13: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 14: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 15: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 16: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 17: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 18: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 19: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 20: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 21: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 22: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 23: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 24: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 25: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 26: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 27: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 28: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 29: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 30: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 31: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 32: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 33: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 34: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 35: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 36: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 37: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 38: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 39: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 40: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 41: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 42: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 43: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 44: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - case 45: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 46: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 47: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 48: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 49: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 50: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; - // case 51: FastLED.addLeds(ledsV.ledsPhysical, startLed, nrOfLeds); break; + case 0: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 1: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 2: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 3: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 4: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 5: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 6: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 7: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 8: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 9: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 10: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 11: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 12: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 13: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 14: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 15: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 16: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 17: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 18: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 19: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 20: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 21: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 22: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 23: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 24: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 25: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 26: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 27: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 28: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 29: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 30: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 31: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 32: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 33: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 34: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 35: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 36: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 37: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 38: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 39: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 40: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 41: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 42: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 43: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 44: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + case 45: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 46: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 47: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 48: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 49: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 50: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; + // case 51: FastLED.addLeds(leds.ledsPhysical, startLed, nrOfLeds); break; #endif //CONFIG_IDF_TARGET_ESP32S2 default: USER_PRINTF("FastLedPin assignment: pin not supported %d\n", pinNr); diff --git a/src/App/AppModPreview.h b/src/App/AppModPreview.h index 28abf8bc..682e0e56 100644 --- a/src/App/AppModPreview.h +++ b/src/App/AppModPreview.h @@ -30,7 +30,7 @@ class AppModPreview:public SysModule { // web->addResponse(var["id"], "comment", "Click to enlarge"); }, nullptr, [](JsonObject var, uint8_t rowNr) { //loopFun - var["interval"] = max(lds->ledsV.nrOfLedsP * web->ws->count()/200, 16U)*10; //interval in ms * 10, not too fast //from cs to ms + var["interval"] = max(lds->leds.nrOfLedsP * web->ws->count()/200, 16U)*10; //interval in ms * 10, not too fast //from cs to ms web->sendDataWs([](AsyncWebSocketMessageBuffer * wsBuf) { uint8_t* buffer; @@ -38,19 +38,19 @@ class AppModPreview:public SysModule { buffer = wsBuf->get(); // send leds preview to clients - for (size_t i = 0; i < lds->ledsV.nrOfLedsP; i++) + for (size_t i = 0; i < lds->leds.nrOfLedsP; i++) { - buffer[i*3+5] = lds->ledsV.ledsPhysical[i].red; - buffer[i*3+5+1] = lds->ledsV.ledsPhysical[i].green; - buffer[i*3+5+2] = lds->ledsV.ledsPhysical[i].blue; + buffer[i*3+5] = lds->leds.ledsPhysical[i].red; + buffer[i*3+5+1] = lds->leds.ledsPhysical[i].green; + buffer[i*3+5+2] = lds->leds.ledsPhysical[i].blue; } //new values buffer[0] = 1; //userFun id - // buffer[1] = ledsV.nrOfLedsP/256; - // buffer[2] = ledsV.nrOfLedsP%256; - // buffer[4] = max(ledsV.nrOfLedsP * SysModWeb::ws->count()/200, 16U); //interval in ms * 10, not too fast + // buffer[1] = leds.nrOfLedsP/256; + // buffer[2] = leds.nrOfLedsP%256; + // buffer[4] = max(leds.nrOfLedsP * SysModWeb::ws->count()/200, 16U); //interval in ms * 10, not too fast - }, lds->ledsV.nrOfLedsP * 3 + 5, true); + }, lds->leds.nrOfLedsP * 3 + 5, true); }); } }; diff --git a/src/User/UserModArtNet.h b/src/User/UserModArtNet.h index 3620708b..afa38a8f 100644 --- a/src/User/UserModArtNet.h +++ b/src/User/UserModArtNet.h @@ -76,7 +76,7 @@ class UserModArtNet:public SysModule { // calculate the number of UDP packets we need to send bool isRGBW = false; - const size_t channelCount = lds->ledsV.nrOfLedsP * (isRGBW?4:3); // 1 channel for every R,G,B,(W?) value + const size_t channelCount = lds->leds.nrOfLedsP * (isRGBW?4:3); // 1 channel for every R,G,B,(W?) value const size_t ARTNET_CHANNELS_PER_PACKET = isRGBW?512:510; // 512/4=128 RGBW LEDs, 510/3=170 RGB LEDs const size_t packetCount = ((channelCount-1)/ARTNET_CHANNELS_PER_PACKET)+1; @@ -117,8 +117,8 @@ class UserModArtNet:public SysModule { ddpUdp.write(0xFF & (packetSize >> 8)); // 16-bit length of channel data, MSB ddpUdp.write(0xFF & (packetSize )); // 16-bit length of channel data, LSB - for (size_t i = 0; i < lds->ledsV.nrOfLedsP; i++) { - CRGB pixel = lds->ledsV.ledsPhysical[i]; + for (size_t i = 0; i < lds->leds.nrOfLedsP; i++) { + CRGB pixel = lds->leds.ledsPhysical[i]; ddpUdp.write(scale8(pixel.r, bri)); // R ddpUdp.write(scale8(pixel.g, bri)); // G ddpUdp.write(scale8(pixel.b, bri)); // B diff --git a/src/User/UserModDDP.h b/src/User/UserModDDP.h index ee9b5fba..4f969fd1 100644 --- a/src/User/UserModDDP.h +++ b/src/User/UserModDDP.h @@ -93,7 +93,7 @@ class UserModDDP:public SysModule { // calculate the number of UDP packets we need to send bool isRGBW = false; - const size_t channelCount = lds->ledsV.nrOfLedsP * (isRGBW? 4:3); // 1 channel for every R,G,B,(W?) value + const size_t channelCount = lds->leds.nrOfLedsP * (isRGBW? 4:3); // 1 channel for every R,G,B,(W?) value const size_t packetCount = ((channelCount-1) / DDP_CHANNELS_PER_PACKET) +1; uint32_t channel = 0; @@ -141,8 +141,8 @@ class UserModDDP:public SysModule { /*8*/ddpUdp.write(0xFF & (packetSize >> 8)); /*9*/ddpUdp.write(0xFF & (packetSize )); - for (size_t i = 0; i < lds->ledsV.nrOfLedsP; i++) { - CRGB pixel = lds->ledsV.ledsPhysical[i]; + for (size_t i = 0; i < lds->leds.nrOfLedsP; i++) { + CRGB pixel = lds->leds.ledsPhysical[i]; ddpUdp.write(scale8(pixel.r, bri)); // R ddpUdp.write(scale8(pixel.g, bri)); // G ddpUdp.write(scale8(pixel.b, bri)); // B