Skip to content

Commit 4b1b0fe

Browse files
authored
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.
1 parent 4d39dd0 commit 4b1b0fe

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

wled00/FX.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7275,6 +7275,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
72757275
if (!strip.isMatrix || !SEGMENT.is2D()) return mode_static(); // not a 2D set-up
72767276

72777277
const int NUM_BANDS = map(SEGMENT.custom1, 0, 255, 1, 16);
7278+
const int CENTER_BIN = map(SEGMENT.custom3, 0, 31, 0, 15);
72787279
const int cols = SEG_W;
72797280
const int rows = SEG_H;
72807281

@@ -7296,8 +7297,14 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
72967297
if ((fadeoutDelay <= 1 ) || ((SEGENV.call % fadeoutDelay) == 0)) SEGMENT.fadeToBlackBy(SEGMENT.speed);
72977298

72987299
for (int x=0; x < cols; x++) {
7299-
uint8_t band = map(x, 0, cols, 0, NUM_BANDS);
7300-
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.
7300+
int band = map(x, 0, cols, 0, NUM_BANDS);
7301+
if (NUM_BANDS < 16) {
7302+
int startBin = constrain(CENTER_BIN - NUM_BANDS/2, 0, 15 - NUM_BANDS + 1);
7303+
if(NUM_BANDS <= 1)
7304+
band = CENTER_BIN; // map() does not work for single band
7305+
else
7306+
band = map(band, 0, NUM_BANDS - 1, startBin, startBin + NUM_BANDS - 1);
7307+
}
73017308
band = constrain(band, 0, 15);
73027309
unsigned colorIndex = band * 17;
73037310
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.
73197326

73207327
return FRAMETIME;
73217328
} // mode_2DGEQ()
7322-
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
7329+
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";
73237330

73247331

73257332
/////////////////////////

0 commit comments

Comments
 (0)