-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathCreepers.cpp
More file actions
27 lines (22 loc) · 773 Bytes
/
Creepers.cpp
File metadata and controls
27 lines (22 loc) · 773 Bytes
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
/*
G35: An Arduino library for GE Color Effects G-35 holiday lights.
Copyright © 2011 The G35 Authors. Use, modification, and distribution are
subject to the BSD license as described in the accompanying LICENSE file.
By Mike Tsao <http://github.com/sowbug>.
See README for complete attributions.
*/
#include <Creepers.h>
Creepers::Creepers(G35& g35) : LightProgram(g35), count_(0), next_worm_(0) {
g35_.fill_color(0, light_count_, 255, COLOR_BLACK);
}
uint32_t Creepers::Do() {
for (int i = 0; i < count_; ++i) {
worms_[i].Do(g35_);
}
if (count_ < 6 && millis() > next_worm_) {
++count_;
worms_[count_ - 1].set_color(rand() & 1 ? COLOR_GREEN : COLOR_ORANGE);
next_worm_ = millis() + 2000 + 1000 * count_;
}
return bulb_frame_;
}