diff --git a/platformio.ini b/platformio.ini index 7d2fb08b..4c57937b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -87,7 +87,7 @@ lib_deps = build_flags = ; -D APP=StarBase -D PIOENV=$PIOENV - -D VERSION=24071207 ; Date and time (GMT!), update at every commit!! + -D VERSION=24071508 ; Date and time (GMT!), update at every commit!! -D LFS_THREADSAFE ; enables use of semaphores in LittleFS driver -D STARBASE_DEVMODE ${ESPAsyncWebServer.build_flags} ;alternatively PsychicHttp diff --git a/src/App/LedEffects.h b/src/App/LedEffects.h index 01d73c5e..a607e05d 100644 --- a/src/App/LedEffects.h +++ b/src/App/LedEffects.h @@ -113,7 +113,8 @@ class RainbowEffect: public Effect { for (forUnsigned16 i = 0; i < leds.nrOfLeds; i++) { uint8_t index = (i * (16 << (scale / 29)) / leds.nrOfLeds) + counter; - leds.setPixelColor(i, ColorFromPalette(leds.palette, index, 255)); + // leds.setPixelColor(i, ColorFromPalette(leds.palette, index)); + leds.setPixelColorPal(i, index); } } @@ -178,14 +179,14 @@ class FlowEffect: public Effect { uint16_t zoneLen = leds.nrOfLeds / zones; uint16_t offset = (leds.nrOfLeds - zones * zoneLen) >> 1; - leds.fill_solid(ColorFromPalette(leds.palette, -counter, 255)); + leds.fill_solid(ColorFromPalette(leds.palette, -counter)); for (int z = 0; z < zones; z++) { uint16_t pos = offset + z * zoneLen; for (int i = 0; i < zoneLen; i++) { uint8_t colorIndex = (i * 255 / zoneLen) - counter; uint16_t led = (z & 0x01) ? i : (zoneLen -1) -i; - leds[pos + led] = ColorFromPalette(leds.palette, colorIndex, 255); + leds[pos + led] = ColorFromPalette(leds.palette, colorIndex); } } } @@ -395,7 +396,7 @@ class BouncingBalls: public Effect { int pos = roundf(balls[i].height * (leds.nrOfLeds - 1)); - CRGB color = ColorFromPalette(leds.palette, i*(256/max(numBalls, (uint8_t)8)), 255); //error: no matching function for call to 'max(uint8_t&, int)' + CRGB color = ColorFromPalette(leds.palette, i*(256/max(numBalls, (uint8_t)8))); //error: no matching function for call to 'max(uint8_t&, int)' leds[pos] = color; // if (leds.nrOfLeds<32) leds.setPixelColor(indexToVStrip(pos, stripNr), color); // encode virtual strip into index @@ -789,7 +790,7 @@ class PopCorn: public Effect { // uint32_t col = SEGMENT.color_wheel(popcorn[i].colIndex); // if (!SEGMENT.palette && popcorn[i].colIndex < NUM_COLORS) col = SEGCOLOR(popcorn[i].colIndex); uint16_t ledIndex = popcorn[i].pos; - CRGB col = ColorFromPalette(leds.palette, popcorn[i].colIndex*(256/maxNumPopcorn), 255); + CRGB col = ColorFromPalette(leds.palette, popcorn[i].colIndex*(256/maxNumPopcorn)); if (ledIndex < leds.nrOfLeds) leds.setPixelColor(ledIndex, col); } } @@ -877,7 +878,7 @@ class AudioRings: public RingEffect { void setRingFromFtt(Leds &leds, int index, int ring) { byte val = wledAudioMod->fftResults[index]; // Visualize leds to the beat - CRGB color = ColorFromPalette(leds.palette, val, 255); + CRGB color = ColorFromPalette(leds.palette, val); color.nscale8_video(val); setRing(leds, ring, color); } @@ -1074,8 +1075,8 @@ class DNA: public Effect { //32: 4 * i //16: 8 * i phase = i * 127 / (leds.size.x-1) * phases / 64; - leds.setPixelColor(leds.XY(i, beatsin8(speed, 0, leds.size.y-1, 0, phase )), ColorFromPalette(leds.palette, i*5+ sys->now /17, beatsin8(5, 55, 255, 0, i*10), LINEARBLEND)); - leds.setPixelColor(leds.XY(i, beatsin8(speed, 0, leds.size.y-1, 0, phase+128)), ColorFromPalette(leds.palette, i*5+128+ sys->now /17, beatsin8(5, 55, 255, 0, i*10+128), LINEARBLEND)); + leds.setPixelColor(leds.XY(i, beatsin8(speed, 0, leds.size.y-1, 0, phase )), ColorFromPalette(leds.palette, i*5+ sys->now /17, beatsin8(5, 55, 255, 0, i*10))); + leds.setPixelColor(leds.XY(i, beatsin8(speed, 0, leds.size.y-1, 0, phase+128)), ColorFromPalette(leds.palette, i*5+128+ sys->now /17, beatsin8(5, 55, 255, 0, i*10+128))); } leds.blur2d(blur); } @@ -1264,7 +1265,8 @@ class Lissajous: public Effect { //leds.setPixelColorXY(xlocn, ylocn, SEGMENT.color_from_palette(sys->now/100+i, false, PALETTE_SOLID_WRAP, 0)); // draw pixel with anti-aliasing unsigned palIndex = (256*locn.y) + phase/2 + (i* freqX)/64; // leds.setPixelColorXY(xlocn, ylocn, SEGMENT.color_from_palette(palIndex, false, PALETTE_SOLID_WRAP, 0)); // draw pixel with anti-aliasing - color follows rotation - leds[locn] = ColorFromPalette(leds.palette, palIndex); + // leds[locn] = ColorFromPalette(leds.palette, palIndex); + leds.setPixelColorPal(locn, palIndex); } } else for (int i=0; i < 256; i ++) { @@ -1274,7 +1276,8 @@ class Lissajous: public Effect { locn.x = (leds.size.x < 2) ? 1 : (map(2*locn.x, 0,511, 0,2*(leds.size.x-1)) +1) /2; // softhack007: "*2 +1" for proper rounding locn.y = (leds.size.y < 2) ? 1 : (map(2*locn.y, 0,511, 0,2*(leds.size.y-1)) +1) /2; // "leds.size.y > 2" is needed to avoid div/0 in map() // leds.setPixelColorXY((uint8_t)xlocn, (uint8_t)ylocn, SEGMENT.color_from_palette(sys->now/100+i, false, PALETTE_SOLID_WRAP, 0)); - leds[locn] = ColorFromPalette(leds.palette, sys->now/100+i); + // leds[locn] = ColorFromPalette(leds.palette, sys->now/100+i); + leds.setPixelColorPal(locn, sys->now/100+i); } } @@ -1311,7 +1314,7 @@ class Frizzles: public Effect { Coord3D pos = {0,0,0}; pos.x = beatsin8(bpm/8 + i, 0, leds.size.x - 1); pos.y = beatsin8(intensity/8 - i, 0, leds.size.y - 1); - CRGB color = ColorFromPalette(leds.palette, beatsin8(12, 0, 255), 255); + CRGB color = ColorFromPalette(leds.palette, beatsin8(12, 0, 255)); leds[pos] = color; } leds.blur2d(blur); @@ -1376,7 +1379,8 @@ class Noise2D: public Effect { for (int y = 0; y < leds.size.y; y++) { for (int x = 0; x < leds.size.x; x++) { uint8_t pixelHue8 = inoise8(x * scale, y * scale, sys->now / (16 - speed)); - leds.setPixelColor(leds.XY(x, y), ColorFromPalette(leds.palette, pixelHue8)); + // leds.setPixelColor(leds.XY(x, y), ColorFromPalette(leds.palette, pixelHue8)); + leds.setPixelColorPal(leds.XY(x, y), pixelHue8); } } } @@ -2263,14 +2267,13 @@ class Waverly: public Effect { uint16_t thisMax = min(map(thisVal, 0, 512, 0, leds.size.y), (long)leds.size.x); for (pos.y = 0; pos.y < thisMax; pos.y++) { - CRGB color = ColorFromPalette(leds.palette, map(pos.y, 0, thisMax, 250, 0), 255, LINEARBLEND); + CRGB color = ColorFromPalette(leds.palette, map(pos.y, 0, thisMax, 250, 0)); if (!noClouds) leds.addPixelColor(pos, color); leds.addPixelColor(leds.XY((leds.size.x - 1) - pos.x, (leds.size.y - 1) - pos.y), color); } } leds.blur2d(16); - } void controls(Leds &leds, JsonObject parentVar) { @@ -2615,7 +2618,7 @@ class RipplesEffect: public Effect { uint32_t time_interval = sys->now/(100 - speed)/((256.0f-128.0f)/20.0f); pos.y = floor(leds.size.y/2.0f + sinf(d/ripple_interval + time_interval) * leds.size.y/2.0f); //between 0 and leds.size.y - leds[pos] = CHSV( sys->now/50 + random8(64), 200, 255);// ColorFromPalette(leds.palette,call, bri, LINEARBLEND); + leds[pos] = CHSV( sys->now/50 + random8(64), 200, 255);// ColorFromPalette(leds.palette,call, bri); } } } @@ -2653,7 +2656,7 @@ class SphereMoveEffect: public Effect { uint16_t d = distance(pos.x, pos.y, pos.z, origin.x, origin.y, origin.z); if (d>diameter && dnow/50 + random8(64), 200, 255);// ColorFromPalette(leds.palette,call, bri, LINEARBLEND); + leds[pos] = CHSV( sys->now/50 + random8(64), 200, 255);// ColorFromPalette(leds.palette,call, bri); } } } @@ -2679,7 +2682,7 @@ class PixelMapEffect: public Effect { leds.fill_solid(CRGB::Black); Coord3D pos = {x, y, z}; - leds[pos] = CHSV( sys->now/50 + random8(64), 255, 255);// ColorFromPalette(leds.palette,call, bri, LINEARBLEND); + leds[pos] = CHSV( sys->now/50 + random8(64), 255, 255);// ColorFromPalette(leds.palette,call, bri); } void controls(Leds &leds, JsonObject parentVar) { diff --git a/src/App/LedFixture.cpp b/src/App/LedFixture.cpp index e6ef51dc..c1952cae 100644 --- a/src/App/LedFixture.cpp +++ b/src/App/LedFixture.cpp @@ -34,10 +34,14 @@ void Fixture::projectAndMap() { leds->size = Coord3D{0,0,0}; //vectors really gone now? for (PhysMap &map:leds->mappingTable) { - if (map.getMapType() == m_morePixels) { - map.indexes->clear(); - delete map.indexes; + if (leds->checkPalColorEffect()) { // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode + leds->mappingTableIndexes.clear(); } + else + if (map.getMapType() == m_morePixels) { + map.indexes->clear(); + delete map.indexes; + } } leds->mappingTable.clear(); // leds->effectData.reset(); //do not reset as want to save settings. @@ -138,11 +142,14 @@ void Fixture::projectAndMap() { if (indexV >= leds->mappingTable.size()) { for (size_t i = leds->mappingTable.size(); i <= indexV; i++) { // ppf("mapping %d,%d,%d add physMap before %d %d\n", pixel.y, pixel.y, pixel.z, indexV, leds->mappingTable.size()); - leds->mappingTable.push_back(PhysMap()); //abort() was called at PC 0x40191473 on core 1 std::allocator >&&) + leds->mappingTable.push_back(PhysMap(leds->checkPalColorEffect())); // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode } } - leds->mappingTable[indexV].addIndexP(indexP); + if (leds->checkPalColorEffect()) // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode + leds->mappingTable[indexV].addIndexP2(*leds, indexP); + else + leds->mappingTable[indexV].addIndexP(indexP); // ppf("mapping b:%d t:%d V:%d\n", indexV, indexP, leds->mappingTable.size()); } //indexV not too high } //indexV @@ -218,26 +225,47 @@ void Fixture::projectAndMap() { if (leds->mappingTable.size() < leds->size.x * leds->size.y * leds->size.z) ppf("mapping add extra physMap %d to %d size: %d,%d,%d\n", leds->mappingTable.size(), leds->size.x * leds->size.y * leds->size.z, leds->size.x, leds->size.y, leds->size.z); for (size_t i = leds->mappingTable.size(); i < leds->size.x * leds->size.y * leds->size.z; i++) { - leds->mappingTable.push_back(PhysMap()); + leds->mappingTable.push_back(PhysMap(leds->checkPalColorEffect())); // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode } leds->nrOfLeds = leds->mappingTable.size(); + // ppf("post leds %d p:%d\n", leds->mappingTable.size(), leds->checkPalColorEffect()); + //debug info + summary values for (PhysMap &map:leds->mappingTable) { - switch (map.getMapType()) { - case m_onePixel: - nrOfPhysical++; - break; - case m_morePixels: - // ppf("ledV %d mapping: #ledsP (%d):", indexV, nrOfLogical); - for (uint16_t indexP:*map.indexes) { - // ppf(" %d", indexP); + if (leds->checkPalColorEffect()) { // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode + // ppf("i: %d t:%d\n", nrOfLogical, map.mapType); + switch (map.mapType) { + case m_onePixel: + // ppf("ledV %d mapping: #ledsP : %d\n", nrOfLogical, map.indexP1); nrOfPhysical++; - } - // ppf("\n"); - break; + break; + case m_morePixels: + // ppf("ledV %d mapping: #ledsP :", nrOfLogical); + + for (uint16_t indexP: leds->mappingTableIndexes[map.indexes1]) { + // ppf(" %d", indexP); + nrOfPhysical++; + } + // ppf("\n"); + break; + } } + else + switch (map.getMapType()) { + case m_onePixel: + nrOfPhysical++; + break; + case m_morePixels: + // ppf("ledV %d mapping: #ledsP :", nrOfLogical); + for (uint16_t indexP:*map.indexes) { + ppf(" %d", indexP); + nrOfPhysical++; + } + // ppf("\n"); + break; + } nrOfLogical++; // else // ppf("ledV %d no mapping\n", x); diff --git a/src/App/LedLeds.cpp b/src/App/LedLeds.cpp index eee3e8b1..f95e6848 100644 --- a/src/App/LedLeds.cpp +++ b/src/App/LedLeds.cpp @@ -27,8 +27,8 @@ void fastled_fill_rainbow(struct CRGB * targetArray, int numToFill, unsigned8 in } void Leds::triggerMapping() { - doMap = true; //specify which leds to remapp - fixture->doMap = true; //fixtgure will also be remapped + doMap = true; //specify which leds to remap + fixture->doMap = true; //fixture will also be remapped } unsigned16 Leds::XYZ(Coord3D pixel) { @@ -71,6 +71,32 @@ void Leds::setPixelColor(unsigned16 indexV, CRGB color, unsigned8 blendAmount) { ppf(" dev sPC V:%d >= %d", indexV, NUM_LEDS_Max); } +void Leds::setPixelColorPal(unsigned16 indexV, uint8_t palIndex, uint8_t palBri, unsigned8 blendAmount) { + if (indexV < mappingTable.size()) { + switch (mappingTable[indexV].mapType) { + case m_color: + mappingTable[indexV].palIndex = palIndex; + mappingTable[indexV].palBri = palBri; + case m_onePixel: { + uint16_t indexP = mappingTable[indexV].indexP1; + fixture->ledsP[indexP] = blend(ColorFromPalette(palette, palIndex, palBri), fixture->ledsP[indexP], blendAmount==UINT8_MAX?fixture->globalBlend:blendAmount); + break; } + case m_morePixels: + if (mappingTable[indexV].indexes1 < mappingTableIndexes.size()) + for (forUnsigned16 indexP: mappingTableIndexes[mappingTable[indexV].indexes1]) { + fixture->ledsP[indexP] = blend(ColorFromPalette(palette, palIndex, palBri), fixture->ledsP[indexP], blendAmount==UINT8_MAX?fixture->globalBlend:blendAmount); + } + // else + // ppf("dev setPixelColorPal i:%d m:%d s:%d\n", indexV, mappingTable[indexV].indexes1, mappingTableIndexes.size()); + break; + } + } + else if (indexV < NUM_LEDS_Max) //no projection + fixture->ledsP[(projectionNr == p_Random)?random(fixture->nrOfLeds):indexV] = ColorFromPalette(palette, palIndex, palBri); + else if (indexV != UINT16_MAX) //assuming UINT16_MAX is set explicitly (e.g. in XYZ) + ppf(" dev sPC V:%d >= %d", indexV, NUM_LEDS_Max); +} + CRGB Leds::getPixelColor(unsigned16 indexV) { if (indexV < mappingTable.size()) { switch (mappingTable[indexV].getMapType()) { @@ -94,7 +120,7 @@ CRGB Leds::getPixelColor(unsigned16 indexV) { } void Leds::fadeToBlackBy(unsigned8 fadeBy) { - if (projectionNr == p_None || projectionNr == p_Random || (fixture->nrOfLeds == nrOfLeds)) { + if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) { fastled_fadeToBlackBy(fixture->ledsP, fixture->nrOfLeds, fadeBy); } else { for (PhysMap &map:mappingTable) { @@ -118,7 +144,7 @@ void Leds::fadeToBlackBy(unsigned8 fadeBy) { } void Leds::fill_solid(const struct CRGB& color, bool noBlend) { - if (projectionNr == p_None || projectionNr == p_Random || (fixture->nrOfLeds == nrOfLeds)) { + if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) { fastled_fill_solid(fixture->ledsP, fixture->nrOfLeds, color); } else { for (PhysMap &map:mappingTable) { @@ -138,7 +164,7 @@ void Leds::fill_solid(const struct CRGB& color, bool noBlend) { } void Leds::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) { - if (projectionNr == p_None || projectionNr == p_Random || (fixture->nrOfLeds == nrOfLeds)) { + if (projectionNr == p_None || projectionNr == p_Random || (fixture->listOfLeds.size() == 1)) { fastled_fill_rainbow(fixture->ledsP, fixture->nrOfLeds, initialhue, deltahue); } else { CHSV hsv; @@ -162,3 +188,28 @@ void Leds::fill_rainbow(unsigned8 initialhue, unsigned8 deltahue) { } } } + +void PhysMap::addIndexP2(Leds &leds, uint16_t indexP) { + // ppf("addIndexP2 i:%d t:%d", indexP, mapType); + switch (mapType) { + case m_color: + // case m_rgbColor: + indexP1 = indexP; + mapType = m_onePixel; + break; + case m_onePixel: { + uint16_t oldIndexP = indexP1; + std::vector newVector; + newVector.push_back(oldIndexP); + newVector.push_back(indexP); + leds.mappingTableIndexes.push_back(newVector); + indexes1 = leds.mappingTableIndexes.size() - 1; + mapType = m_morePixels; + break; } + case m_morePixels: + leds.mappingTableIndexes[indexes1].push_back(indexP); + // ppf(" more %d", mappingTableIndexes.size()); + break; + } + // ppf("\n"); +} diff --git a/src/App/LedLeds.h b/src/App/LedLeds.h index 58e13189..1464b2b1 100644 --- a/src/App/LedLeds.h +++ b/src/App/LedLeds.h @@ -120,7 +120,6 @@ static Trigo trigoTiltPanRoll(255); // Trigo8 is hardly any faster (27 vs 28 fps class Fixture; //forward - //StarLight implementation of segment.data class SharedData { @@ -192,9 +191,11 @@ enum mapType { m_count //keep as last entry }; +class Leds; //forward + + struct PhysMap { union { - std::vector * indexes; // 4 bytes CRGB color; // 3 bytes struct { uint16_t indexP; // 2 bytes @@ -202,15 +203,36 @@ struct PhysMap { byte placeHolder2:6; //6 bits byte type:2; // 2 bits used for color and indexP (more colors is using raw[3], see getMapType) }; //4 bytes + std::vector * indexes; // 4 bytes + //the following struct / union will replace above if fully converted to Pal / 2 byte mapping mode + struct { + union { + struct { //no physical pixel (type==0) palette (all linearblend) + uint8_t palIndex:8; //8 bits (256) + uint8_t palBri:6; //6 bits (64) + byte mapType:2; //2 bits (4) + }; // 16 bits + uint16_t indexP1: 14; //16384 one physical pixel (type==1) index to ledsP array + uint16_t indexes1:14; //16384 multiple physical pixels (type==2) index in std::vector> mappingTableIndexes; + struct { //condensed rgb, keep in GBR order!!! exceptional cases when no palette. e.g. solid? + uint8_t g:5; //32 + uint8_t b:3; //8 + uint8_t r:6; //64 + }; //14 bits + }; //14 bits + byte rawx[2]; //temporary filler to check if total will not extend 4 bytes + }; //2 bytes byte raw[4]; //raw[3] == 63 for indexes pointers }; // 4 bytes - PhysMap() { + PhysMap(bool palColorEffect) { // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode indexes = nullptr; //all zero's - type = m_color; // the default until indexP is added + if (palColorEffect) + mapType = m_color; // the default until indexP is added + else + type = m_color; // the default until indexP is added } - void setColor(CRGB color) { this->color = color; placeHolder2 = 0; //cleanup memory @@ -220,7 +242,8 @@ struct PhysMap { } uint8_t getMapType() { - if (raw[3] == 63) return m_morePixels; // this first as pointer could contain values for m)color and m_onepixel + if (raw[3] == 63) return m_morePixels; // this first as pointer could contain values for m_color and m_onepixel + // raw[3] == 63 is the imperical found value if the 4th bit of a pointer, hopefully this is the same on all boards, but we will check in addIndexP if (type == m_color) return m_color; if (type == m_onePixel) return m_onePixel; return UINT8_MAX; // no valid type found @@ -237,9 +260,10 @@ struct PhysMap { break; case m_onePixel: { uint16_t oldIndexP = this->indexP; //save old indexP - indexes = new std::vector; //overwrite old indexP with indexes + indexes = new std::vector; //overwrite old indexP with indexes, type will be m_morePixels implicetly because this is a pointer!!! // ppf("dev new indexes t:%d i:%d t3:%d b:%d p:%p\n", type, indexP, raw[3], raw[3] & 0x80, indexes); if (getMapType() != m_morePixels) + // raw[3] == 63 is the imperical found value if the 4th bit of a pointer, hopefully this is the same on all boards, but we will check here if it is not the case ppf("dev addIndexP not indexes t:%d i:%d t3:%d b:%d p:%p\n", type, indexP, raw[3], raw[3] & 0x80, indexes); else { indexes->push_back(oldIndexP); @@ -253,6 +277,8 @@ struct PhysMap { } } + void addIndexP2(Leds &leds, uint16_t indexP); // addIndexP2: temp method until all effects have been converted to Palette / 2 byte mapping mode + }; // 4 bytes class Projection; //forward for cached virtual class methods! @@ -290,6 +316,8 @@ class Leds { SharedData projectionData; std::vector mappingTable; + std::vector> mappingTableIndexes; + unsigned16 indexVLocal = 0; //set in operator[], used by operator= @@ -324,10 +352,14 @@ class Leds { fadeToBlackBy(100); doMap = true; // so loop is not running while deleting for (PhysMap &map:mappingTable) { - if (map.getMapType() == m_morePixels) { - map.indexes->clear(); - delete map.indexes; + if (checkPalColorEffect()) { // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode + mappingTableIndexes.clear(); } + else + if (map.getMapType() == m_morePixels) { + map.indexes->clear(); + delete map.indexes; + } } mappingTable.clear(); } @@ -377,6 +409,10 @@ class Leds { void setPixelColor(unsigned16 indexV, CRGB color, unsigned8 blendAmount = UINT8_MAX); void setPixelColor(Coord3D pixel, CRGB color, unsigned8 blendAmount = UINT8_MAX) {setPixelColor(XYZ(pixel), color, blendAmount);} + // temp methods until all effects have been converted to Palette / 2 byte mapping mode + void setPixelColorPal(unsigned16 indexV, uint8_t palIndex, uint8_t palBri = 255, unsigned8 blendAmount = UINT8_MAX); + void setPixelColorPal(Coord3D pixel, uint8_t palIndex, uint8_t palBri = 255, unsigned8 blendAmount = UINT8_MAX) {setPixelColorPal(XYZ(pixel), palIndex, palBri, blendAmount);} + CRGB getPixelColor(unsigned16 indexV); CRGB getPixelColor(Coord3D pixel) {return getPixelColor(XYZ(pixel));} @@ -403,7 +439,10 @@ class Leds { //checks if a virtual pixel is mapped to a physical pixel (use with XY() or XYZ() to get the indexV) bool isMapped(unsigned16 indexV) { - return indexV < mappingTable.size() && (mappingTable[indexV].getMapType() == m_onePixel || mappingTable[indexV].getMapType() == m_morePixels); + if (checkPalColorEffect()) // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode + return indexV < mappingTable.size() && (mappingTable[indexV].mapType == m_onePixel || mappingTable[indexV].mapType == m_morePixels); + else + return indexV < mappingTable.size() && (mappingTable[indexV].getMapType() == m_onePixel || mappingTable[indexV].getMapType() == m_morePixels); } void blur1d(fract8 blur_amount) @@ -522,4 +561,13 @@ class Leds { } } + // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode + // add id's of all converted methods here + bool checkPalColorEffect() { + return (fx == 1) //rainBow + || (fx == 24) //lissajous + || (fx == 27) //noise2D + ; + } + }; \ No newline at end of file diff --git a/src/App/LedModEffects.h b/src/App/LedModEffects.h index e15d84bc..17511034 100644 --- a/src/App/LedModEffects.h +++ b/src/App/LedModEffects.h @@ -204,13 +204,16 @@ class LedModEffects:public SysModule { if (rowNr < fixture.listOfLeds.size()) { Leds *leds = fixture.listOfLeds[rowNr]; + leds->doMap = true; //stop the effects loop already here + + bool oldPal = leds->checkPalColorEffect(); // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode + leds->fx = mdl->getValue(var, rowNr); ppf("setEffect fx[%d]: %d\n", rowNr, leds->fx); if (leds->fx < effects.size()) { - Effect* effect = effects[leds->fx]; // effect->loop(leds); //do a loop to set effectData right @@ -226,10 +229,12 @@ class LedModEffects:public SysModule { print->printVar(var); ppf("\n"); - if (effect->dim() != leds->effectDimension) { + if (effect->dim() != leds->effectDimension || oldPal != leds->checkPalColorEffect()) { // checkPalColorEffect: temp method until all effects have been converted to Palette / 2 byte mapping mode leds->effectDimension = effect->dim(); leds->triggerMapping(); } + else + leds->doMap = false; //run the effects again } // fx < size } @@ -265,6 +270,8 @@ class LedModEffects:public SysModule { if (rowNr < fixture.listOfLeds.size()) { Leds *leds = fixture.listOfLeds[rowNr]; + leds->doMap = true; //stop the effects loop already here + stackUnsigned8 proValue = mdl->getValue(var, rowNr); leds->projectionNr = proValue;