-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequences.cpp
More file actions
109 lines (90 loc) · 2.92 KB
/
sequences.cpp
File metadata and controls
109 lines (90 loc) · 2.92 KB
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
#include "sequences.h"
#include "Sequence.h"
#include "Step.h"
#include "Action.h"
#include "DEBUG.h"
namespace LEDAnimation {
Sequence* const Sequences::allOn = [] {
Step* step = new Step(sec_ms(10));
for (uint8_t i = 1; i <= MAX_LEDS; i++) {
*step << Action(i, LEDstate::on);
}
return new Sequence(step);
}();
Sequence* const Sequences::gate = [] {
const unsigned int midOnTime = sec_ms(1), addLen = sec_ms(2);
Sequence* sequence = new Sequence(&(*new Step(midOnTime) << Action(4, LEDstate::on)));
for (uint8_t i = 5; i <= 7; i++) {
Step* step = new Step(addLen);
*step << Action(4, LEDstate::off) << Action(i, LEDstate::on);
Step* midOn = new Step(midOnTime);
*midOn << Action(4, LEDstate::on);
*sequence << step << midOn;
}
for (uint8_t i = 1; i <= 3; i++) {
Step* step = new Step(addLen);
*step << Action(4, LEDstate::off) << Action(i, LEDstate::on);
Step* midOn = new Step(midOnTime);
*midOn << Action(4, LEDstate::on);
*sequence << step << midOn;
}
Step* gateWait = new Step(sec_ms(5) - midOnTime);
*gateWait << Action(4, LEDstate::on);
*sequence << gateWait;
Step* gateLast = new Step(sec_ms(2));
for (uint8_t i = 1; i <= 7; i++) {
*gateLast << Action(i, LEDstate::off);
}
*sequence << gateLast;
return sequence;
}();
Sequence* const Sequences::bounce = [] {
const unsigned int bounceTimer = 1000;
Sequence* sequence = new Sequence(&(*new Step(bounceTimer) << Action(1, LEDstate::on)));
for (uint8_t i = 2; i <= MAX_LEDS; i++) {
Step* step = new Step(bounceTimer);
*step << Action(i, LEDstate::on) << Action(i - 1, LEDstate::off);
*sequence << step;
}
for (uint8_t i = MAX_LEDS; i > 1; i--) {
Step* step = new Step(bounceTimer);
*step << Action(i - 1, LEDstate::on) << Action(i, LEDstate::off);
*sequence << step;
}
return sequence;
}();
Sequence* const Sequences::ripple = [] {
const unsigned int rippleTime = 100;
Sequence* sequence = new Sequence(&(*new Step(rippleTime) << Action(4, LEDstate::off)));
for (uint8_t i = 1; i <= 3; i++) {
Step* step;
step = new Step(rippleTime);
*step << Action(4 + i, LEDstate::on);
*step << Action(4 - i, LEDstate::on);
*step << Action(4 + i - 1, LEDstate::off);
*step << Action(4 - i + 1, LEDstate::off);
*sequence << step;
}
for (int8_t i = 2; i >= 0; i--) {
Step* step;
step = new Step(rippleTime);
*step << Action(4 + i, LEDstate::on);
*step << Action(4 - i, LEDstate::on);
*step << Action(4 + i + 1, LEDstate::off);
*step << Action(4 - i - 1, LEDstate::off);
*sequence << step;
}
return sequence;
}();
Sequence* const Sequences::trail = [] {
const unsigned int timer = sec_ms(2);
Sequence* sequence = new Sequence(&(*new Step(timer) << Action(1, LEDstate::on)));
for (uint8_t i = 1; i <= MAX_LEDS; i++) {
Step* step;
step = new Step(timer);
*step << Action(i, LEDstate::on);
*sequence << step;
}
return sequence;
}();
}