charlie-cube/planarFlop3D.ino
2022-04-06 21:35:35 -04:00

159 lines
4.4 KiB
C++

/******************************* PLANAR FLOP 3D *******************************\
| Version 2 of the planar flop, doing more complicated maths and 3D vectors |
| 'n stuff. Making this function found the bug of reversed z axis line drawing |
| |
| Modified By: S. Dugre to use asynchronous timer |
\******************************************************************************/
int planarCase;
void planarFlop3D() {
if (currentState != lastState) {
lastState = currentState;
Serial.print("New State = ");
Serial.println(currentState);
currentTimer = 0;
maxTimer = 3125; // 50 ms
planarCase = 0;
}
if (timerReset) {
switch (planarCase) {
case 0:
for (int y = 3; y > 0; y--) {
for (int z = 0; z < 4; z++) drawLine(color, 0, 3, z, 3, y, z);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 1:
for (int x = 3; x > 0; x--) {
for (int z = 0; z < 4; z++) drawLine(color, 0, 3, z, x, 0, z);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 2:
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 4; y++) drawLine(color, 0, y, 0, x, y, 3);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 3:
for (int z = 3; z > 0; z--) {
for (int y = 0; y < 4; y++) drawLine(color, 0, y, 0, 3, y, z);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 4:
for (int z = 0; z < 3; z++) {
for (int x = 0; x < 4; x++) drawLine(color, x, 0, 0, x, 3, z);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 5:
for (int y = 3; y > 0; y--) {
for (int x = 0; x < 4; x++) drawLine(color, x, 0, 0, x, y, 3);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 6:
for (int y = 0; y < 3; y++) {
for (int z = 0; z < 4; z++) drawLine(color, 3, 0, z, 0, y, z);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 7:
for (int x = 0; x < 3; x++) {
for (int z = 0; z < 4; z++) drawLine(color, 3, 0, z, x, 3, z);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 8:
for (int x = 3; x > 0; x--) {
for (int y = 0; y < 4; y++) drawLine(color, 3, y, 3, x, y, 0);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 9:
for (int z = 0; z < 3; z++) {
for (int y = 0; y < 4; y++) drawLine(color, 3, y, 3, 0, y, z);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 10:
for (int z = 3; z > 0; z--) {
for (int x = 0; x < 4; x++) drawLine(color, x, 3, 3, x, 0, z);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase++;
currentTimer = 0;
timerReset = false;
}
case 11:
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 4; x++) drawLine(color, x, 3, 3, x, y, 0);
flushBuffer();
clearBuffer();
//delay(animationSpeed);
planarCase = 0;
currentTimer = 0;
timerReset = false;
}
color = nextColor(color);
}
}
}