forked from fivefishstudios/AuroraDrop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAuroraDrop-LXP.ino
807 lines (543 loc) · 24.1 KB
/
AuroraDrop-LXP.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
/*
* Suggested simple hardware solution:-
*
* ESP32 I2S Matrix Shield
* https://github.com/witnessmenow/ESP32-i2s-Matrix-Shield
* https://www.youtube.com/watch?v=ZiR93TmSyE0
*
* Libraries needed:-
*
* FastLED (tested with v3.5)
* https://github.com/FastLED/FastLED
*
* ESP32 HUB75 LED MATRIX PANEL DMA Display (tested with v3.0.0)
* https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA
*
* ArduinoFFT - "develop" branch (Last commit Sept 26, 2022)
* https://github.com/kosme/arduinoFFT/tree/develop
*
*/
// =================================================================================================
// == START basic user configuration ===============================================================
// =================================================================================================
#define PANEL_WIDTH 64
#define PANEL_HEIGHT 64
#define PANELS_NUMBER 2
int GLOBAL_BRIGHTNESS = 255; //0-255 - this gets overridden with the ADC value if BRIGHT_PIN is defined - otherwise it stays here.
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
// #define PRODUCTION_BOARD
#ifdef PRODUCTION_BOARD
#pragma message("HUB75 - Production Board Pinout")
// HUB75 Pins
//
#define R1_PIN 21
#define G1_PIN 16
#define B1_PIN 26
// placeholder GND - skip
#define R2_PIN 33
#define G2_PIN 14
#define B2_PIN 34
#define E_PIN 13
#define A_PIN 35
#define B_PIN 12
#define C_PIN 36
#define D_PIN 11 // GND on silkscreen, but working example is assigned to a pin tho where "D" should be on the HUB75 connector, after C
#define CLK_PIN 37
#define LAT_PIN 10
#define OE_PIN 38
// placeholder GND - skip
// INMP441 Pins
//
#define I2S_WS 6
#define I2S_SCK 7
#define I2S_SD 8
// ESP32-S3 Devkit C/M have these, optional - but if you have one, define it.
//
#define ONBOARD_RGB_LED_PIN 48
// Brightness ADC pin, optional
//
#define BRIGHT_PIN 1
// Quick definition for debug pin, optional
// Boot button is often 0 and LOW
//
#define PIN_FOR_DEBUG_MODE 0
#define PIN_FOR_DEBUG_MODE_STATE LOW
// Show personalized dedication on debug screen - don't use this
//
// #define DEDICATION
#else
#pragma message("HUB75 - Testbed Board Pinout")
// Testbed Board
// HUB75 Pins
//
#define R1_PIN 42
#define G1_PIN 6
#define B1_PIN 41
// placeholder GND - 7
#define R2_PIN 40
#define G2_PIN 15
#define B2_PIN 39
#define E_PIN 16
#define A_PIN 38
#define B_PIN 17
#define C_PIN 37
#define D_PIN 18 // GND on silkscreen, but working example is assigned to a pin tho where "D" should be on the HUB75 connector, after C
#define CLK_PIN 36
#define LAT_PIN 8
#define OE_PIN 35
// placeholder GND - 3
// INMP441 Pins
//
#define I2S_WS 20
#define I2S_SCK 19
#define I2S_SD 14
// ESP32-S3 Devkit C/M have these
//
// #define ONBOARD_RGB_LED_PIN 48
// Brightness ADC pin, optional
//
// #define BRIGHT_PIN 1
// Quick definition for debug pin, optional
// Boot button is often 0 and LOW
//
#define PIN_FOR_DEBUG_MODE 0
#define PIN_FOR_DEBUG_MODE_STATE LOW
#endif
MatrixPanel_I2S_DMA *dma_display = nullptr;
#include <FastLED.h>
#ifdef ONBOARD_RGB_LED_PIN
// If it's present and not initialized, it can behave randonly...
CRGB statusled[1];
CLEDController* statuscontroller = &FastLED.addLeds<NEOPIXEL, ONBOARD_RGB_LED_PIN>(statusled, 1);
#endif
#define MATRIX_WIDTH (PANEL_WIDTH * PANELS_NUMBER) // works with 1x to 4x 32x64 and 64x32 panels in landscape
#define MATRIX_HEIGHT (PANEL_HEIGHT) // doesn't seem to making "tall" portrait arrays - yet.
#define MATRIX_CENTER_X (MATRIX_WIDTH / 2)
#define MATRIX_CENTER_Y (MATRIX_HEIGHT / 2)
// diagnostic options, some can be enabled by a button if setup
//
bool option1Diagnostics = false;
bool option2LockFps = false;
bool option3ShowRenderTime = false;
bool option4PauseCycling = false;
bool option5ShowEffectsStack = false;
bool option6DisableForeground = false;
bool option7DisableAudio = false;
bool option8DisableStatic = false;
bool option9DisableBackground = false;
bool option10DisableCaleidoEffects = false;
class FFTData{
// this class holds some data, but nothing calls its functions...
// ... and a lot of things are defined and never used, so paired down significantly.
// ... mostly this is here to avoid many edits to remove the references to
// this class.
public:
#define BINS 128
uint16_t bpm = 120; // for testing currently, not fully implemented yet by most test patterns
byte specDataMaxVolume;
byte specDataMinVolume;
byte specData8[8];
byte specData16[16];
byte specData32[32];
byte specData64[64];
byte specData[128];
bool noAudio = true;
};
FFTData fftData;
#include "FftMic.h"
// fixed maximums here for memory allocation, these must be >= variables used below
//
#define MAX_PLAYLISTS_BACKGROUND 1 // Background effect. Leave it at 1.
#define MAX_PLAYLISTS_AUDIO 2 // audio reactive effects
#define MAX_PLAYLISTS_STATIC 2 // standard non-audio animations inc. boids etc.
#define MAX_PLAYLISTS_FOREGROUND 2 // bluring/fading/sweeping effects
//
// ...this is also the order the effects are layered - with "FOREGROUND" on top
static uint8_t CountPlaylistsBackground = MAX_PLAYLISTS_BACKGROUND; // This is now the farthest back effects, background of the entire frame.
static uint8_t CountPlaylistsAudio = MAX_PLAYLISTS_AUDIO; // <------- 2 or 3
static uint8_t CountPlaylistsStatic = MAX_PLAYLISTS_STATIC; // <------- 2 or 3
static uint8_t CountPlaylistsForeground = MAX_PLAYLISTS_FOREGROUND; // <------- 1 or 2 - Foreground effect
#include "Geometry.h"
#include "Effects.h"
Effects effects;
#include "Drawable.h"
#include "Playlist.h"
#include "Vector.h"
#include "Boid.h"
#include "Attractor.h"
#include "Playlist_Foreground.h"
#include "Playlist_Background.h"
#include "Playlist_Audio.h"
#include "Playlist_Static.h"
Playlist_Background playlistBackground[MAX_PLAYLISTS_BACKGROUND];
Playlist_Audio playlistAudio[MAX_PLAYLISTS_AUDIO];
Platlist_Static playlistStatic[MAX_PLAYLISTS_STATIC];
Playlist_Foreground playlistForeground[MAX_PLAYLISTS_FOREGROUND];
// TODO: sort? useful or not - I don't know if this does anything...
//
static uint8_t PatternsAudioMainEffectCount = 0;
static uint8_t PatternsAudioBackdropCount = 0;
static uint8_t PatternsAudioCaleidoscopeCount = 0;
static uint16_t PatternsAudioBluringCount = 0;
uint32_t startMillis = millis();
uint32_t Xlast_render_ms = millis();
#include "Diagnostics.h"
void setup() {
#ifdef BRIGHT_PIN
// set on startup so we don't blow up someone's eyeballs
analogReadResolution(8);
GLOBAL_BRIGHTNESS = analogRead(BRIGHT_PIN);
#endif
Serial.begin(115200);
delay(1000);
Serial.printf("ESP32 IDF version: %s\n",IDF_VER);
#ifdef ONBOARD_RGB_LED_PIN
statuscontroller->leds()[0] = CRGB::Purple;
statuscontroller->showLeds(10);
#endif
HUB75_I2S_CFG mxconfig;
mxconfig.mx_height = PANEL_HEIGHT;
mxconfig.mx_width = PANEL_WIDTH;
mxconfig.chain_length = PANELS_NUMBER;
mxconfig.gpio.r1 = R1_PIN;
mxconfig.gpio.g1 = G1_PIN;
mxconfig.gpio.b1 = B1_PIN;
mxconfig.gpio.r2 = R2_PIN;
mxconfig.gpio.g2 = G2_PIN;
mxconfig.gpio.b2 = B2_PIN;
mxconfig.gpio.a = A_PIN;
mxconfig.gpio.b = B_PIN;
mxconfig.gpio.c = C_PIN;
mxconfig.gpio.d = D_PIN;
mxconfig.gpio.e = E_PIN;
mxconfig.gpio.lat = LAT_PIN;
mxconfig.gpio.oe = OE_PIN;
mxconfig.gpio.clk = CLK_PIN;
mxconfig.driver = HUB75_I2S_CFG::FM6126A; // my panels (with D or E pins) have needed this.
Serial.println("Starting HUB75 Display Test...");
dma_display = new MatrixPanel_I2S_DMA(mxconfig);
dma_display->begin();
dma_display->setBrightness8(GLOBAL_BRIGHTNESS);
dma_display->fillScreenRGB888(255,0,0);
delay(150);
dma_display->fillScreenRGB888(0,255,0);
delay(150);
dma_display->fillScreenRGB888(0,0,255);
delay(150);
dma_display->fillScreenRGB888(128,128,128);
delay(150);
dma_display->clearScreen();
setupAudio();
Serial.println("Starting AuroraDrop LXG Demo...");
// setup the effects and noise generator
//
effects.Setup();
Serial.println("Effects being loaded: ");
listPatterns();
// initialise all the initial effects patterns
//
for (uint8_t i=0; i < MAX_PLAYLISTS_FOREGROUND; i++) {
playlistForeground[i].default_fps = 90;
playlistForeground[i].pattern_fps = 90;
playlistForeground[i].ms_animation_max_duration = animation_duration;
do {
playlistForeground[i].moveRandom(1, i);
} while (!playlistForeground[i].getCurrentItemEnabled());
Serial.print("Starting with foreground pattern: ");
Serial.println(playlistForeground[i].getCurrentPatternName());
playlistForeground[i].start(i);
playlistForeground[i].ms_previous = millis();
playlistForeground[i].fps_timer = millis();
for (uint8_t j=0; j < playlistForeground[i].getPatternCount(); j++) {
playlistForeground[i].setItemEnabled(j, 1);
if (MATRIX_WIDTH > 128+64) {
if (playlistForeground[i].getItemName(j) == "Munch") playlistForeground[i].setItemEnabled(j, 0);
}
}
}
// initialise all the audio effects patterns
//
for (uint8_t i=0; i < MAX_PLAYLISTS_AUDIO; i++) {
playlistAudio[i].default_fps = 90;
playlistAudio[i].pattern_fps = 90;
playlistAudio[i].ms_animation_max_duration = animation_duration;
do {
playlistAudio[i].moveRandom(1, i);
} while (!playlistAudio[i].getCurrentItemEnabled());
Serial.print("Starting with static effects pattern: ");
Serial.println(playlistAudio[i].getCurrentPatternName());
playlistAudio[i].start(i);
playlistAudio[i].ms_previous = millis();
playlistAudio[i].fps_timer = millis();
// TESTING: enable all the effects
for (uint8_t j=0; j < playlistAudio[i].getPatternCount(); j++) {
playlistAudio[i].setItemEnabled(j, 1);
if (MATRIX_WIDTH > 128) {
if (playlistAudio[i].getItemName(j) == "Audio Dots Single") playlistAudio[i].setItemEnabled(j, 0);
if (playlistAudio[i].getItemName(j) == "AuroraDrop") playlistAudio[i].setItemEnabled(j, 0);
}
if (MATRIX_WIDTH > 128+64) {
if (playlistAudio[i].getItemName(j) == "Test Spectrum Pattern") playlistAudio[i].setItemEnabled(j, 0);
if (playlistAudio[i].getItemName(j) == "Classic 128 Spectrum") playlistAudio[i].setItemEnabled(j, 0);
}
}
}
// initialise all the static/non-audio effects patterns
//
for (uint8_t i=0; i < MAX_PLAYLISTS_STATIC; i++) {
playlistStatic[i].default_fps = 90;
playlistStatic[i].pattern_fps = 90;
playlistStatic[i].ms_animation_max_duration = animation_duration*8; // 16 beats * 8
do {
playlistStatic[i].moveRandom(1, i);
} while (!playlistStatic[i].getCurrentItemEnabled());
Serial.print("Starting with static effects pattern: ");
Serial.println(playlistStatic[i].getCurrentPatternName());
playlistStatic[i].start(i);
playlistStatic[i].ms_previous = millis();
playlistStatic[i].fps_timer = millis();
// TESTING: enable all the effects
for (uint8_t j=0; j < playlistStatic[i].getPatternCount(); j++) {
playlistStatic[i].setItemEnabled(j, 1);
}
}
for (uint8_t i=0; i < MAX_PLAYLISTS_BACKGROUND; i++) {
playlistBackground[i].default_fps = 90;
playlistBackground[i].pattern_fps = 90;
playlistBackground[i].ms_animation_max_duration = animation_duration;
do {
playlistBackground[i].moveRandom(1, i);
} while (!playlistBackground[i].getCurrentItemEnabled());
Serial.print("Starting with intitial effects pattern: ");
Serial.println(playlistBackground[i].getCurrentPatternName());
playlistBackground[i].start(i);
playlistBackground[i].ms_previous = millis();
playlistBackground[i].fps_timer = millis();
// TESTING: enable all the effects
for (uint8_t j=0; j < playlistBackground[i].getPatternCount(); j++) {
playlistBackground[i].setItemEnabled(j, 1);
}
}
Xlast_render_ms = millis();
}
void loop() {
#ifdef BRIGHT_PIN
GLOBAL_BRIGHTNESS = (GLOBAL_BRIGHTNESS * 0.9) + (analogRead(BRIGHT_PIN) * 0.1);
if (GLOBAL_BRIGHTNESS < 2) {
GLOBAL_BRIGHTNESS = 0;
}
if (GLOBAL_BRIGHTNESS == 0) {
delay(500);
return;
}
#endif
#ifdef PIN_FOR_DEBUG_MODE
if (digitalRead(PIN_FOR_DEBUG_MODE) == PIN_FOR_DEBUG_MODE_STATE) {
// OFF, Main Debug, Effects Stack List
if (option1Diagnostics == false && option5ShowEffectsStack == false) {
option1Diagnostics = true;
option5ShowEffectsStack = false;
} else if (option1Diagnostics == true && option5ShowEffectsStack == false) {
option1Diagnostics = false;
option5ShowEffectsStack = true;
} else {
option1Diagnostics = false;
option5ShowEffectsStack = false;
}
delay(500); // simple debounce
}
#endif
start_render_ms = millis();
// check here if we are ready to render the next frame or not
//
if (option2LockFps && millis() < Xlast_render_ms + 50) return; // 40=25fps, 50=20fps;
Xlast_render_ms = millis();
if (CountPlaylistsForeground==0 || option6DisableForeground) effects.DimAll(230); // if we have no effects enabled, dim screen by small amount (e.g. during testing)
// clear counters/flags for psuedo randomness workings inside pattern setup and drawing
//
PatternsAudioMainEffectCount = 0;
PatternsAudioBackdropCount = 0;
PatternsAudioCaleidoscopeCount = 0;
PatternsAudioBluringCount = 0;
// Background effects - rendered first (and the back)
//
if (!option9DisableBackground) {
for (uint8_t i=0; i < CountPlaylistsBackground; i++) {
// #-------- start next animation if maxduration reached --------#
//
if ( (millis() - playlistBackground[i].ms_previous) > playlistBackground[i].ms_animation_max_duration) {
if (!option4PauseCycling) {
playlistBackground[i].stop();
do {
playlistBackground[i].moveRandom(1, i);
} while (!playlistBackground[i].getCurrentItemEnabled());
playlistBackground[i].ms_animation_max_duration = animation_duration;
playlistBackground[i].start(i);
Serial.print("Changing background effect pattern to: ");
Serial.println(playlistBackground[i].getCurrentPatternName());
playlistBackground[i].ms_previous = millis();
playlistBackground[i].fps_timer = millis();
}
}
// -------- draw the next frame if fps timer dictates so --------
//
if (1000 / playlistBackground[i].pattern_fps + playlistBackground[i].last_frame < millis()) {
playlistBackground[i].last_frame = millis();
playlistBackground[i].pattern_fps = playlistBackground[i].drawFrame(i, CountPlaylistsBackground);
if (!playlistBackground[i].pattern_fps) {
playlistBackground[i].pattern_fps = playlistBackground[i].default_fps;
}
++playlistBackground[i].fps;
playlistBackground[i].render_ms = millis() - playlistBackground[i].last_frame;
}
if (playlistBackground[i].fps_timer + 1000 < millis()){
playlistBackground[i].fps_timer = millis();
playlistBackground[i].fps_last = playlistBackground[i].fps;
actual_fps = playlistBackground[i].fps;
playlistBackground[i].fps = 0;
}
}
}
// -------------- loop through, and apply each of the audio re-active patterns ----------------
//
if (!option7DisableAudio) {
for (uint8_t i=0; i < CountPlaylistsAudio; i++) {
// -------- start next animation if max duration reached --------
//
if ( (millis() - playlistAudio[i].ms_previous) > playlistAudio[i].ms_animation_max_duration) {
if (!option4PauseCycling) {
playlistAudio[i].stop();
do {
playlistAudio[i].moveRandom(1, i);
} while (!playlistAudio[i].getCurrentItemEnabled());
playlistAudio[i].ms_animation_max_duration = animation_duration;
playlistAudio[i].start(i);
Serial.print("Changing audio pattern to: ");
Serial.println(playlistAudio[i].getCurrentPatternName());
Serial.printf("multAgc: %f\n", multAgc);
Serial.printf("Brightness: %d\n", GLOBAL_BRIGHTNESS);
playlistAudio[i].ms_previous = millis();
playlistAudio[i].fps_timer = millis();
// select a random palette when ANY of the audio patterns start/re-start, this can look funky when/if they start changing out out sync
// TODO: consider randomly locking palette change to only when the first pattern of the group re-starts (or maybe also when an initial effect restarts)
// possible bug? if we change the palette when the palette is currently transitioning to another, the palette changes abruptly?
//
effects.RandomPalette();
}
}
// -------- draw the next frame if fps timer dictates so --------
//
if ( 1000 / playlistAudio[i].pattern_fps + playlistAudio[i].last_frame < millis()) {
playlistAudio[i].last_frame = millis();
playlistAudio[i].pattern_fps = playlistAudio[i].drawFrame(i, CountPlaylistsAudio);
if (!playlistAudio[i].pattern_fps) {
playlistAudio[i].pattern_fps = playlistAudio[i].default_fps;
}
++playlistAudio[i].fps;
playlistAudio[i].render_ms = millis() - playlistAudio[i].last_frame;
}
// ----- every 1000ms update fps and timer
//
if (playlistAudio[i].fps_timer + 1000 < millis()){
playlistAudio[i].fps_timer = millis();
playlistAudio[i].fps_last = playlistAudio[i].fps;
actual_fps = playlistAudio[i].fps;
playlistAudio[i].fps = 0;
}
}
}
// ---------- loop through, and apply each of the audio static (mostly) patterns, e.g. boids --------
//
if (!option8DisableStatic) {
for (uint8_t i=0; i < CountPlaylistsStatic; i++) {
// -------- start next animation if max duration reached --------
//
if ((millis() - playlistStatic[i].ms_previous) > playlistStatic[i].ms_animation_max_duration) {
if (!option4PauseCycling) {
playlistStatic[i].stop();
do {
playlistStatic[i].moveRandom(1, i);
} while (!playlistStatic[i].getCurrentItemEnabled());
playlistStatic[i].ms_animation_max_duration = animation_duration;
playlistStatic[i].start(i);
Serial.print("Changing static pattern to: ");
Serial.println(playlistStatic[i].getCurrentPatternName());
playlistStatic[i].ms_previous = millis();
playlistStatic[i].fps_timer = millis();
}
}
// -------- draw the next frame if fps timer dictates so --------
//
if (1000 / playlistStatic[i].pattern_fps + playlistStatic[i].last_frame < millis()) {
playlistStatic[i].last_frame = millis();
playlistStatic[i].pattern_fps = playlistStatic[i].drawFrame(i, CountPlaylistsStatic);
if (!playlistStatic[i].pattern_fps) {
playlistStatic[i].pattern_fps = playlistStatic[i].default_fps;
}
++playlistStatic[i].fps;
playlistStatic[i].render_ms = millis() - playlistStatic[i].last_frame;
}
// ----- every 1000ms update fps and timer
//
if (playlistStatic[i].fps_timer + 1000 < millis()){
playlistStatic[i].fps_timer = millis();
playlistStatic[i].fps_last = playlistStatic[i].fps;
actual_fps = playlistStatic[i].fps;
playlistStatic[i].fps = 0;
}
}
}
// This is the most foreground effect(s). This allows blurs over the entire rendered frame, for example
//
if (!option6DisableForeground) {
for (uint8_t i=0; i < CountPlaylistsForeground; i++) {
// -------- start next animation if max duration reached --------
//
if ( (millis() - playlistForeground[i].ms_previous) > playlistForeground[i].ms_animation_max_duration) {
if (!option4PauseCycling) {
playlistForeground[i].stop();
do {
playlistForeground[i].moveRandom(1, i);
} while (!playlistForeground[i].getCurrentItemEnabled());
playlistForeground[i].ms_animation_max_duration = animation_duration;
playlistForeground[i].start(i);
Serial.print("Changing foreground effect pattern to: ");
Serial.println(playlistForeground[i].getCurrentPatternName());
playlistForeground[i].ms_previous = millis();
playlistForeground[i].fps_timer = millis();
}
}
// -------- draw the next frame if fps timer dictates so --------
//
if ( 1000 / playlistForeground[i].pattern_fps + playlistForeground[i].last_frame < millis()) {
playlistForeground[i].last_frame = millis();
playlistForeground[i].pattern_fps = playlistForeground[i].drawFrame(i, CountPlaylistsForeground);
if (!playlistForeground[i].pattern_fps) {
playlistForeground[i].pattern_fps = playlistForeground[i].default_fps;
}
++playlistForeground[i].fps;
playlistForeground[i].render_ms = millis() - playlistForeground[i].last_frame;
}
// ----- every 1000ms update fps and timer
//
if (playlistForeground[i].fps_timer + 1000 < millis()) {
playlistForeground[i].fps_timer = millis();
playlistForeground[i].fps_last = playlistForeground[i].fps;
actual_fps = playlistForeground[i].fps;
playlistForeground[i].fps = 0;
}
}
}
effects.updateBpmOscillators();
actual_render_ms = millis() - start_render_ms;
effects.ShowFrame();
total_render_ms = millis() - start_render_ms;
UpdateDiagnosticsData(); // put this at the end so it paints over everything else.
// Serial.print("RAM: ");
// Serial.println(ESP.getFreeHeap());
}
void listPatterns() {
if (CountPlaylistsAudio > 0) {
playlistAudio[0].listPatterns();
}
}