-
Notifications
You must be signed in to change notification settings - Fork 85
/
ls_playbook.ino
210 lines (187 loc) · 6.17 KB
/
ls_playbook.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
208
209
210
/*************************** ls_playbook: Displays a playbook of images ***************************
Copyright 2023 Roger Linn Design (https://www.rogerlinndesign.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***************************************************************************************************
This cycles through a series of images to creation an animated playbook.
**************************************************************************************************/
const int CHRISTMAS_FRAME_COUNT = 7;
const char* CHRISTMAS_FRAMES_200[CHRISTMAS_FRAME_COUNT] = {
" W W W W W "
" W W G W W W W"
" GGRW W G "
" W RGG WG RGG W "
" W WGGGGGW W RGG GGR "
" RGGRG W GGRGGRGG W"
" W GGRGGGGW GRGGGGGGRG "
" WWWWWWYWWWWWWWWWYWWWYWWWW",
" W W W W "
" W WG W W W "
" W W GGR W W WG W"
" RGGW W G RGG "
" W GGGGG RGG GGR W "
" W WRGGRGW W GGRGGRGG "
" GGRGGGG WGRGGGGGGRGW"
" WWWWWWYWWWWWWWWWYWWWYWWWW",
" W W W"
" W G W W "
" W GGR W W GW "
" W W RGG W W G RGG W"
" GGGGG W RGG GGR "
" W RGGRG GGRGGRGGW "
" W GGRGGGG W GRGGGGGGRG "
" WWWWWWYWWWWWWWWWYWWWYWWWW",
" W W W W W W W "
" G W W W"
" W GGR W W G "
" W RGG W G WRGG "
" W WGGGGG W WRGG GGR W"
" RGGRG W GGRGGRGG "
" WGGRGGGG GRGGGGGGRG "
" WWWWWWYWWWWWWWWWYWWWYWWWW",
" W W W "
" W W WG W W W W "
" GGR W WG W"
" W RGG W G RGG "
" W GGGGG W RGGWGGR "
" W WRGGRG W WGGRGGRGG W"
" GGRGGGG WGRGGGGGGRG "
" WWWWWWYWWWWWWWWWYWWWYWWWW",
" W W "
" W G W W "
" W W GGR W W W GW "
" RGG W G RGG W"
" W GGGGG W RGG GGR "
" W RGGRG W GGRGGRGG "
" W GGRGGGG W GRGGGGGGRGW"
" WWWWWWYWWWWWWWWWYWWWYWWWW",
" W W W W W W"
" G W W "
" W GGR W G W "
" W W RGG W W GW RGG "
" GGGGG W RGG GGR W"
" W RGGRG W GGRGGRGG "
" W GGRGGGG WGRGGGGGGRG "
" WWWWWWYWWWWWWWWWYWWWYWWWW"
};
const char* CHRISTMAS_FRAMES_128[CHRISTMAS_FRAME_COUNT] = {
" W W W "
" W W W G W W "
" GGRW W "
" W RGG "
" W WGGGGGW W "
" W RGGRG W "
" W GGRGGGGW "
" WWWWWWWYWWWWWWWW ",
" W W W "
" W WG W "
" W W W GGR W W "
" RGGW W "
" W GGGGG "
" W WRGGRGW W "
" W GGRGGGG W "
" WWWWWWWYWWWWWWWW ",
" W W "
" W G W "
" W GGR W "
" W W W RGG W W "
" GGGGG W "
" W RGGRG "
" W GGRGGGG W "
" WWWWWWWYWWWWWWWW ",
" W W W W W "
" W G W "
" W GGR W "
" W RGG W "
" W W WGGGGG W W "
" RGGRG W "
" WGGRGGGG "
" WWWWWWWYWWWWWWWW ",
" W "
" W W WG W W "
" W GGR W "
" W RGG W "
" W GGGGG W "
" W W WRGGRG W W "
" GGRGGGG W "
" WWWWWWWYWWWWWWWW ",
" W W "
" W G "
" W W GGR W W "
" W RGG W "
" W GGGGG W "
" W RGGRG W "
" W W GGRGGGG W W "
" WWWWWWWYWWWWWWWW ",
" W W W W W "
" G W W "
" W GGR "
" W W RGG W W "
" W GGGGG W "
" W RGGRG W "
" W GGRGGGG W "
" WWWWWWWYWWWWWWWW "
};
void playChristmasAnimation() {
if (LINNMODEL == 200) {
playPlayBook(CHRISTMAS_FRAME_COUNT, CHRISTMAS_FRAMES_200);
}
else if (LINNMODEL == 128) {
playPlayBook(CHRISTMAS_FRAME_COUNT, CHRISTMAS_FRAMES_128);
}
}
void playPlayBook(int totalFrames, const char** playbook) {
Device.sleepAnimationActive = true;
storeSettings();
setDisplayMode(displayAnimation);
clearFullDisplay();
int frameIndex = 0;
while (!stopAnimation) {
animationActive = true;
const char* frameData = playbook[frameIndex];
startBufferedLeds();
for (int r = MAXROWS-1; r >= 0; --r) {
for (int c = 0; c < MAXCOLS; ++c) {
setLed(c, r, colorCharToNumber(*frameData), cellOn);
frameData++;
}
performContinuousTasks();
}
finishBufferedLeds();
delayUsecWithScanning(400000);
animationActive = false;
if (++frameIndex >= totalFrames) {
frameIndex = 0;
}
}
stopAnimation = false;
animationActive = false;
clearFullDisplay();
Device.sleepAnimationActive = false;
storeSettings();
lastTouchMoment = millis();
setDisplayMode(displayNormal);
updateDisplay();
}
byte colorCharToNumber(char color) {
switch (color) {
case 'B': return 5;
case 'C': return 4;
case 'G': return 3;
case 'L': return 10;
case 'M': return 6;
case 'O': return 9;
case 'P': return 11;
case 'R': return 1;
case 'W': return 8;
case 'Y': return 2;
}
return 0;
}