added rainbow corner animation
This commit is contained in:
parent
c5e12398be
commit
5ce8892af1
2 changed files with 34 additions and 11 deletions
|
|
@ -582,7 +582,7 @@ int currentTimer = 0;
|
||||||
int maxTimer = 6250; // 100ms delay / 16uS interrupt time
|
int maxTimer = 6250; // 100ms delay / 16uS interrupt time
|
||||||
|
|
||||||
int nextState(int state) {
|
int nextState(int state) {
|
||||||
return (state + 1) % 8;
|
return (state + 1) % 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the interrupt function to display the leds (T2 = 8 bit timer)
|
// the interrupt function to display the leds (T2 = 8 bit timer)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
/******************************* RAINBOW CORNER *******************************\
|
/******************************* RAINBOW CORNER *******************************\
|
||||||
| Found on the internet.... |
|
| Found on the internet.... |
|
||||||
| |
|
| |
|
||||||
| Modified By: S. Dugre to use asynchronous timer
|
| Modified By: S. Dugre to use asynchronous timer |
|
||||||
|
| |
|
||||||
NOT WORKING GOOD. IT SCREWS UP ANIMATION PROGRESSION
|
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
|
int loop_rc1, loop_rc2, loop_rc3, loop_rc4;
|
||||||
|
int moveAxisState;
|
||||||
|
|
||||||
byte spectrum2[24][3] = {
|
byte spectrum2[24][3] = {
|
||||||
{8,0,0},{7,1,0},{6,2,0},{5,3,0},{4,4,0},{3,5,0},{2,6,0},{1,7,0},
|
{8,0,0},{7,1,0},{6,2,0},{5,3,0},{4,4,0},{3,5,0},{2,6,0},{1,7,0},
|
||||||
{0,8,0},{0,7,1},{0,6,2},{0,5,3},{0,4,4},{0,3,5},{0,2,6},{0,1,7},
|
{0,8,0},{0,7,1},{0,6,2},{0,5,3},{0,4,4},{0,3,5},{0,2,6},{0,1,7},
|
||||||
|
|
@ -15,7 +17,7 @@ byte offset = 0;
|
||||||
byte shift[3] = {0,0,0};
|
byte shift[3] = {0,0,0};
|
||||||
bool mirror[3] = {false,false,false};
|
bool mirror[3] = {false,false,false};
|
||||||
byte anim[8] = {0,2,0,1,0,2,0,1};
|
byte anim[8] = {0,2,0,1,0,2,0,1};
|
||||||
|
|
||||||
void drawCube() {
|
void drawCube() {
|
||||||
for (byte x = 0; x <= 3; x++) {
|
for (byte x = 0; x <= 3; x++) {
|
||||||
for (byte y = 0; y <= 3; y++) {
|
for (byte y = 0; y <= 3; y++) {
|
||||||
|
|
@ -36,20 +38,25 @@ void drawCube() {
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
clearBuffer();
|
clearBuffer();
|
||||||
offset = offset == 0 ? 23 : offset - 1;
|
offset = offset == 0 ? 23 : offset - 1;
|
||||||
//delay(75);
|
//delay(75);
|
||||||
currentTimer = 0;
|
//timerReset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveAxis(byte axis) {
|
void moveAxis(byte axis) {
|
||||||
for (int n = 1;n <= 3; n++) {
|
for (int n = 1;n <= 3; n++) {
|
||||||
shift[axis] = n;
|
shift[axis] = n;
|
||||||
drawCube();
|
drawCube();
|
||||||
|
delay(75);
|
||||||
}
|
}
|
||||||
|
|
||||||
mirror[axis] = not mirror[axis];
|
mirror[axis] = not mirror[axis];
|
||||||
drawCube();
|
drawCube();
|
||||||
|
delay(75);
|
||||||
|
|
||||||
for (int n = 2;n >= 0; n--) {
|
for (int n = 2;n >= 0; n--) {
|
||||||
shift[axis] = n;
|
shift[axis] = n;
|
||||||
drawCube();
|
drawCube();
|
||||||
|
delay(75);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,13 +70,29 @@ void rainbow_corner() {
|
||||||
|
|
||||||
currentTimer = 0;
|
currentTimer = 0;
|
||||||
maxTimer = 4687; // 75 ms
|
maxTimer = 4687; // 75 ms
|
||||||
|
|
||||||
|
loop_rc1 = loop_rc2 = 0;
|
||||||
|
loop_rc3 = 1;
|
||||||
|
loop_rc4 = 2;
|
||||||
|
moveAxisState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( timerReset) {
|
if ( timerReset) {
|
||||||
for (byte n = 0;n <= 7;n++) {
|
|
||||||
for (byte m = 0;m < 50;m++) drawCube();
|
if(loop_rc2 < 50){
|
||||||
moveAxis(anim[n]);
|
loop_rc2++;
|
||||||
|
drawCube();
|
||||||
|
timerReset = false;
|
||||||
}
|
}
|
||||||
timerReset = false;
|
else {
|
||||||
|
loop_rc2 = 0;
|
||||||
|
moveAxis(anim[loop_rc1]);
|
||||||
|
if(loop_rc1 <= 7){
|
||||||
|
loop_rc1++;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
loop_rc1 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue