2019-05-11 16:20:53 +02:00
|
|
|
/* ------------------------- CUSTOM GPIO PIN MAPPING ------------------------- */
|
|
|
|
#define R1_PIN 18
|
|
|
|
#define G1_PIN 25
|
|
|
|
#define B1_PIN 5
|
|
|
|
#define R2_PIN 17
|
|
|
|
#define G2_PIN 26
|
|
|
|
#define B2_PIN 16
|
|
|
|
#define A_PIN 14
|
|
|
|
#define B_PIN 27
|
|
|
|
#define C_PIN 12
|
|
|
|
#define D_PIN 4
|
|
|
|
#define E_PIN -1
|
|
|
|
#define LAT_PIN 13
|
|
|
|
#define OE_PIN 15
|
|
|
|
#define CLK_PIN 2
|
|
|
|
|
|
|
|
/* -------------------------- Display Config Initialisation -------------------- */
|
|
|
|
|
|
|
|
#define MATRIX_WIDTH 64
|
|
|
|
#define MATRIX_HEIGHT 32
|
|
|
|
|
|
|
|
/* -------------------------- Class Initialisation -------------------------- */
|
2020-11-28 09:39:35 +01:00
|
|
|
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
|
2020-11-28 10:45:30 +01:00
|
|
|
MatrixPanel_I2S_DMA matrix;
|
2019-05-11 16:20:53 +02:00
|
|
|
|
|
|
|
#include <FastLED.h>
|
|
|
|
|
|
|
|
#include "Effects.h"
|
|
|
|
Effects effects;
|
|
|
|
|
|
|
|
#include "Drawable.h"
|
|
|
|
#include "Playlist.h"
|
|
|
|
//#include "Geometry.h"
|
|
|
|
|
|
|
|
#include "Patterns.h"
|
|
|
|
Patterns patterns;
|
|
|
|
|
|
|
|
/* -------------------------- Some variables -------------------------- */
|
2020-12-01 17:28:17 +01:00
|
|
|
unsigned long fps = 0, fps_timer; // fps (this is NOT a matix refresh rate!)
|
|
|
|
unsigned int default_fps = 30, pattern_fps = 30; // default fps limit (this is not a matix refresh conuter!)
|
|
|
|
unsigned long ms_animation_max_duration = 20000; // 20 seconds
|
|
|
|
unsigned long last_frame=0, ms_previous=0;
|
2019-05-11 16:20:53 +02:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
// Setup serial interface
|
|
|
|
Serial.begin(115200);
|
|
|
|
delay(250);
|
|
|
|
matrix.begin(R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN ); // setup the LED matrix
|
|
|
|
|
|
|
|
Serial.println("**************** Starting Aurora Effects Demo ****************");
|
|
|
|
|
|
|
|
// setup the effects generator
|
|
|
|
effects.Setup();
|
|
|
|
|
|
|
|
delay(500);
|
|
|
|
Serial.println("Effects being loaded: ");
|
|
|
|
listPatterns();
|
|
|
|
|
|
|
|
|
2020-12-01 17:28:17 +01:00
|
|
|
//patterns.setPattern(0); // // simple noise
|
|
|
|
patterns.moveRandom(1); // start from a random pattern
|
2019-05-11 16:20:53 +02:00
|
|
|
|
|
|
|
Serial.print("Starting with pattern: ");
|
|
|
|
Serial.println(patterns.getCurrentPatternName());
|
2020-12-01 17:28:17 +01:00
|
|
|
patterns.start();
|
|
|
|
ms_previous = millis();
|
|
|
|
fps_timer = millis();
|
2019-05-11 16:20:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
// menu.run(mainMenuItems, mainMenuItemCount);
|
|
|
|
|
2020-12-01 17:28:17 +01:00
|
|
|
if ( (millis() - ms_previous) > ms_animation_max_duration )
|
|
|
|
{
|
2019-05-11 16:20:53 +02:00
|
|
|
patterns.stop();
|
2020-12-01 17:28:17 +01:00
|
|
|
patterns.moveRandom(1);
|
|
|
|
//patterns.move(1);
|
2019-05-11 16:20:53 +02:00
|
|
|
patterns.start();
|
|
|
|
|
|
|
|
|
|
|
|
Serial.print("Changing pattern to: ");
|
|
|
|
Serial.println(patterns.getCurrentPatternName());
|
|
|
|
|
2020-12-01 17:28:17 +01:00
|
|
|
ms_previous = millis();
|
2019-05-11 16:20:53 +02:00
|
|
|
|
|
|
|
// Select a random palette as well
|
|
|
|
//effects.RandomPalette();
|
|
|
|
}
|
|
|
|
|
2020-12-01 17:28:17 +01:00
|
|
|
if ( 1000 / pattern_fps + last_frame < millis()){
|
|
|
|
last_frame = millis();
|
|
|
|
pattern_fps = patterns.drawFrame();
|
|
|
|
if (!pattern_fps)
|
|
|
|
pattern_fps = default_fps;
|
|
|
|
|
|
|
|
++fps;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fps_timer + 1000 < millis()){
|
2020-12-02 20:39:03 +01:00
|
|
|
Serial.printf_P(PSTR("Effect fps: %ld\n"), fps);
|
2020-12-01 17:28:17 +01:00
|
|
|
fps_timer = millis();
|
|
|
|
fps = 0;
|
|
|
|
}
|
2019-05-11 16:20:53 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void listPatterns() {
|
|
|
|
patterns.listPatterns();
|
|
|
|
}
|