From 4b1b0fe04535e4762d253755769de6e6937201ec Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Mon, 22 Sep 2025 20:01:54 +0200 Subject: [PATCH] Adding center bin selection to 2D GEQ (#4764) * adding center bin selection to 2D GEQ: this makes it possible to use subsets of the GEQ on distributed strips setting custom3 to 0 gives the "old" behaviour, this is the default. existing presets will have the custom3 slider at the center, changing presets that do not use the full width so this is a breaking change for those but I assume theser are rare. --- wled00/FX.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index f6bf54c0..b0aa1875 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -7275,6 +7275,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma. if (!strip.isMatrix || !SEGMENT.is2D()) return mode_static(); // not a 2D set-up const int NUM_BANDS = map(SEGMENT.custom1, 0, 255, 1, 16); + const int CENTER_BIN = map(SEGMENT.custom3, 0, 31, 0, 15); const int cols = SEG_W; const int rows = SEG_H; @@ -7296,8 +7297,14 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma. if ((fadeoutDelay <= 1 ) || ((SEGENV.call % fadeoutDelay) == 0)) SEGMENT.fadeToBlackBy(SEGMENT.speed); for (int x=0; x < cols; x++) { - uint8_t band = map(x, 0, cols, 0, NUM_BANDS); - 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. + int band = map(x, 0, cols, 0, NUM_BANDS); + if (NUM_BANDS < 16) { + int startBin = constrain(CENTER_BIN - NUM_BANDS/2, 0, 15 - NUM_BANDS + 1); + if(NUM_BANDS <= 1) + band = CENTER_BIN; // map() does not work for single band + else + band = map(band, 0, NUM_BANDS - 1, startBin, startBin + NUM_BANDS - 1); + } band = constrain(band, 0, 15); unsigned colorIndex = band * 17; int barHeight = map(fftResult[band], 0, 255, 0, rows); // do not subtract -1 from rows here @@ -7319,7 +7326,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma. return FRAMETIME; } // mode_2DGEQ() -static const char _data_FX_MODE_2DGEQ[] PROGMEM = "GEQ@Fade speed,Ripple decay,# of bands,,,Color bars;!,,Peaks;!;2f;c1=255,c2=64,pal=11,si=0"; // Beatsin +static const char _data_FX_MODE_2DGEQ[] PROGMEM = "GEQ@Fade speed,Ripple decay,# of bands,,Bin,Color bars;!,,Peaks;!;2f;c1=255,c2=64,pal=11,si=0,c3=0"; /////////////////////////