@@ -18,8 +18,7 @@ void volumeLEDOutputUnoR4(LEDOutputUnoR4Config *cfg, LEDOutputUnoR4 *matrix);
18
18
* @author Phil Schatzmann
19
19
*/
20
20
struct LEDOutputUnoR4Config {
21
- // / Custom callback logic to update the LEDs - by default we use
22
- // / fftLEDOutputUnoR4()
21
+ // / Custom callback logic to update the LEDs when update() is called
23
22
void (*update_callback)(LEDOutputUnoR4Config *cfg,
24
23
LEDOutputUnoR4 *matrix) = nullptr ;
25
24
// / Update the leds only ever nth call
@@ -28,29 +27,32 @@ struct LEDOutputUnoR4Config {
28
27
int x = 12 ;
29
28
// / Number of LEDs in a column
30
29
int y = 8 ;
30
+ // / when true 0,0 is in the lower left corder
31
31
bool y_mirror = true ;
32
32
// / Influences the senitivity
33
33
int max_magnitude = 700 ;
34
34
};
35
35
36
36
/* *
37
- * @brief LEDOutputUnoR4 using the FastLED library. You write the data to the
38
- * FFT Stream. This displays the result of the FFT to a LED matrix.
37
+ * @brief LED output using the R4 LED matrix library.
39
38
* @ingroup io
40
39
* @author Phil Schatzmann
41
40
*/
42
41
class LEDOutputUnoR4 {
43
42
44
43
public:
44
+ // / @brief Default Constructor
45
45
LEDOutputUnoR4 () = default ;
46
46
47
- // / @brief Default Constructor
47
+ // / @brief Constructor for FFT scenario
48
48
// / @param fft
49
49
LEDOutputUnoR4 (FFTDisplay &fft) {
50
50
p_fft = &fft;
51
51
cfg.update_callback = fftLEDOutputUnoR4;
52
52
}
53
53
54
+ // / @brief Constructor for VolumeOutput scenario
55
+ // / @param vol
54
56
LEDOutputUnoR4 (VolumeOutput &vol) {
55
57
p_vol = &vol;
56
58
cfg.update_callback = volumeLEDOutputUnoR4;
@@ -59,6 +61,7 @@ class LEDOutputUnoR4 {
59
61
// / Provides the default config object
60
62
LEDOutputUnoR4Config defaultConfig () { return cfg; }
61
63
64
+ // / Starts the processing with the default configuration
62
65
bool begin () { return begin (defaultConfig ()); }
63
66
64
67
// / Setup Led matrix
@@ -70,8 +73,7 @@ class LEDOutputUnoR4 {
70
73
return true ;
71
74
}
72
75
73
- // / Updates the display by calling the update callback method: call this
74
- // / method in your loop
76
+ // / Updates the display by calling the update callback method: call this method in your loop
75
77
virtual void update () {
76
78
if (cfg.update_callback != nullptr && count++ % cfg.update_frequency == 0 ) {
77
79
// use custom update logic defined in config
@@ -85,7 +87,7 @@ class LEDOutputUnoR4 {
85
87
return frame[x + (y * cfg.x )];
86
88
}
87
89
88
- // / @brief Provodes the max magnitude
90
+ // / Provodes the max magnitude for the VolumeOutput and FFT scenario
89
91
virtual float getMaxMagnitude () {
90
92
// get magnitude from
91
93
if (p_vol != nullptr ) {
@@ -128,14 +130,15 @@ class LEDOutputUnoR4 {
128
130
setColumnBar (max_column, currY);
129
131
}
130
132
131
- // / Provides access to the actual config object. E.g. to change the update
132
- // / logic
133
+ // / Provides access to the actual config object. E.g. to change the update logic
133
134
LEDOutputUnoR4Config &config () { return cfg; }
134
135
136
+ // / Update the led_matrix
135
137
void display () {
136
138
led_matrix.loadPixels ((uint8_t *)frame.data (), cfg.x * cfg.y );
137
139
}
138
140
141
+ // / Provides access to the FFTDisplay object
139
142
FFTDisplay& fftDisplay () {
140
143
return *p_fft;
141
144
}
0 commit comments