forked from lichtenberg/bismillah
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bismillah.ino
119 lines (94 loc) · 2.01 KB
/
Bismillah.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
///////////////////////////////////////////////////////////////////////////////////////////
//
// Bismillah art project, based on:
// ALA library example: RgbStripButton
//
// Example to demonstrate how to switch animations using three buttons.
// The first button change the animation.
// The second button the color palette.
// The third button change the animation speed.
//
// Button library is required: http://playground.arduino.cc/Code/Button
//
// Web page: http://yaab-arduino.blogspot.com/p/ala-example-rgbstripbutton.html
//
///////////////////////////////////////////////////////////////////////////////////////////
#include <AlaLedRgb.h>
#include <OneButton.h>
AlaLedRgb rgbStrip;
int animation = 1;
int duration = 2;
int palette = 0;
OneButton button(3, true);
int animList[] = {
ALA_OFF,
ALA_ON,
ALA_ON,
ALA_ON,
ALA_FADECOLORSLOOP,
ALA_MOVINGGRADIENT,
ALA_MOVINGBARS,
ALA_COMET,
ALA_COMETCOL,
ALA_GLOW,
ALA_CYCLECOLORS,
ALA_FADECOLORS,
ALA_FIRE,
0
};
AlaColor colorGreen[] = { 0x008000 };
AlaPalette alaPalGreen = {1, colorGreen};
AlaColor colorWhite[] = { 0xFFFFFF };
AlaPalette alaPalWhite = {1, colorWhite};
AlaColor colorGray[] = { 0x202020 };
AlaPalette alaPalGray = {1, colorGray};
AlaPalette paletteList[] = {
alaPalRgb,
alaPalGray,
alaPalWhite,
alaPalGreen,
alaPalRgb,
alaPalRgb,
alaPalRgb,
alaPalRgb,
alaPalRgb,
alaPalGreen,
alaPalRgb,
alaPalRgb,
alaPalRgb,
alaPalRgb,
alaPalRgb,
alaPalRgb,
};
//AlaPalette paletteList[3] = {
// alaPalRgb,
// alaPalRainbow,
// alaPalFire
//};
int durationList[3] = {
1000,
2000,
5000
};
void buttonClick()
{
animation++;
if (animList[animation] == 0) animation = 0;
updateAnimation();
}
void setup()
{
delay(500);
rgbStrip.initWS2812(24, 15);
updateAnimation();
button.attachClick(buttonClick);
}
void loop()
{
button.tick();
rgbStrip.runAnimation();
}
void updateAnimation()
{
rgbStrip.setAnimation(animList[animation], durationList[duration % 3], paletteList[animation]);
}