-
Notifications
You must be signed in to change notification settings - Fork 9
/
FunkyNoise_SmartMatrix_Edition.ino
162 lines (103 loc) · 2.85 KB
/
FunkyNoise_SmartMatrix_Edition.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
/*
FunkyNoise 1.0
----------------
A Collection Of
Animations
And Helper Functions
for two dimensional led effects
on the 32x32 SmartMatrix.
Tested on PJRCs Teensy 3.1 @ 96Mhz.
With explicit thanks to Daniel Garcia,
Mark Kriegsmann and Louis Beaudoin.
Written by Stefan Petrick 2014.
hello(at) stefan-petrick . de
...
Download the required software first:
FastLED 3.0
SmartMatrix
Arduino IDE 1.0.6
Teensyduino 1.2
*/
#include<SmartMatrix.h>
#include<FastLED.h>
// the size of your matrix
#define kMatrixWidth 32
#define kMatrixHeight 32
// used in FillNoise for central zooming
byte CentreX = (kMatrixWidth / 2) - 1;
byte CentreY = (kMatrixHeight / 2) - 1;
// set up the framebuffer
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
CRGB leds[kMatrixWidth * kMatrixHeight];
// a place to store the color palette
CRGBPalette16 currentPalette;
// can be used for palette rotation
// "colorshift"
byte colorshift;
// The coordinates for 3 16-bit noise spaces.
#define NUM_LAYERS 3
uint32_t x[NUM_LAYERS];
uint32_t y[NUM_LAYERS];
uint32_t z[NUM_LAYERS];
uint32_t scale_x[NUM_LAYERS];
uint32_t scale_y[NUM_LAYERS];
// used for the random based animations
int16_t dx;
int16_t dy;
int16_t dz;
int16_t dsx;
int16_t dsy;
// a 3dimensional array used to store the calculated
// values of the different noise planes
uint8_t noise[NUM_LAYERS][kMatrixWidth][kMatrixHeight];
// used for the color histogramm
uint16_t values[256];
uint8_t noisesmoothing;
// everything for the button + menu handling
int button1;
int button2;
int button3;
byte mode;
byte pgm;
byte spd;
byte brightness;
byte red_level;
byte green_level;
byte blue_level;
void setup() {
// enable debugging info output
Serial.begin(115200);
// add the SmartMatrix controller
LEDS.addLeds<SMART_MATRIX>(leds,NUM_LEDS);
// switch dithering off to avoid flicking at low fps
FastLED.setDither(0);
// adjust the gamma curves to human perception
pSmartMatrix->setColorCorrection(cc48);
// fill all animation variables with valid values to
// allow straight forward animation programming
BasicVariablesSetup();
// the pins for the 3 buttons of my custom interface
pinMode(17, INPUT);
pinMode(18, INPUT);
pinMode(19, INPUT);
SetupMatrixText();
}
// basically beatsin16 with an additional phase
uint16_t beatsin(accum88 beats_per_minute, uint16_t lowest = 0, uint16_t highest = 65535, byte phase = 0)
{
uint16_t beat = beat16( beats_per_minute);
uint16_t beatsin = (sin16( beat+(phase*256)) + 32768);
uint16_t rangewidth = highest - lowest;
uint16_t scaledbeat = scale16( beatsin, rangewidth);
uint16_t result = lowest + scaledbeat;
return result;
}
void loop() {
/*
Whats new?
Caleidoscope1-5 functions in experimental.ino
Calceidoscope examples Caleido1-7 in Animations.ino
*/
Caleido3();
ShowFrame();
}