From 9f282f831e059cf92e5456ac1e56b32cc505eaac Mon Sep 17 00:00:00 2001 From: Ewoud Date: Sat, 11 Mar 2023 13:59:23 +0100 Subject: [PATCH] GEQ: even distribution of bands and small changes FX.cpp: GEQ: even distribution of bands FX_fcn: tiny change wled.cpp: setupMatrix also if loadedledmap != 0 ws.cpp: replace getLengthTotal by width * height (for ledmaps) --- wled00/FX.cpp | 14 +++++++++++--- wled00/FX_fcn.cpp | 2 +- wled00/wled.cpp | 2 +- wled00/wled.h | 2 +- wled00/ws.cpp | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 61c9a328..46502614 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -7132,11 +7132,19 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma. if ((fadeoutDelay <= 1 ) || ((SEGENV.call % fadeoutDelay) == 0)) SEGMENT.fadeToBlackBy(SEGMENT.speed); uint16_t lastBarHeight = 0; // WLEDMM: for smoothing out bars + + //WLEDMM: evenly ditribut bands + float bandwidth = (float)cols / NUM_BANDS; + float remaining = bandwidth; + uint8_t band = 0; for (int x=0; x < cols; x++) { - uint8_t band = map(x, 0, cols-1, 0, NUM_BANDS - 1); - if(cols > 24) band = map(x+1, 0, cols-1, 0, NUM_BANDS - 1); // WLEDMM fix for too-wide first band + //WLEDMM if not enough remaining + if (remaining < 1) {band++; remaining+= bandwidth;} //increase remaining but keep the current remaining + remaining--; //consume remaining + + // Serial.printf("x %d b %d n %d w %f %f\n", x, band, NUM_BANDS, bandwidth, remaining); if (NUM_BANDS < 16) band = map(band, 0, NUM_BANDS - 1, 0, 15); // always use full range. comment out this line to get the previous behaviour. - band = constrain(band, 0, 15); + // band = constrain(band, 0, 15); //WLEDMM can never be out of bounds (I think...) uint16_t colorIndex = band * 17; uint16_t barHeight = map(fftResult[band], 0, 255, 0, rows); // do not subtract -1 from rows here diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 12eb67c9..96d3844c 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -2092,7 +2092,7 @@ bool WS2812FX::deserializeMap(uint8_t n) { customMappingSize = map.size(); customMappingTable = new uint16_t[customMappingSize]; - for (uint16_t i=0; iqueueLength() > 0) return false; //only send if queue free - uint16_t used = strip.getLengthTotal(); + uint16_t used = Segment::maxWidth * Segment::maxHeight; //WLEDMM: not strip.getLengthTotal() as not working for ledmaps mapping to a smaller ledcount then width*height const uint16_t MAX_LIVE_LEDS_WS = strip.isMatrix ? 4096 : 256; //WLEDMM use 4096 as max matrix size uint16_t n = ((used -1)/MAX_LIVE_LEDS_WS) +1; //only serve every n'th LED if count over MAX_LIVE_LEDS_WS uint16_t pos = (strip.isMatrix ? 6 : 2); //WLEDMM 6 instead of 4