File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,15 +85,34 @@ void setup() {
8585
8686unsigned long loopCounter = 0 ;
8787unsigned long timeCount = 0 ;
88+ bool timeIncrement = true ;
8889
89- const unsigned long loopMod = 500 ;
90+ const unsigned long loopMod = 50 ;
9091
9192void loop () {
9293 leds.loop ();
9394 loopCounter++;
9495
9596 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+ }
97116 drawPlasma (timeCount);
98117 loopCounter = 0 ;
99118 }
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ void setup() {
8585
8686unsigned long loopCounter = 0 ;
8787unsigned long timeCount = 0 ;
88+ bool timeIncrement = true ;
8889
8990const unsigned long loopMod = 500 ;
9091
@@ -93,7 +94,25 @@ void loop() {
9394 loopCounter++;
9495
9596 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+ }
97116 drawPlasma (timeCount);
98117 loopCounter = 0 ;
99118 }
You can’t perform that action at this time.
0 commit comments