-
Notifications
You must be signed in to change notification settings - Fork 0
/
animations.cpp
75 lines (72 loc) · 2.05 KB
/
animations.cpp
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
#include <Arduino.h>
#include <LEDCube.h>
#include <animations.h>
namespace LEDCubeAnimations {
void animationFrameBlank(LEDCubeBase& cube, uint8_t iterations) {
cube.fillCube(LOW);
cube.updateFor(FRAME_TIME * iterations);
}
void animationFillCube(LEDCubeBase& cube, uint8_t iterations) {
for (uint8_t i = 0; i < iterations; i++) {
cube.fillCube(HIGH);
cube.updateFor(FRAME_TIME);
cube.fillCube(LOW);
cube.updateFor(FRAME_TIME);
}
}
void animationPlaneShift(LEDCubeBase& cube, uint8_t iterations,
uint8_t direction) {
for (uint8_t i = 0; i < iterations; i++) {
switch (direction) {
case (UP): {
for (uint8_t y = 0; y < cube.getHeight(); y++) {
cube.fillCube(LOW);
cube.fillXZPlane(y, HIGH);
cube.updateFor(FRAME_TIME);
}
break;
}
case (DOWN): {
for (int8_t y = cube.getHeight() - 1; y >= 0; y--) {
cube.fillCube(LOW);
cube.fillXZPlane(y, HIGH);
cube.updateFor(FRAME_TIME);
}
break;
}
case (RIGHT): {
for (uint8_t x = 0; x < cube.getWidth(); x++) {
cube.fillCube(LOW);
cube.fillYZPlane(x, HIGH);
cube.updateFor(FRAME_TIME);
}
break;
}
case (LEFT): {
for (int8_t x = cube.getWidth() - 1; x >= 0; x--) {
cube.fillCube(LOW);
cube.fillYZPlane(x, HIGH);
cube.updateFor(FRAME_TIME);
}
break;
}
case (BACKWARD): {
for (uint8_t z = 0; z < cube.getDepth(); z++) {
cube.fillCube(LOW);
cube.fillXYPlane(z, HIGH);
cube.updateFor(FRAME_TIME);
}
break;
}
case (FORWARD): {
for (int8_t z = cube.getDepth() - 1; z >= 0; z--) {
cube.fillCube(LOW);
cube.fillXYPlane(z, HIGH);
cube.updateFor(FRAME_TIME);
}
break;
}
}
}
}
}