add trifade animation
This commit is contained in:
parent
c9479eaee8
commit
86376ae168
5 changed files with 70 additions and 4 deletions
|
|
@ -1,5 +1,3 @@
|
|||
// WIP. 4/13/2022: added pin change interrupt to handle changing animations
|
||||
|
||||
#include "config.h"
|
||||
#include "cubeplex.h"
|
||||
|
||||
|
|
@ -44,6 +42,10 @@ void loop() {
|
|||
|
||||
case PLANARSPIN:
|
||||
planar_spin();
|
||||
break;
|
||||
|
||||
case TRIFADE:
|
||||
trifade();
|
||||
break;
|
||||
|
||||
case RAINBOWCORNER:
|
||||
|
|
|
|||
1
config.h
1
config.h
|
|
@ -8,6 +8,7 @@ typedef enum STATE {
|
|||
SHIFTSQUARES,
|
||||
FOUNTAIN,
|
||||
PLANARSPIN,
|
||||
TRIFADE,
|
||||
RAINBOWCORNER,
|
||||
PLANARFLOP3D
|
||||
};
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ int currentTimer = 0;
|
|||
int maxTimer = 6250; // 100ms delay / 16uS interrupt time
|
||||
|
||||
int nextState(int state) {
|
||||
return (state + 1) % 6;
|
||||
return (state + 1) % 7;
|
||||
}
|
||||
|
||||
// the interrupt function to display the leds (T2 = 8 bit timer)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ void fountain() {
|
|||
Serial.println(currentState);
|
||||
|
||||
currentTimer = 0;
|
||||
maxTimer = 0.2 * 1000 * 1000 / 16; // 0.1 seconds
|
||||
maxTimer = 0.2 * 1000 * 1000 / 16; // 0.2 seconds
|
||||
fountain_loop = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
63
trifade.ino
Normal file
63
trifade.ino
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/********************************** TRI-FADE **********************************\
|
||||
| This animation fades through the red green and blue colors of the leds |
|
||||
| creating different mixtures of each of the colors. |
|
||||
| |
|
||||
| Written By: Asher Glick |
|
||||
| Modified By: S. Dugre to use asynchronous timer |
|
||||
\******************************************************************************/
|
||||
|
||||
//int animationSpeed = 100;
|
||||
int loop_tf;
|
||||
|
||||
void trifade() {
|
||||
|
||||
if (currentState != lastState) {
|
||||
|
||||
lastState = currentState;
|
||||
Serial.print("New State = ");
|
||||
Serial.println(currentState);
|
||||
|
||||
currentTimer = 0;
|
||||
maxTimer = 0.2 * 1000 * 1000 / 16; // 0.2 seconds
|
||||
loop_tf = 1;
|
||||
}
|
||||
|
||||
if ( timerReset) {
|
||||
|
||||
switch(loop_tf){
|
||||
|
||||
case 0 ... 7:
|
||||
drawBox(blue,8-loop_tf,0,0,0,3,3,3);
|
||||
drawBox(red,loop_tf+1,0,0,0,3,3,3);
|
||||
flushBuffer();
|
||||
clearBuffer();
|
||||
loop_tf++;
|
||||
timerReset = false;
|
||||
break;
|
||||
|
||||
case 8 ... 15:
|
||||
// red fade out, green fade in
|
||||
drawBox(red,8-(loop_tf % 8),0,0,0,3,3,3);
|
||||
drawBox(green,(loop_tf % 8)+1,0,0,0,3,3,3);
|
||||
flushBuffer();
|
||||
clearBuffer();
|
||||
loop_tf++;
|
||||
timerReset = false;
|
||||
break;
|
||||
|
||||
case 16 ... 23:
|
||||
// green fade out, blue fade in
|
||||
drawBox(green,8-(loop_tf % 8),0,0,0,3,3,3);
|
||||
drawBox(blue,(loop_tf % 8)+1,0,0,0,3,3,3);
|
||||
flushBuffer();
|
||||
clearBuffer();
|
||||
loop_tf++;
|
||||
timerReset = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
loop_tf = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue