-
Notifications
You must be signed in to change notification settings - Fork 0
/
pendant.ino
207 lines (174 loc) · 9.32 KB
/
pendant.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
#include <TinyWireM.h>
#include "Animator.h"
// display object using default address
LEDMatrix matrix = LEDMatrix();
//
//--------------alien 1 ------------------------------------
//
const uint8_t alien1Data[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B00011000, B00011000 },
{ B00111100, B00111100 },
{ B01111110, B01111110 },
{ B11011011, B11011011 },
{ B11111111, B11111111 },
{ B00100100, B00100100 },
{ B01011010, B01011010 },
{ B10100101, B01000010 } };
const uint8_t alien1Timing[] PROGMEM =
{ LFRM_DLAY, LFRM_DLAY, END_FRAMES};
//
//--------------alien 2 ------------------------------------
//
const uint8_t alien2Data[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B00000000, B00111100 },
{ B00111100, B01111110 },
{ B01111110, B11011011 },
{ B11011011, B11011011 },
{ B11011011, B01111110 },
{ B01111110, B00100100 },
{ B00100100, B00100100 },
{ B11000011, B00100100 } };
const uint8_t alien2Timing[] PROGMEM =
{ LFRM_DLAY, LFRM_DLAY, END_FRAMES};
//
//--------------alien 3 ------------------------------------
//
const uint8_t alien3Data[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B00100100, B00100100 },
{ B00100100, B10100101 },
{ B01111110, B11111111 },
{ B11011011, B11011011 },
{ B11111111, B11111111 },
{ B11111111, B01111110 },
{ B10100101, B00100100 },
{ B00100100, B01000010 } };
const uint8_t alien3Timing[] PROGMEM =
{ LFRM_DLAY, LFRM_DLAY, END_FRAMES };
//
//--------------alien 4 ------------------------------------
//
const uint8_t alien4Data[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B00111100, B00111100, B00111100, B00111100 },
{ B01111110, B01111110, B01111110, B01111110 },
{ B00110011, B10011001, B11001100, B01100110 },
{ B01111110, B01111110, B01111110, B01111110 },
{ B00111100, B00111100, B00111100, B00111100 },
{ B00000000, B00000000, B00000000, B00000000 },
{ B00001000, B00001000, B00000000, B00000000 },
{ B00000000, B00001000, B00001000, B00000000 } };
const uint8_t alien4Timing[] PROGMEM =
{ MFRM_DLAY, MFRM_DLAY, MFRM_DLAY, MFRM_DLAY, END_FRAMES };
//
//--------------pacman ------------------------------------
//
const uint8_t pacmanData[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B00111100, B00111100, B00111100, B00111100, B00111100, B00111100 },
{ B01111110, B01111110, B01111110, B01111110, B01111110, B01111110 },
{ B11011110, B11011111, B11011111, B11011111, B11011111, B11011111 },
{ B11111000, B11111100, B11111111, B11111111, B11111111, B11111100 },
{ B11100000, B11100000, B11110000, B11111111, B11110000, B11100000 },
{ B11111000, B11111100, B11111111, B11111111, B11111111, B11111100 },
{ B01111110, B01111110, B01111110, B01111110, B01111110, B01111110 },
{ B00111100, B00111100, B00111100, B00111100, B00111100, B00111100 } };
const uint8_t pacmanTiming[] PROGMEM =
{ MFRM_DLAY, MFRM_DLAY, MFRM_DLAY, MFRM_DLAY, MFRM_DLAY, MFRM_DLAY, END_FRAMES };
//
//--------------ghost ------------------------------------
//
const uint8_t ghostData[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B00011000, B00011000},
{ B01100110, B01100110},
{ B10000001, B10000001},
{ B10100101, B10010011},
{ B10000001, B10000001},
{ B10000001, B10000001},
{ B10101011, B10101011},
{ B01010101, B10101010} };
const uint8_t ghostTiming[] PROGMEM =
{ LFRM_DLAY, LFRM_DLAY, END_FRAMES };
//
//--------------smiley ------------------------------------
//
const uint8_t smileyData[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B01000010, B01000010, B01000010, B01000010, B01000010, B01000010, B01000010, B01000010, B01000010, B01000010},
{ B10100101, B10100101, B10100101, B10100101, B10100101, B10100101, B10100101, B10100101, B11100111, B10100101},
{ B01000010, B01000010, B01000010, B01000010, B01000010, B01000010, B01000010, B01000010, B01000010, B01000010},
{ B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000, B00011000},
{ B00000000, B00000000, B10000001, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000},
{ B00000000, B11000011, B01000010, B11000011, B01011010, B00011000, B00000000, B00000000, B00000000, B00000000},
{ B11111111, B00111100, B00111100, B00111100, B00111100, B00100100, B01100110, B11111111, B11111111, B11111111},
{ B00000000, B00000000, B00000000, B00000000, B00000000, B00011000, B00011000, B00000000, B00000000, B00000000} };
const uint8_t smileyTiming[] PROGMEM =
{ LFRM_DLAY, LFRM_DLAY, LFRM_DLAY, LFRM_DLAY, LFRM_DLAY, LFRM_DLAY, LFRM_DLAY, LFRM_DLAY, LFRM_DLAY, LFRM_DLAY, END_FRAMES };
//
//--------------fireworks ------------------------------------
//
const uint8_t fireworksData[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00010000, B00000000},
{ B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00010000, B10101010, B00000000},
{ B00000000, B00000000, B00000000, B00000000, B00000000, B00100000, B00000000, B00010000, B00101000, B01000100, B00000000},
{ B00000000, B00000000, B00000000, B00000000, B00100000, B00000000, B00010000, B00101000, B01010100, B10000010, B00000000},
{ B00000000, B00000000, B00000000, B00100000, B00000000, B00000000, B00000000, B00010000, B00101000, B01000100, B00000000},
{ B00000000, B00000000, B01000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00010000, B10101010, B00000000},
{ B00000000, B01000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00010000, B00000000},
{ B10000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00010000, B00000000} };
const uint8_t fireworksTiming[] PROGMEM =
{ SFRM_DLAY, MFRM_DLAY, LFRM_DLAY, LFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, MFRM_DLAY, MFRM_DLAY, MFRM_DLAY, MFRM_DLAY, END_FRAMES };
//
//--------------asteroids ------------------------------------
//
const uint8_t asteroidsData[ROWS_PER_FRAME][MAX_FRAMES] PROGMEM = {
{ B00000000, B00000010, B00011100, B00111000, B00100000, B00010000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000 },
{ B00000000, B00000000, B00001000, B00010000, B01011000, B10001000, B10001000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000 },
{ B00000000, B00000000, B00000000, B00000000, B11110000, B10001000, B00000000, B00000000, B00000000, B00100000, B01100000, B00110000, B00011000, B00001100, B00000110, B00000011 },
{ B00000000, B00000000, B00000000, B00100000, B00000000, B00000000, B00000000, B00000000, B00100000, B01010000, B01010000, B00101000, B00010100, B00001010, B00000101, B00000010 },
{ B00000000, B00000000, B00100000, B00000000, B00000000, B00000000, B00000000, B00100000, B01010000, B01110000, B01100000, B00110000, B00011000, B00001100, B00000110, B00000011 },
{ B00100000, B00100000, B00100000, B00100000, B00100000, B00100000, B00100000, B01010000, B01110000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000 },
{ B01010000, B01010000, B01010000, B01010000, B01010000, B01010000, B01010000, B01110000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000 },
{ B01110000, B01110000, B01110000, B01110000, B01110000, B01110000, B01110000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000 } };
const uint8_t asteroidsTiming[] PROGMEM =
{ VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, VFRM_DLAY, END_FRAMES };
//
// initial setup
//
void setup() {
matrix.lowPowerMode();
matrix.initializeDisplay(12, LEDMatrix::BLINK_NONE);
}
//
// main loop
//
void loop() {
for ( int numReps = 0; numReps < 30; numReps++) {
matrix.setBrightness(10);
// pacman runs right
drawAnimation(matrix, pacmanTiming, pacmanData, Translation(1, 0, false, 3), 8);
// pacman backs left faster
drawAnimation(matrix, pacmanTiming, pacmanData, Translation(-2, 0, true, 3), 4);
// ghost chases left
drawAnimation(matrix, ghostTiming, ghostData, Translation(-1, 0, false, 2), 16);
// animate asteroids
drawAnimation(matrix, asteroidsTiming, asteroidsData, Translation(0, 0, false, 0), 1);
// bright fireworks
matrix.setBrightness(12);
drawAnimation(matrix, fireworksTiming, fireworksData, Translation(0, 0, false, 0), 1);
drawAnimation(matrix, fireworksTiming, fireworksData, Translation(0, 0, true, 0), 1);
drawAnimation(matrix, fireworksTiming, fireworksData, Translation(0, 0, false, 0), 1);
// smiley
matrix.setBrightness(8);
drawAnimation(matrix, smileyTiming, smileyData, Translation(0, 0, false, 0), 4);
// drop alien 1 from the top
drawAnimation(matrix, alien1Timing, alien1Data, Translation(0, 1, false, 2), 16);
// alien 2 rises from the bottom
drawAnimation(matrix, alien2Timing, alien2Data, Translation(0, -1, false, 2), 16);
// alien 3 upper left to center
drawAnimation(matrix, alien3Timing, alien3Data, Translation(1, 1, false, 2), 8);
// alien 3 stay and dance a bit
drawAnimation(matrix, alien3Timing, alien3Data, Translation(0, 0, false, 0), 4);
// alien 4 fade in/out
fadeInOut(matrix, alien4Timing, alien4Data, 1, 2, 3000);
delay(10000);
}
// go to permanent sleep mode and dont return until button pushed
matrix.goToSleep();
}