@@ -10,30 +10,33 @@ LEDOutput *selfLEDOutput=nullptr;
10
10
// default callback function which implements led update
11
11
void updateLEDOutput (LEDOutputConfig*cfg, LEDOutput *matrix, int max_y);
12
12
// default color
13
- CHSV get_color (int x, int y, int magnitude){
14
- return CHSV ( 224 , 187 , 255 );
13
+ CHSV getColor (int x, int y, int magnitude){
14
+ return CHSV ( 224 , 187 , 100 );
15
15
}
16
16
17
17
/* *
18
18
* LED Matrix Configuration. Provide the number of leds in x and y direction and
19
19
* the data pin.
20
+ * @author Phil Schatzmann
20
21
*/
21
22
struct LEDOutputConfig {
22
23
// / Number of leds in x direction
23
24
int x = 0 ;
24
25
// / Number of leds in y direction
25
26
int y = 0 ;
26
- // / optinal custom logic to select color
27
- CHSV (*get_color )(int x, int y, int magnitude) = get_color ;
27
+ // / optinal custom logic to provide CHSV color: Prividing a 'rainbow' color with hue 0-255, saturating 0-255, and brightness (value) 0-255 (v2)
28
+ CHSV (*color_callback )(int x, int y, int magnitude) = getColor ;
28
29
// / Custom callback logic to update the LEDs - by default we use updateLEDOutput()
29
- void (*update )(LEDOutputConfig*cfg, LEDOutput *matrix, int max_y) = updateLEDOutput;
30
+ void (*update_callback )(LEDOutputConfig*cfg, LEDOutput *matrix, int max_y) = updateLEDOutput;
30
31
// / Update the leds only ever nth call
31
32
int update_frequency = 1 ; // update every call
32
33
};
33
34
34
35
/* *
35
36
* LEDOutput using the FastLED library. You write the data to the FFT Stream.
36
37
* This displays the result of the FFT to a LED matrix.
38
+ * @ingroup io
39
+ * @author Phil Schatzmann
37
40
*/
38
41
class LEDOutput {
39
42
public:
@@ -75,14 +78,13 @@ class LEDOutput {
75
78
return true ;
76
79
}
77
80
78
- // Provides the number of LEDs: call begin() first!
81
+ // / Provides the number of LEDs: call begin() first!
79
82
int ledCount (){
80
83
int num_leds = cfg.x * cfg.y ;
81
84
return num_leds;
82
85
}
83
86
84
- // / @brief Provides the address fo the CRGB array: call begin() first!
85
- // / @return
87
+ // / Provides the address fo the CRGB array: call begin() first!
86
88
CRGB* ledData () {
87
89
if (ledCount () == 0 ) {
88
90
LOGE (" x or y == 0" );
@@ -94,9 +96,9 @@ class LEDOutput {
94
96
95
97
// / Updates the display: call this method in your loop
96
98
virtual void update () {
97
- if (count++ % cfg.update_frequency == 0 ) {
99
+ if (cfg. update_callback != nullptr && count++ % cfg.update_frequency == 0 ) {
98
100
// use custom update logic defined in config
99
- cfg.update (&cfg, this , max_y);
101
+ cfg.update_callback (&cfg, this , max_y);
100
102
}
101
103
}
102
104
@@ -163,7 +165,7 @@ void updateLEDOutput(LEDOutputConfig*cfg, LEDOutput *matrix, int max_y){
163
165
// update horizontal bar
164
166
for (int y = 0 ; y < maxY; y++) {
165
167
// determine color
166
- CHSV color = cfg->get_color (x, y, maxY);
168
+ CHSV color = cfg->color_callback (x, y, maxY);
167
169
// update LED
168
170
matrix->xyLed (x, y) = color;
169
171
}
0 commit comments