Skip to content

Commit 803cc20

Browse files
GregGreg
authored andcommitted
Move 2d check to the top of the function
1 parent 63fd020 commit 803cc20

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

wled00/FX.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7260,6 +7260,7 @@ uint16_t mode_single_eqbar(void) {
72607260
um_data_t *um_data = getAudioData();
72617261
uint8_t *fftResult = (uint8_t*)um_data->u_data[2];
72627262
if (!fftResult) return mode_static();
7263+
bool is2d = (strip.isMatrix || SEGMENT.is2D());
72637264

72647265
// User controls. Speed is referenced directly instead of creating a new varible.
72657266
uint8_t freqBin = map(SEGMENT.custom1, 0, 255, 0, 15); // 0-15 (or up to available bins)
@@ -7280,7 +7281,7 @@ uint16_t mode_single_eqbar(void) {
72807281

72817282
// Draw the main bar (but not peak pixel)
72827283
for (int i = 0; i < barHeight; i++) {
7283-
if (strip.isMatrix || SEGMENT.is2D()){
7284+
if (is2d){
72847285
// If we are in a matrix or 2D segment, draw the bar vertically
72857286
for (int j = 0; j < SEG_W; j++) {
72867287
SEGMENT.setPixelColorXY(j, i, SEGMENT.color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
@@ -7294,7 +7295,7 @@ uint16_t mode_single_eqbar(void) {
72947295
if (peakDecay == 0){
72957296
// No peak pixel if decay is set to zero, just draw the peak pixel of the bar.
72967297
if (barHeight > 0) {
7297-
if (strip.isMatrix || SEGMENT.is2D()) {
7298+
if (is2d) {
72987299
for (int j = 0; j < SEG_W; j++) {
72997300
SEGMENT.setPixelColorXY(j, barHeight, SEGMENT.color_from_palette(barHeight, true, PALETTE_SOLID_WRAP, 0));
73007301
}
@@ -7309,7 +7310,7 @@ uint16_t mode_single_eqbar(void) {
73097310
// Set peak pixel and clear pixels over peak (otherwise they would fadewith value from speed slider)
73107311
if (*prevBarHeight > 0) {
73117312

7312-
if (strip.isMatrix || SEGMENT.is2D()) {
7313+
if (is2d) {
73137314
for (int j = 0; j < SEG_W; j++) {
73147315
SEGMENT.setPixelColorXY(j, *prevBarHeight, SEGCOLOR(2));
73157316
}
@@ -7319,7 +7320,7 @@ uint16_t mode_single_eqbar(void) {
73197320
}
73207321
if (*prevBarHeight < SEGLEN) {
73217322

7322-
if (strip.isMatrix || SEGMENT.is2D()) {
7323+
if (is2d) {
73237324
for (int j = 0; j < SEG_W; j++) {
73247325
SEGMENT.setPixelColorXY(j, *prevBarHeight + 1, BLACK); // clear next pixel immediately.
73257326
}

0 commit comments

Comments
 (0)