@@ -187,22 +187,24 @@ void setup() {
187187 #endif
188188
189189 yield ();
190- if (arcada.drawBMP ((char *)" /splash.bmp" , 0 , 0 , (eye[0 ].display )) == IMAGE_SUCCESS) {
191- Serial.println (" Splashing" );
192- if (NUM_EYES > 1 ) { // other eye
193- yield ();
194- arcada.drawBMP ((char *)" /splash.bmp" , 0 , 0 , (eye[1 ].display ));
195- }
196- // backlight on for a bit
197- for (int bl=0 ; bl<=250 ; bl+=20 ) {
198- arcada.setBacklight (bl);
199- delay (20 );
200- }
201- delay (2000 );
202- // backlight back off
203- for (int bl=250 ; bl>=0 ; bl-=20 ) {
204- arcada.setBacklight (bl);
205- delay (20 );
190+ if (showSplashScreen) {
191+ if (arcada.drawBMP ((char *)" /splash.bmp" , 0 , 0 , (eye[0 ].display )) == IMAGE_SUCCESS) {
192+ Serial.println (" Splashing" );
193+ if (NUM_EYES > 1 ) { // other eye
194+ yield ();
195+ arcada.drawBMP ((char *)" /splash.bmp" , 0 , 0 , (eye[1 ].display ));
196+ }
197+ // backlight on for a bit
198+ for (int bl=0 ; bl<=250 ; bl+=20 ) {
199+ arcada.setBacklight (bl);
200+ delay (20 );
201+ }
202+ delay (2000 );
203+ // backlight back off
204+ for (int bl=250 ; bl>=0 ; bl-=20 ) {
205+ arcada.setBacklight (bl);
206+ delay (20 );
207+ }
206208 }
207209 }
208210
@@ -475,8 +477,10 @@ void loop() {
475477 if (eyeInMotion) { // Currently moving?
476478 if (dt >= eyeMoveDuration) { // Time up? Destination reached.
477479 eyeInMotion = false ; // Stop moving
478- eyeMoveDuration = random (10000 , 3000000 ); // 0.01-3 sec stop
479- eyeMoveStartTime = t; // Save initial time of stop
480+ if (moveEyesRandomly) {
481+ eyeMoveDuration = random (10000 , 3000000 ); // 0.01-3 sec stop
482+ eyeMoveStartTime = t; // Save initial time of stop
483+ }
480484 eyeX = eyeOldX = eyeNewX; // Save position
481485 eyeY = eyeOldY = eyeNewY;
482486 } else { // Move time's not yet fully elapsed -- interpolate position
@@ -489,13 +493,23 @@ void loop() {
489493 eyeX = eyeOldX;
490494 eyeY = eyeOldY;
491495 if (dt > eyeMoveDuration) { // Time up? Begin new move.
496+ // r is the radius in X and Y that the eye can go, from (0,0) in the center.
492497 float r = (float )mapDiameter - (float )DISPLAY_SIZE * M_PI_2; // radius of motion
493- r *= 0.6 ;
494- eyeNewX = random (-r, r);
495- float h = sqrt (r * r - x * x);
496- eyeNewY = random (-h, h);
498+ r *= 0.6 ; // calibration constant
499+
500+ if (moveEyesRandomly) {
501+ eyeNewX = random (-r, r);
502+ float h = sqrt (r * r - x * x);
503+ eyeNewY = random (-h, h);
504+ } else {
505+ eyeNewX = eyeTargetX * r;
506+ eyeNewY = eyeTargetY * r;
507+ }
508+
497509 eyeNewX += mapRadius;
498510 eyeNewY += mapRadius;
511+
512+ // Set the duration for this move, and start it going.
499513 eyeMoveDuration = random (83000 , 166000 ); // ~1/12 - ~1/6 sec
500514 eyeMoveStartTime = t; // Save initial time of move
501515 eyeInMotion = true ; // Start move on next frame
@@ -870,8 +884,7 @@ void loop() {
870884 lightSensorPin = -1 ; // Stop trying to use the light sensor
871885 } else {
872886 lastLightReadTime = t - LIGHT_INTERVAL + 30000 ; // Try again in 30 ms
873- }
874- }
887+ } }
875888 }
876889 irisValue = (irisValue * 0.97 ) + (lastLightValue * 0.03 ); // Filter response for smooth reaction
877890 } else {
0 commit comments