@@ -9,6 +9,10 @@ struct LEDOutputConfig;
9
9
LEDOutput *selfLEDOutput=nullptr ;
10
10
// default callback function which implements led update
11
11
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
+ }
12
16
13
17
/* *
14
18
* LED Matrix Configuration. Provide the number of leds in x and y direction and
@@ -19,10 +23,8 @@ struct LEDOutputConfig {
19
23
int x = 0 ;
20
24
// / Number of leds in y direction
21
25
int y = 0 ;
22
- // / Default color
23
- int color = CRGB::Blue;
24
26
// / 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 ;
26
28
// / Custom callback logic to update the LEDs - by default we use updateLEDOutput()
27
29
void (*update)(LEDOutputConfig*cfg, LEDOutput *matrix, int max_y) = updateLEDOutput;
28
30
// / Update the leds only ever nth call
@@ -160,10 +162,9 @@ void updateLEDOutput(LEDOutputConfig*cfg, LEDOutput *matrix, int max_y){
160
162
}
161
163
// update horizontal bar
162
164
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
167
168
matrix->xyLed (x, y) = color;
168
169
}
169
170
}
0 commit comments