diff --git a/charlieCube.ino b/charlieCube.ino index 7d9ce3c..a303edc 100644 --- a/charlieCube.ino +++ b/charlieCube.ino @@ -46,14 +46,14 @@ void loop() { case TRIFADE: trifade(); - break; - - case RAINBOWCORNER: - rainbow_corner(); break; case PLANARFLOP3D: planarFlop3D(); break; + + case RAINBOWCORNER: + rainbow_corner(); + break; } } diff --git a/config.h b/config.h index e1da3c9..b0938cc 100644 --- a/config.h +++ b/config.h @@ -9,8 +9,8 @@ typedef enum STATE { FOUNTAIN, PLANARSPIN, TRIFADE, - RAINBOWCORNER, - PLANARFLOP3D + PLANARFLOP3D, + RAINBOWCORNER }; STATE currentState, lastState; diff --git a/cubeplex.h b/cubeplex.h index d14d83b..e88b8d5 100644 --- a/cubeplex.h +++ b/cubeplex.h @@ -582,7 +582,7 @@ int currentTimer = 0; int maxTimer = 6250; // 100ms delay / 16uS interrupt time int nextState(int state) { - return (state + 1) % 7; + return (state + 1) % 8; } // the interrupt function to display the leds (T2 = 8 bit timer) diff --git a/planarFlop3D.ino b/planarFlop3D.ino index 000ee0e..eaa21d4 100644 --- a/planarFlop3D.ino +++ b/planarFlop3D.ino @@ -5,7 +5,7 @@ | Modified By: S. Dugre to use asynchronous timer | \******************************************************************************/ -int planarCase; +int loop1, loop2, case_pf; void planarFlop3D() { @@ -16,144 +16,91 @@ void planarFlop3D() { Serial.println(currentState); currentTimer = 0; - maxTimer = 3125; // 50 ms + maxTimer = 0.1 * 1000 * 1000 / 16; // 100 ms - planarCase = 0; + loop1 = loop2 = case_pf = 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; - } + switch (case_pf) { + case 0: + drawLine(color, 0, 3, loop2, 3, 3-loop1, loop2); + break; 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; - } + drawLine(color, 0, 3, loop2, 3-loop1, 0, loop2); + break; 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; - } - + drawLine(color, 0, loop2, 0, loop1, loop2, 3); + break; + 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; - } + drawLine(color, 0, loop2, 0, 3, loop2, 3-loop1); + break; 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; - } + drawLine(color, loop2, 0, 0, loop2, 3, loop1); + break; 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; - } + drawLine(color, loop2, 0, 0, loop2, 3-loop1, 3); + break; 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; - } + drawLine(color, 3, 0, loop2, 0, loop1, loop2); + break; 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; - } + drawLine(color, 3, 0, loop2, loop1, 3, loop2); + break; 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; - } + drawLine(color, 3, loop2, 3, 3-loop1, loop2, 0); + break; + 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; - } + drawLine(color, 3, loop2, 3, 0, loop2, loop1); + break; 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; - } + drawLine(color, loop2, 3, 3, loop2, 0, 3-loop1); + break; 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; + drawLine(color, loop2, 3, 3, loop2, loop1, 0); + break; + } + + switch(loop2){ + case 0 ... 2: + loop2++; + break; + case 3: + loop2 = 0; + + switch(loop1){ + case 0 ... 1: + loop1++; + break; + case 2: + loop1 = 0; + + switch(case_pf){ + case 0 ... 10: + case_pf++; + break; + case 11: + color = nextColor(color); + case_pf = 0; + break; + } + break; } - color = nextColor(color); + flushBuffer(); + clearBuffer(); + timerReset = false; + break; } } }