@@ -2,17 +2,15 @@ boolean MSGEQ7read() {
22 return fft_available;
33}
44
5-
65#define MSGEQ7_OUT_MAX 255
76
87int MSGEQ7get (int band, int channel) {
9- int value = map ((fftData[band] * 100 ), 0 , 100 , 0 , MSGEQ7_OUT_MAX);
8+ int value = map ((fftData[band] * 1000 ), 0 , 100 , 0 , MSGEQ7_OUT_MAX); // TODO: should be 100, but testing at home
109// Serial.printf("Band: %u = %u\n", band, value);
1110 return value;
1211}
1312
14- int barWidth = (kMatrixWidth / 8 ) / 2 ;
15- int blockWidth = barWidth * 8 ;
13+ int barWidth = (kMatrixHeight / 8 );
1614
1715void drawPixel (int x, int y, CRGB color) {
1816 leds[XY (x, y)] = color;
@@ -34,41 +32,26 @@ void FunkyPlank() {
3432 int hue = MSGEQ7get (band, 0 );
3533 int v = map (MSGEQ7get (band, 0 ), 0 , MSGEQ7_OUT_MAX, 10 , 255 );
3634 for (int b = 0 ; b < barWidth; b++) {
37- int xpos = blockWidth - (barWidth * band) - b;
38- drawPixel (xpos, 0 , CHSV (hue, 255 , v));
39- // Serial.printf("band: %u, hue: %u v: %u\n", band, hue, v);
35+ int pos = (barWidth * band) + b;
36+ drawPixel (0 , pos , CHSV (hue, 255 , v));
37+ Serial.printf (" pos: %u band: %u hue: %u v: %u\n " , pos , band, hue, v);
4038 // drawPixel((offset + band + 1), 0, CHSV(hue, 255, 255));
4139 }
4240 }
4341
44- // display values of left channel on DMD
45- for (int band = 0 ; band < 8 ; band++ )
46- {
47- int hue = MSGEQ7get (band, 1 );
48- int v = map (MSGEQ7get (band, 1 ), 0 , MSGEQ7_OUT_MAX, 10 , 255 );
49- for (int b = 0 ; b < barWidth; b++) {
50- int xpos = blockWidth + 1 + (barWidth * band) + b;
51- drawPixel (xpos, 0 , CHSV (hue, 255 , v));
42+ // Update the display:
43+ for (int i = (kMatrixHeight - 1 ); i >= 0 ; i--) {
44+ for (int j = (kMatrixWidth - 1 ); j >= 0 ; j--) {
45+ int src = XY ((j - 1 ), i);
46+ int dst = XY (j, i);
47+ leds[dst] = leds[src];
5248 }
5349 }
54-
55- FastLED.show ();
56- moveUp ();
50+ FastLED.show (); // TODO: needs non-blocking delay
5751
5852 }
5953}
6054
61- void moveUp () {
62- // Update the display:
63- for (int i = (kMatrixHeight - 1 ); i >= 0 ; i--) {
64- for (int j = (kMatrixWidth - 1 ); j >= 0 ; j--) {
65- int src = XY (j, (i - 1 ));
66- int dst = XY (j, i);
67- leds[dst] = leds[src];
68- }
69- }
70- }
71-
7255
7356// DJ Light -----------------------------------------------------------------------------------
7457
@@ -85,20 +68,19 @@ void DJLight() {
8568 if (newReading) {
8669
8770 int bands[8 ];
88- for (int band = 0 ; band < 8 ; band++ )
89- {
90- bands[band] = MSGEQ7get (band, 1 );
71+ for (int band = 0 ; band < 8 ; band++ ) {
72+ bands[band] = MSGEQ7get (band, 1 ) / 2 ;
9173 }
9274
9375
9476// leds[mid] = CRGB(bands[6], bands[5] / 8, bands[1] / 2);
9577// leds[mid].fadeToBlackBy(bands[3] / 12);
9678
9779
98- ledsAudio[mid] = CRGB (bands[5 ]/ 2 , bands[2 ]/ 2 , bands[0 ]/ 2 );
80+ ledsAudio[mid] = CRGB (bands[5 ], bands[2 ], bands[0 ]);
9981 ledsAudio[mid].fadeToBlackBy ((map (bands[1 ], 0 , MSGEQ7_OUT_MAX, 255 , 10 )));
10082
101- Serial.printf (" RGB: %u %u %u\n " , bands[5 ]/ 2 , bands[2 ]/ 2 , bands[0 ]/ 2 );
83+ Serial.printf (" RGB: %u %u %u\n " , bands[5 ], bands[2 ], bands[0 ]);
10284
10385
10486 // move to the left
0 commit comments