File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -85,15 +85,34 @@ void setup() {
85
85
86
86
unsigned long loopCounter = 0 ;
87
87
unsigned long timeCount = 0 ;
88
+ bool timeIncrement = true ;
88
89
89
- const unsigned long loopMod = 500 ;
90
+ const unsigned long loopMod = 50 ;
90
91
91
92
void loop () {
92
93
leds.loop ();
93
94
loopCounter++;
94
95
95
96
if (loopCounter == loopMod) {
96
- timeCount++;
97
+ if (timeIncrement) {
98
+ timeCount++;
99
+
100
+ //
101
+ // set a maximum to timeCount because floats only have
102
+ // a max precision of 5 significant digits. Otherwise, when timeCount
103
+ // gets too large, the animation will get choppy because calls to drawPlasma()
104
+ // will not have a noticable change to timeCount/TIME_DILATION. for several
105
+ // consecutive calls.
106
+ //
107
+ if (timeCount >= 1000 *PI) {
108
+ timeIncrement = false ;
109
+ }
110
+ } else {
111
+ timeCount--;
112
+ if (timeCount == 0 ) {
113
+ timeIncrement = true ;
114
+ }
115
+ }
97
116
drawPlasma (timeCount);
98
117
loopCounter = 0 ;
99
118
}
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ void setup() {
85
85
86
86
unsigned long loopCounter = 0 ;
87
87
unsigned long timeCount = 0 ;
88
+ bool timeIncrement = true ;
88
89
89
90
const unsigned long loopMod = 500 ;
90
91
@@ -93,7 +94,25 @@ void loop() {
93
94
loopCounter++;
94
95
95
96
if (loopCounter == loopMod) {
96
- timeCount++;
97
+ if (timeIncrement) {
98
+ timeCount++;
99
+
100
+ //
101
+ // set a maximum to timeCount because floats only have
102
+ // a max precision of 5 significant digits. Otherwise, when timeCount
103
+ // gets too large, the animation will get choppy because calls to drawPlasma()
104
+ // will not have a noticable change to timeCount/TIME_DILATION. for several
105
+ // consecutive calls.
106
+ //
107
+ if (timeCount >= 100000 *PI) {
108
+ timeIncrement = false ;
109
+ }
110
+ } else {
111
+ timeCount--;
112
+ if (timeCount == 0 ) {
113
+ timeIncrement = true ;
114
+ }
115
+ }
97
116
drawPlasma (timeCount);
98
117
loopCounter = 0 ;
99
118
}
You can’t perform that action at this time.
0 commit comments