forked from AaronLiddiment/LEDMatrix
-
Notifications
You must be signed in to change notification settings - Fork 24
/
MatrixExample1.ino
100 lines (86 loc) · 2.27 KB
/
MatrixExample1.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
#include <FastLED.h> //https://github.com/FastLED/FastLED
#include <LEDMatrix.h> //https://github.com/Jorgen-VikingGod/LEDMatrix
// Change the next defines to match your matrix type and size
#define DATA_PIN 14
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
// initial matrix layout (to get led strip index by x/y)
#define MATRIX_WIDTH 11
#define MATRIX_HEIGHT 11
#define MATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX
#define MATRIX_SIZE (MATRIX_WIDTH*MATRIX_HEIGHT)
#define NUMPIXELS MATRIX_SIZE
// create our matrix based on matrix definition
cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;
uint8_t hue;
int16_t counter;
void setup()
{
// initial LEDs
FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds[0], leds.Size()).setCorrection(TypicalSMD5050);
FastLED.setCorrection(TypicalLEDStrip);
FastLED.setBrightness(127);
FastLED.clear(true);
delay(500);
FastLED.showColor(CRGB::Red);
delay(1000);
FastLED.showColor(CRGB::Lime);
delay(1000);
FastLED.showColor(CRGB::Blue);
delay(1000);
FastLED.showColor(CRGB::White);
delay(1000);
FastLED.clear(true);
hue = 0;
counter = 0;
}
void loop()
{
int16_t sx, sy, x, y;
uint8_t h;
FastLED.clear();
h = hue;
if (counter < 1125)
{
// ** Fill LED's with diagonal stripes
for (x=0; x<(leds.Width()+leds.Height()); ++x)
{
leds.DrawLine(x - leds.Height(), leds.Height() - 1, x, 0, CHSV(h, 255, 255));
h+=16;
}
}
else
{
// ** Fill LED's with horizontal stripes
for (y=0; y<leds.Height(); ++y)
{
leds.DrawLine(0, y, leds.Width() - 1, y, CHSV(h, 255, 255));
h+=16;
}
}
hue+=4;
if (counter < 125)
;
else if (counter < 375)
leds.HorizontalMirror();
else if (counter < 625)
leds.VerticalMirror();
else if (counter < 875)
leds.QuadrantMirror();
else if (counter < 1125)
leds.QuadrantRotateMirror();
else if (counter < 1250)
;
else if (counter < 1500)
leds.TriangleTopMirror();
else if (counter < 1750)
leds.TriangleBottomMirror();
else if (counter < 2000)
leds.QuadrantTopTriangleMirror();
else if (counter < 2250)
leds.QuadrantBottomTriangleMirror();
counter++;
if (counter >= 2250)
counter = 0;
FastLED.show();
}