added planar spin animation
This commit is contained in:
parent
4e72a85d49
commit
c9479eaee8
4 changed files with 78 additions and 2 deletions
71
planar_spin.ino
Normal file
71
planar_spin.ino
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/********************************* PLANAR SPIN ********************************\
|
||||
| A plane of light spins around the virtical center of the cube and changes |
|
||||
| colors after a certian number of rotations |
|
||||
| |
|
||||
| Written By: Asher Glick |
|
||||
| Modified By: S. Dugre to use asynchronous timer |
|
||||
\******************************************************************************/
|
||||
|
||||
//int animationSpeed = 50;
|
||||
int spinsPerColor = 5; // a spin is actually half a revolution
|
||||
int spin;
|
||||
int loop_ps;
|
||||
|
||||
void planar_spin() {
|
||||
|
||||
if (currentState != lastState) {
|
||||
|
||||
lastState = currentState;
|
||||
Serial.print("New State = ");
|
||||
Serial.println(currentState);
|
||||
|
||||
currentTimer = 0;
|
||||
maxTimer = 0.1 * 1000 * 1000 / 16; // 100 ms
|
||||
loop_ps = 0;
|
||||
spin = 0;
|
||||
}
|
||||
|
||||
if ( timerReset) {
|
||||
//int x = 0;
|
||||
//int y = 0;
|
||||
//for (int i = 0; i < spinsPerColor; i++) {
|
||||
if(spin < spinsPerColor){
|
||||
//for (int x = 0; x < 3; x++) {
|
||||
switch(loop_ps){
|
||||
|
||||
case 0 ... 2:
|
||||
drawLine(color,loop_ps,0,0,3-loop_ps,3,0);
|
||||
drawLine(color,loop_ps,0,1,3-loop_ps,3,1);
|
||||
drawLine(color,loop_ps,0,2,3-loop_ps,3,2);
|
||||
drawLine(color,loop_ps,0,3,3-loop_ps,3,3);
|
||||
flushBuffer();
|
||||
clearBuffer();
|
||||
loop_ps++;
|
||||
timerReset = false;
|
||||
break;
|
||||
|
||||
//for (int y = 0; y < 3; y++) {
|
||||
case 3 ... 5:
|
||||
drawLine(color,3,(loop_ps % 3),0,0,3-(loop_ps % 3),0);
|
||||
drawLine(color,3,(loop_ps % 3),1,0,3-(loop_ps % 3),1);
|
||||
drawLine(color,3,(loop_ps % 3),2,0,3-(loop_ps % 3),2);
|
||||
drawLine(color,3,(loop_ps % 3),3,0,3-(loop_ps % 3),3);
|
||||
flushBuffer();
|
||||
clearBuffer();
|
||||
loop_ps++;
|
||||
timerReset = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
loop_ps = 0;
|
||||
spin++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
color = nextColor(color);
|
||||
spin = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue