diff --git a/platformio.ini b/platformio.ini index 4c55a998..0df2d543 100644 --- a/platformio.ini +++ b/platformio.ini @@ -50,6 +50,36 @@ build_flags = lib_deps = https://github.com/netmindz/WLED-sync#v0.14.0.b16 +[env:lolin_d32] +board = lolin_d32 ;https://github.com/platformio/platform-espressif32/blob/develop/boards/esp32dev.json +; recommended to pin to a platform version, see https://github.com/platformio/platform-espressif32/releases +platform = espressif32@6.5.0 ;using platformio/framework-arduinoespressif32 @ ~3.20014.0 / framework-arduinoespressif32 @ 3.20014.231204 (2.0.14) +framework = arduino +monitor_speed = 115200 +monitor_filters = esp32_exception_decoder +; board_build.partitions = tools/WLED_ESP32_4MB_256KB_FS.csv ;; 1.8MB firmware, 256KB filesystem (esptool erase_flash needed when changing from "standard WLED" partitions) +board_build.filesystem = littlefs +; board_build.f_flash = 80000000L ; use full 80MHz speed for flash (default = 40Mhz) +; board_build.flash_mode = dio ; (dio = dual i/o; more compatible than qio = quad i/o) +; build_type = debug ;increases flash size! +build_flags = + ; -DCONFIG_IDF_TARGET_ESP32=1 + ; -DCONFIG_ASYNC_TCP_USE_WDT=0 + ; -DLFS_THREADSAFE ;; enables use of semaphores in LittleFS driver + ; -DARDUINO_USB_CDC_ON_BOOT=0 ;; Make sure that the right HardwareSerial driver is picked in arduino-esp32 (needed on "classic ESP32") + ${appmod_leds.build_flags} + ${usermod_e131.build_flags} + ; ${usermod_ha.build_flags} + ${usermod_wledaudio.build_flags} +lib_deps = + ${starmod.lib_deps} + ${appmod_leds.lib_deps} + ${usermod_e131.lib_deps} + ; ${usermod_ha.lib_deps} + ${usermod_wledaudio.lib_deps} +; RAM: [== ] 15.6% (used 51124 bytes from 327680 bytes) +; Flash: [======= ] 68.1% (used 892033 bytes from 1310720 bytes) + [env:esp32dev] board = esp32dev ;https://github.com/platformio/platform-espressif32/blob/develop/boards/esp32dev.json ; recommended to pin to a platform version, see https://github.com/platformio/platform-espressif32/releases diff --git a/src/App/AppEffects.h b/src/App/AppEffects.h index 8946beff..0740827b 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() {} + virtual void setup(LedsV &ledsV) {} - virtual void loop() {} + virtual void loop(LedsV &ledsV) {} virtual bool controls(JsonObject parentVar) {return false;} @@ -114,7 +114,7 @@ class SolidEffect: public Effect { const char * name() { return "Solid 1D"; } - void loop() { + void loop(LedsV &ledsV) { uint8_t red = mdl->getValue("Red"); uint8_t green = mdl->getValue("Green"); uint8_t blue = mdl->getValue("Blue"); @@ -134,7 +134,7 @@ class RainbowEffect: public Effect { const char * name() { return "Rainbow 1D"; } - void loop() { + void loop(LedsV &ledsV) { // FastLED's built-in rainbow generator ledsV.fill_rainbow(gHue, 7); } @@ -145,12 +145,12 @@ class RainbowWithGlitterEffect:public RainbowEffect { const char * name() { return "Rainbow with glitter 1D"; } - void loop() { + void loop(LedsV &ledsV) { // built-in FastLED rainbow, plus some random sparkly glitter - RainbowEffect::loop(); - addGlitter(80); + RainbowEffect::loop(ledsV); + addGlitter(ledsV, 80); } - void addGlitter( fract8 chanceOfGlitter) + void addGlitter(LedsV &ledsV, fract8 chanceOfGlitter) { if( random8() < chanceOfGlitter) { ledsV[ random16(ledsV.nrOfLedsV) ] += CRGB::White; @@ -163,7 +163,7 @@ class SinelonEffect: public Effect { const char * name() { return "Sinelon 1D"; } - void loop() { + void loop(LedsV &ledsV) { // a colored dot sweeping back and forth, with fading trails ledsV.fadeToBlackBy(20); int pos = beatsin16( mdl->getValue("BPM").as(), 0, ledsV.nrOfLedsV-1 ); @@ -183,7 +183,7 @@ class RunningEffect: public Effect { const char * name() { return "Running 1D"; } - void loop() { + void loop(LedsV &ledsV) { // 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 @@ -205,7 +205,7 @@ class ConfettiEffect: public Effect { const char * name() { return "Confetti 1D"; } - void loop() { + void loop(LedsV &ledsV) { // random colored speckles that blink in and fade smoothly ledsV.fadeToBlackBy(10); int pos = random16(ledsV.nrOfLedsV); @@ -219,7 +219,7 @@ class BPMEffect: public Effect { return "Beats per minute 1D"; } - void loop() { + void loop(LedsV &ledsV) { // colored stripes pulsing at a defined Beats-Per-Minute (BPM) uint8_t BeatsPerMinute = 62; uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); @@ -238,7 +238,7 @@ class JuggleEffect: public Effect { const char * name() { return "Juggle 1D"; } - void loop() { + void loop(LedsV &ledsV) { // eight colored dots, weaving in and out of sync with each other ledsV.fadeToBlackBy(20); uint8_t dothue = 0; @@ -254,7 +254,7 @@ class Ripples3DEffect: public Effect { const char * name() { return "Ripples 3D"; } - void loop() { + void loop(LedsV &ledsV) { uint8_t interval = mdl->getValue("interval"); float ripple_interval = 1.3 * (interval/128.0); @@ -286,7 +286,7 @@ class SphereMove3DEffect: public Effect { const char * name() { return "SphereMove 3D"; } - void loop() { + void loop(LedsV &ledsV) { uint16_t origin_x, origin_y, origin_z, d; float diameter; @@ -321,9 +321,9 @@ class SphereMove3DEffect: public Effect { }; // SphereMove3DEffect //XY used by blur2d -uint16_t XY( uint8_t x, uint8_t y) { - return ledsV.XY(x,y); -} +// uint16_t XY( uint8_t x, uint8_t y) { +// return ledsV.XY(x,y); +// } //Frizzles2D inspired by WLED, Stepko, Andrew Tuline, https://editor.soulmatelights.com/gallery/640-color-frizzles class Frizzles2D: public Effect { @@ -332,14 +332,14 @@ class Frizzles2D: public Effect { return "Frizzles 2D"; } - void loop() { + void loop(LedsV &ledsV) { ledsV.fadeToBlackBy(16); for (size_t i = 8; i > 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); CRGB color = ColorFromPalette(palette, beatsin8(12, 0, 255), 255); - ledsV[XY(x,y)] = color; + ledsV[ledsV.XY(x,y)] = color; } ledsV.blur2d(ledsV.widthV, ledsV.heightV, mdl->getValue("blur")); } @@ -358,19 +358,19 @@ class Lines2D: public Effect { return "Lines 2D"; } - void loop() { + void loop(LedsV &ledsV) { ledsV.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 for (size_t y = 0; y < ledsV.heightV; y++) { - ledsV[XY(x,y)] = CHSV( gHue, 255, 192); + ledsV[ledsV.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[XY(x,y)] = CHSV( gHue, 255, 192); + ledsV[ledsV.XY(x,y)] = CHSV( gHue, 255, 192); } } } @@ -393,7 +393,7 @@ class DistortionWaves2D: public Effect { return "DistortionWaves 2D"; } - void loop() { + void loop(LedsV &ledsV) { const uint16_t cols = ledsV.widthV; const uint16_t rows = ledsV.heightV; @@ -433,7 +433,7 @@ class DistortionWaves2D: public Effect { valueG = gamma8(cos8(valueG)); valueB = gamma8(cos8(valueB)); - ledsV[XY(x,y)] = CRGB(valueR, valueG, valueB); + ledsV[ledsV.XY(x,y)] = CRGB(valueR, valueG, valueB); } } } @@ -457,7 +457,7 @@ class Octopus2D: public Effect { uint8_t radius; } map_t; - void loop() { + void loop(LedsV &ledsV) { const uint16_t cols = ledsV.widthV; const uint16_t rows = ledsV.heightV; @@ -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[XY(x, y)].angle = 40.7436f * atan2f(y - C_Y, x - C_X); // avoid 128*atan2()/PI - rMap[XY(x, y)].radius = hypotf(x - C_X, y - C_Y) * mapp; //thanks Sutaburosu + 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 } } } @@ -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[XY(x,y)].angle; - byte radius = rMap[XY(x,y)].radius; + byte angle = rMap[ledsV.XY(x,y)].angle; + byte radius = rMap[ledsV.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[XY(x,y)] = color; + ledsV[ledsV.XY(x,y)] = color; } } } @@ -525,7 +525,7 @@ class Lissajous2D: public Effect { return "Lissajous 2D"; } - void loop() { + void loop(LedsV &ledsV) { const uint16_t cols = ledsV.widthV; const uint16_t rows = ledsV.heightV; @@ -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[XY(xlocn, ylocn)] = ColorFromPalette(palette, palIndex); + ledsV[ledsV.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[XY(xlocn, ylocn)] = ColorFromPalette(palette, now/100+i); + ledsV[ledsV.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() { + void loop(LedsV &ledsV) { uint8_t grav = mdl->getValue("gravity"); uint8_t numBalls = mdl->getValue("balls"); @@ -603,7 +603,7 @@ class BouncingBalls1D: public Effect { // const bool hasCol2 = SEGCOLOR(2); const unsigned long time = now; - //not necessary as sharedData is cleared at setup() + //not necessary as sharedData is cleared at setup(LedsV &ledsV) // if (call == 0) { // for (size_t i = 0; i < maxNumBalls; i++) balls[i].lastBounceTime = time; // } @@ -657,7 +657,7 @@ class BouncingBalls1D: public Effect { class RingEffect:public Effect { protected: - void setRing(int ring, CRGB colour) { //so britisch ;-) + void setRing(LedsV &ledsV, int ring, CRGB colour) { //so britisch ;-) ledsV[ring] = colour; } @@ -669,14 +669,14 @@ class RingRandomFlow:public RingEffect { return "RingRandomFlow 1D"; } - void loop() { + void loop(LedsV &ledsV) { 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++) { - setRing(r, CHSV(hue[r], 255, 255)); + setRing(ledsV, r, CHSV(hue[r], 255, 255)); } for (int r = (ledsV.nrOfLedsV - 1); r >= 1; r--) { hue[r] = hue[(r - 1)]; // set this ruing based on the inner @@ -694,11 +694,11 @@ class GEQEffect:public Effect { return "GEQ 2D"; } - void setup() { + void setup(LedsV &ledsV) { ledsV.fadeToBlackBy(16); } - void loop() { + void loop(LedsV &ledsV) { sharedData.allocate(sizeof(uint16_t) * ledsV.widthV + sizeof(uint32_t)); uint16_t *previousBarHeight = sharedData.bind(ledsV.widthV); //array uint32_t *step = sharedData.bind(); @@ -772,11 +772,11 @@ class GEQEffect:public Effect { ledColor = ColorFromPalette(palette, (uint8_t)colorIndex); - ledsV.setPixelColor(XY(x, rows - 1 - y), ledColor); + ledsV.setPixelColor(ledsV.XY(x, rows - 1 - y), ledColor); } if ((ripple > 0) && (previousBarHeight[x] > 0) && (previousBarHeight[x] < rows)) // WLEDMM avoid "overshooting" into other segments - ledsV.setPixelColor(XY(x, rows - previousBarHeight[x]), CHSV( gHue, 255, 192)); // take gHue color for the time being + ledsV.setPixelColor(ledsV.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() { + void loop(LedsV &ledsV) { 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(i, color); + setRing(ledsV, i, color); // setRingFromFtt((i * 2), i); } - setRingFromFtt(2, 7); // set outer ring to bass - setRingFromFtt(0, 8); // set outer ring to bass + setRingFromFtt(ledsV, 2, 7); // set outer ring to bass + setRingFromFtt(ledsV, 0, 8); // set outer ring to bass } - void setRingFromFtt(int index, int ring) { + void setRingFromFtt(LedsV &ledsV, 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(ring, color); + setRing(ledsV, ring, color); } bool controls(JsonObject parentVar) { @@ -860,11 +860,11 @@ class FreqMatrix:public Effect { return "FreqMatrix 1D"; } - void setup() { + void setup(LedsV &ledsV) { ledsV.fadeToBlackBy(16); } - void loop() { + void loop(LedsV &ledsV) { sharedData.allocate(sizeof(uint8_t)); uint8_t *aux0 = sharedData.bind(); if (!sharedData.allocated()) return; @@ -980,10 +980,10 @@ class Effects { // #endif } - void loop(uint8_t fx) { + void loop(LedsV &ledsV) { now = millis(); //tbd timebase - effects[fx%effects.size()]->loop(); + effects[ledsV.fx%effects.size()]->loop(ledsV); call++; @@ -994,7 +994,7 @@ class Effects { return effects.size(); } - bool setEffect(JsonObject parentVar, uint8_t rowNr) { + bool setEffect(LedsV &ledsV, JsonObject parentVar, uint8_t rowNr) { bool doMap = false; ledsV.fx = mdl->getValue(parentVar, rowNr); @@ -1057,7 +1057,7 @@ class Effects { Effect* effect = effects[ledsV.fx]; effect->controls(parentVar); //tbd: add rowNr... - effect->setup(); //if changed then run setup once (like call==0 in WLED) + effect->setup(ledsV); //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/AppLedsV.cpp index 1bcba277..4104a7f6 100644 --- a/src/App/AppLedsV.cpp +++ b/src/App/AppLedsV.cpp @@ -320,7 +320,7 @@ void LedsV::fixtureProjectAndMap() { USER_PRINTF("fixtureProjectAndMap: Filename for fixture %d not found\n", fixtureNr); } -// ledsV[indexV] stores indexV locally +// indexVLocal stored to be used by other operators LedsV& LedsV::operator[](uint16_t indexV) { indexVLocal = indexV; return *this; @@ -332,7 +332,7 @@ LedsV& LedsV::operator[](uint16_t indexV) { // return x; // } -// ledsV = uses locally stored indexV and color to call setPixelColor +// uses indexVLocal and color to call setPixelColor LedsV& LedsV::operator=(const CRGB color) { setPixelColor(indexVLocal, color); return *this; @@ -364,21 +364,4 @@ CRGB LedsV::getPixelColor(int indexV) { void LedsV::addPixelColor(int indexV, CRGB color) { setPixelColor(indexV, getPixelColor(indexV) + color); -} - - -// LedsV& operator+=(const CRGB color) { -// setPixelColor(indexVLocal, getPixelColor(indexVLocal) + color); -// return *this; -// } -// LedsV& operator|=(const CRGB color) { -// // setPixelColor(indexVLocal, color); -// setPixelColor(indexVLocal, getPixelColor(indexVLocal) | color); -// return *this; -// } - -// LedsV& operator+(const CRGB color) { -// setPixelColor(indexVLocal, getPixelColor(indexVLocal) + color); -// return *this; -// } - +} \ No newline at end of file diff --git a/src/App/AppLedsV.h b/src/App/AppLedsV.h index ce122030..bdb15900 100644 --- a/src/App/AppLedsV.h +++ b/src/App/AppLedsV.h @@ -41,6 +41,8 @@ enum Projections class LedsV { public: + + //tbd: move ledsPhysical and nrOfLedsP out of ledsV // CRGB *leds = nullptr; CRGB ledsPhysical[NUM_LEDS_Max]; // if (!leds) @@ -52,6 +54,8 @@ class LedsV { // leds = (CRGB*)reallocarray uint16_t nrOfLedsP = 64; //amount of physical leds + + uint16_t nrOfLedsV = 64; //amount of virtual leds (calculated by projection) uint16_t widthP = 8; @@ -86,7 +90,6 @@ class LedsV { uint16_t indexVLocal = 0; //set in operator[], used by operator= - // ledsV[indexV] stores indexV locally LedsV& operator[](uint16_t indexV); // CRGB& operator[](uint16_t indexV) { @@ -95,7 +98,6 @@ class LedsV { // return x; // } - // ledsV = uses locally stored indexV and color to call setPixelColor LedsV& operator=(const CRGB color); // maps the virtual led to the physical led(s) and assign a color to it @@ -211,9 +213,4 @@ class LedsV { private: std::vector> mappingTable; uint16_t mappingTableLedCounter; -}; - -//Global vars! -//after header split they all needs to be static otherwise multiple definition link error -static LedsV ledsV = LedsV(); //virtual leds -// static CRGB *ledsP = ledsV.ledsPhysical; //physical leds, used by FastLed in particular +}; \ No newline at end of file diff --git a/src/App/AppModLeds.h b/src/App/AppModLeds.h index a873c168..ca1d64c2 100644 --- a/src/App/AppModLeds.h +++ b/src/App/AppModLeds.h @@ -50,6 +50,8 @@ class AppModLeds:public SysModule { bool doMap = false; Effects effects; + LedsV ledsV = LedsV(); //virtual leds + AppModLeds() :SysModule("Leds") {}; void setup() { @@ -107,7 +109,7 @@ class AppModLeds:public SysModule { select.add(effect->name()); } }, [this](JsonObject var, uint8_t rowNr) { //chFun - doMap = effects.setEffect(var, rowNr); + doMap = effects.setEffect(ledsV, var, rowNr); }); currentVar["stage"] = true; @@ -186,11 +188,11 @@ class AppModLeds:public SysModule { } }); //fixture - ui->initText(tableVar, "dimensions", nullptr, 32, true, [](JsonObject var) { //uiFun + 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); }); - ui->initText(tableVar, "nrOfLeds", nullptr, 32, true, [](JsonObject var) { //uiFun + 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"], "comment", "Max %d", NUM_LEDS_Max); }); @@ -240,7 +242,7 @@ class AppModLeds:public SysModule { //for each programmed effect // run the next frame of the effect - effects.loop(ledsV.fx); + effects.loop(ledsV); FastLED.show(); diff --git a/src/App/AppModPreview.h b/src/App/AppModPreview.h index 22d54c5b..28abf8bc 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(ledsV.nrOfLedsP * web->ws->count()/200, 16U)*10; //interval in ms * 10, not too fast //from cs to ms + var["interval"] = max(lds->ledsV.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,11 +38,11 @@ class AppModPreview:public SysModule { buffer = wsBuf->get(); // send leds preview to clients - for (size_t i = 0; i < ledsV.nrOfLedsP; i++) + for (size_t i = 0; i < lds->ledsV.nrOfLedsP; i++) { - buffer[i*3+5] = ledsV.ledsPhysical[i].red; - buffer[i*3+5+1] = ledsV.ledsPhysical[i].green; - buffer[i*3+5+2] = ledsV.ledsPhysical[i].blue; + 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; } //new values buffer[0] = 1; //userFun id @@ -50,7 +50,7 @@ class AppModPreview:public SysModule { // buffer[2] = ledsV.nrOfLedsP%256; // buffer[4] = max(ledsV.nrOfLedsP * SysModWeb::ws->count()/200, 16U); //interval in ms * 10, not too fast - }, ledsV.nrOfLedsP * 3 + 5, true); + }, lds->ledsV.nrOfLedsP * 3 + 5, true); }); } }; diff --git a/src/User/UserModArtNet.h b/src/User/UserModArtNet.h index 6f02576d..3620708b 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 = ledsV.nrOfLedsP * (isRGBW?4:3); // 1 channel for every R,G,B,(W?) value + const size_t channelCount = lds->ledsV.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 < ledsV.nrOfLedsP; i++) { - CRGB pixel = ledsV.ledsPhysical[i]; + for (size_t i = 0; i < lds->ledsV.nrOfLedsP; i++) { + CRGB pixel = lds->ledsV.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 9a44f820..ee9b5fba 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 = ledsV.nrOfLedsP * (isRGBW? 4:3); // 1 channel for every R,G,B,(W?) value + const size_t channelCount = lds->ledsV.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 < ledsV.nrOfLedsP; i++) { - CRGB pixel = ledsV.ledsPhysical[i]; + for (size_t i = 0; i < lds->ledsV.nrOfLedsP; i++) { + CRGB pixel = lds->ledsV.ledsPhysical[i]; ddpUdp.write(scale8(pixel.r, bri)); // R ddpUdp.write(scale8(pixel.g, bri)); // G ddpUdp.write(scale8(pixel.b, bri)); // B