Skip to content

Commit 4a43391

Browse files
committed
LEDOutput
1 parent 2f7cbdb commit 4a43391

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/AudioLibs/LEDOutput.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ struct LEDOutputConfig;
99
LEDOutput *selfLEDOutput=nullptr;
1010
// default callback function which implements led update
1111
void updateLEDOutput(LEDOutputConfig*cfg, LEDOutput *matrix, int max_y);
12+
// default color
13+
CHSV get_color(int x, int y, int magnitude){
14+
return CHSV( 224, 187, 255);
15+
}
1216

1317
/**
1418
* LED Matrix Configuration. Provide the number of leds in x and y direction and
@@ -19,10 +23,8 @@ struct LEDOutputConfig {
1923
int x = 0;
2024
/// Number of leds in y direction
2125
int y = 0;
22-
/// Default color
23-
int color = CRGB::Blue;
2426
/// optinal custom logic to select color
25-
int (*get_color)(int x, int y, int magnitude) = nullptr;
27+
CHSV (*get_color)(int x, int y, int magnitude) = get_color;
2628
/// Custom callback logic to update the LEDs - by default we use updateLEDOutput()
2729
void (*update)(LEDOutputConfig*cfg, LEDOutput *matrix, int max_y) = updateLEDOutput;
2830
/// Update the leds only ever nth call
@@ -160,10 +162,9 @@ void updateLEDOutput(LEDOutputConfig*cfg, LEDOutput *matrix, int max_y){
160162
}
161163
// update horizontal bar
162164
for (int y = 0; y < maxY; y++) {
163-
int color = cfg->color;
164-
if (cfg->get_color != nullptr) {
165-
color = cfg->get_color(x, y, maxY);
166-
}
165+
// determine color
166+
CHSV color = cfg->get_color(x, y, maxY);
167+
// update LED
167168
matrix->xyLed(x, y) = color;
168169
}
169170
}

0 commit comments

Comments
 (0)