4 #include "AudioTools/AudioLibs/AudioFFT.h"
5 #include "FFTDisplay.h"
10 struct LEDOutputConfig;
13 void fftLEDOutput(LEDOutputConfig *cfg, LEDOutput *matrix);
37 bool is_serpentine_layout =
true;
38 bool is_matrix_vertical =
true;
79 for (
int j = 0; j <
ledCount(); j++) {
86 if (p_fft !=
nullptr) {
97 int num_leds = cfg.
x * cfg.
y;
123 if (x > cfg.
x) x = cfg.
x - 1;
125 if (y > cfg.
y) y = cfg.
y - 1;
127 int index = xy(x, y);
132 CRGB &
led(uint8_t index) {
133 if (index > cfg.
x * cfg.
y)
return not_valid;
140 for (uint8_t y = 0; y < currY; y++) {
146 for (uint8_t y = currY; y < cfg.
y; y++) {
147 ledXY(x, y) = CRGB::Black;
149 if (x > max_column) max_column = x;
158 if (max_column >= cfg.
x) {
161 if (max_column > cfg.
x - 1) {
162 max_column = cfg.
x - 1;
173 if (p_vol !=
nullptr) {
177 if (p_fft !=
nullptr) {
178 for (
int j = 0; j < cfg.
x; j++) {
201 VolumeMeter *p_vol =
nullptr;
202 FFTDisplay *p_fft =
nullptr;
208 for (
int x = 1; x < cfg.x; x++) {
209 for (
int y = 0; y < cfg.y; y++) {
213 for (
int y = 0; y < cfg.y; y++) {
214 ledXY(cfg.x - 1, y) = CRGB::Black;
218 uint16_t xy(uint8_t x, uint8_t y) {
221 if (cfg.is_serpentine_layout ==
false) {
222 if (cfg.is_matrix_vertical ==
false) {
225 i = cfg.y * (cfg.x - (x + 1)) + y;
229 if (cfg.is_serpentine_layout ==
true) {
230 if (cfg.is_matrix_vertical ==
false) {
233 uint8_t reverseX = (cfg.x - 1) - x;
234 i = (y * cfg.x) + reverseX;
241 i = cfg.y * (cfg.x - (x + 1)) + y;
243 i = cfg.y * (cfg.x - x) - (y + 1);
256 for (
int x = 0; x < cfg->
x; x++) {
258 int currY = matrix->
fftDisplay().getMagnitudeScaled(x, cfg->
y);
259 LOGD(
"x: %d, y: %d", x, currY);
268 int currY = mapT<float>(vol, 0,
270 static_cast<float>(cfg->
y));
277 int color =
map(magnitude, 0, 7, 255, 0);
278 return CHSV(color, 255, 100);