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)
This commit is contained in:
Ewoud
2023-03-11 13:59:23 +01:00
parent 6ea77954bf
commit 9f282f831e
5 changed files with 15 additions and 7 deletions

View File

@@ -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

View File

@@ -2092,7 +2092,7 @@ bool WS2812FX::deserializeMap(uint8_t n) {
customMappingSize = map.size();
customMappingTable = new uint16_t[customMappingSize];
for (uint16_t i=0; i<MIN(customMappingSize, map.size()); i++)
for (uint16_t i=0; i<customMappingSize; i++)
customMappingTable[i] = (uint16_t) (map[i]<0 ? 0xFFFFU : map[i]);
loadedLedmap = n;

View File

@@ -181,7 +181,7 @@ void WLED::loop()
//WLEDMM refactored (to be done: setUpMatrix is called in finalizeInit and also in deserializeMap, deserializeMap is called in finalizeInit and also here)
if (loadLedmap) {
if (!strip.deserializeMap(loadedLedmap) && strip.isMatrix && loadedLedmap == 0) strip.setUpMatrix();
if (!strip.deserializeMap(loadedLedmap) && strip.isMatrix) strip.setUpMatrix(); //WLEDMM: always if nonexistent: && loadedLedmap == 0
strip.enumerateLedmaps(); //WLEDMM
loadLedmap = false;
}

View File

@@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2303101
#define VERSION 2303110
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG

View File

@@ -148,7 +148,7 @@ bool sendLiveLedsWs(uint32_t wsClient)
AsyncWebSocketClient * wsc = ws.client(wsClient);
if (!wsc || wsc->queueLength() > 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