vStrip calculation

remove Segment copy constructor
This commit is contained in:
Blaz Kristan 2022-08-29 21:51:46 +02:00
parent c6126db2a2
commit 005419ab9a
2 changed files with 7 additions and 3 deletions

View File

@ -2796,7 +2796,7 @@ typedef struct Ball {
*/ */
uint16_t mode_bouncing_balls(void) { uint16_t mode_bouncing_balls(void) {
//allocate segment data //allocate segment data
const uint16_t strips = SEGMENT.map1D2D == M12_pBar ? SEGMENT.nrOfVStrips() : 1; const uint16_t strips = SEGMENT.nrOfVStrips(); // adapt for 2D
const size_t maxNumBalls = 16; const size_t maxNumBalls = 16;
uint16_t dataSize = sizeof(ball) * maxNumBalls; uint16_t dataSize = sizeof(ball) * maxNumBalls;
if (!SEGENV.allocateData(dataSize * strips)) return mode_static(); //allocation failed if (!SEGENV.allocateData(dataSize * strips)) return mode_static(); //allocation failed

View File

@ -410,7 +410,11 @@ uint16_t Segment::nrOfVStrips() const {
uint16_t vLen = 1; uint16_t vLen = 1;
#ifndef WLED_DISABLE_2D #ifndef WLED_DISABLE_2D
if (is2D()) { if (is2D()) {
vLen = virtualWidth(); switch (map1D2D) {
case M12_pBar:
vLen = virtualWidth();
break;
}
} }
#endif #endif
return vLen; return vLen;
@ -1435,7 +1439,7 @@ void WS2812FX::setTransitionMode(bool t)
void WS2812FX::printSize() void WS2812FX::printSize()
{ {
size_t size = 0; size_t size = 0;
for (const Segment seg : _segments) size += seg.getSize(); for (const Segment &seg : _segments) size += seg.getSize();
DEBUG_PRINTF("Segments: %d -> %uB\n", _segments.size(), size); DEBUG_PRINTF("Segments: %d -> %uB\n", _segments.size(), size);
DEBUG_PRINTF("Modes: %d*%d=%uB\n", sizeof(mode_ptr), _mode.size(), (_mode.capacity()*sizeof(mode_ptr))); DEBUG_PRINTF("Modes: %d*%d=%uB\n", sizeof(mode_ptr), _mode.size(), (_mode.capacity()*sizeof(mode_ptr)));
DEBUG_PRINTF("Data: %d*%d=%uB\n", sizeof(const char *), _modeData.size(), (_modeData.capacity()*sizeof(const char *))); DEBUG_PRINTF("Data: %d*%d=%uB\n", sizeof(const char *), _modeData.size(), (_modeData.capacity()*sizeof(const char *)));