added asynchronous timer
This commit is contained in:
parent
53879d6546
commit
62666ebb8c
6 changed files with 608 additions and 505 deletions
|
|
@ -1,9 +1,11 @@
|
|||
/******************************** CHASE THE DOT *******************************\
|
||||
/******************************** CHASE THE DOT *******************************\
|
||||
| A single point of light moves around the cube randomly and changes colors |
|
||||
| when it tries to go out of bounds |
|
||||
| |
|
||||
| Inspired By: Jonah Glick |
|
||||
| Written By: Asher Glick |
|
||||
| |
|
||||
| Modified By: S. Dugre to use asynchronous timer |
|
||||
\******************************************************************************/
|
||||
|
||||
int xpos = 0;
|
||||
|
|
@ -13,21 +15,23 @@ int zpos = 0;
|
|||
int animationSpeed = 100;
|
||||
|
||||
void chaseTheDot() {
|
||||
//continuePattern = true;
|
||||
|
||||
if (currentState != lastState) {
|
||||
|
||||
lastState = currentState;
|
||||
Serial.print("last State = ");
|
||||
Serial.println(lastState);
|
||||
Serial.print("New State = ");
|
||||
Serial.println(currentState);
|
||||
xpos = 0;
|
||||
ypos = 0;
|
||||
zpos = 0;
|
||||
|
||||
currentTimer = 0;
|
||||
maxTimer = 6250; // 100 ms
|
||||
}
|
||||
|
||||
|
||||
//while (continuePattern) {
|
||||
if ( not animationDelayTiming) {
|
||||
if ( timerReset) {
|
||||
switch (random(0, 6)) {
|
||||
case 0:
|
||||
if (xpos > 0) {
|
||||
|
|
@ -75,8 +79,12 @@ void chaseTheDot() {
|
|||
flushBuffer();
|
||||
clearBuffer();
|
||||
//delay(animationSpeed);
|
||||
animationDelay.start();
|
||||
animationDelayTiming = true;
|
||||
Serial.println("start timer");
|
||||
|
||||
//animationDelay.start();
|
||||
//animationDelayTiming = true;
|
||||
//Serial.println("start timer");
|
||||
|
||||
currentTimer = 0;
|
||||
timerReset = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue