Skip to content

Commit 43a7ba4

Browse files
committed
FxParticlesystem Fix memory calculation of framebuffer size #275
Updated memory calculation for CRGB to use virtual width and height. Somehow virtualLength is not reliable, so use vWidth * vHeight
1 parent 6ff45e7 commit 43a7ba4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

wled00/FXparticleSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ bool allocateParticleSystemMemory2D(uint32_t numparticles, uint32_t numsources,
11031103
if (sizecontrol)
11041104
requiredmemory += sizeof(PSsizeControl) * numparticles;
11051105
requiredmemory += sizeof(PSsource) * numsources;
1106-
requiredmemory += sizeof(CRGB) * SEGMENT.virtualLength(); // virtualLength is witdh * height
1106+
requiredmemory += sizeof(CRGB) * uint32_t(SEGMENT.calc_virtualWidth()) * uint32_t(SEGMENT.calc_virtualHeight()); // virtualLength not reliable, better to use vWidth * vHeight
11071107
requiredmemory += additionalbytes + 3; // add 3 to ensure there is room for stuffing bytes
11081108
//requiredmemory = (requiredmemory + 3) & ~0x03; // align memory block to next 4-byte boundary
11091109
PSPRINTLN("mem alloc: " + String(requiredmemory));
@@ -1938,4 +1938,4 @@ static bool checkBoundsAndWrap(int32_t &position, const int32_t max, const int32
19381938
c.b = ((c.b * scale) >> 8);
19391939
}
19401940

1941-
#endif // !(defined(WLED_DISABLE_PARTICLESYSTEM2D) && defined(WLED_DISABLE_PARTICLESYSTEM1D))
1941+
#endif // !(defined(WLED_DISABLE_PARTICLESYSTEM2D) && defined(WLED_DISABLE_PARTICLESYSTEM1D))

0 commit comments

Comments
 (0)