@@ -162,11 +162,12 @@ void setup() {
162162 delay (20 );
163163#endif
164164
165- uint8_t e;
165+ uint8_t e, rtna = 0x01 ; // Screen refresh rate control (datasheet 9.2.18, FRCTRL2)
166166 // Initialize displays
167167 for (e=0 ; e<NUM_EYES; e++) {
168168 eye[e].display = new Adafruit_ST7789 (eye[e].spi , eye[e].cs , eye[e].dc , eye[e].rst );
169169 eye[e].display ->init (240 , 240 );
170+ eye[e].display ->sendCommand (0xC6 , &rtna, 1 );
170171 eye[e].spi ->setClockSource (DISPLAY_CLKSRC);
171172 eye[e].display ->fillScreen (0x1234 );
172173 eye[e].display ->setRotation (0 );
@@ -510,24 +511,30 @@ void loop() {
510511 timeToNextBlink = blinkDuration * 3 + random (4000000 );
511512 }
512513
513- // Eyelids naturally "track" the pupils (move up or down automatically)
514- int ix = (int )map2screen (mapRadius - eye[eyeNum].eyeX ) + 120 , // Pupil position
515- iy = (int )map2screen (mapRadius - eye[eyeNum].eyeY ) + 120 ; // on screen
516- iy += irisRadius / 2 ; // top edge of iris (ish) in screen pixels
517514 float uq, lq; // So many sloppy temp vars in here for now, sorry
518- if (eyeNum & 1 ) ix = 239 - ix; // Flip for right eye
519- if (iy > upperOpen[ix]) {
520- uq = 1.0 ;
521- } else if (iy < upperClosed[ix]) {
522- uq = 0.0 ;
523- } else {
524- uq = (float )(iy - upperClosed[ix]) / (float )(upperOpen[ix] - upperClosed[ix]);
525- }
526- if (booped) {
527- uq = 0.9 ;
528- lq = 0.7 ;
515+ if (tracking) {
516+ // Eyelids naturally "track" the pupils (move up or down automatically)
517+ int ix = (int )map2screen (mapRadius - eye[eyeNum].eyeX ) + 120 , // Pupil position
518+ iy = (int )map2screen (mapRadius - eye[eyeNum].eyeY ) + 120 ; // on screen
519+ iy += irisRadius * trackFactor;
520+ if (eyeNum & 1 ) ix = 239 - ix; // Flip for right eye
521+ if (iy > upperOpen[ix]) {
522+ uq = 1.0 ;
523+ } else if (iy < upperClosed[ix]) {
524+ uq = 0.0 ;
525+ } else {
526+ uq = (float )(iy - upperClosed[ix]) / (float )(upperOpen[ix] - upperClosed[ix]);
527+ }
528+ if (booped) {
529+ uq = 0.9 ;
530+ lq = 0.7 ;
531+ } else {
532+ lq = 1.0 - uq;
533+ }
529534 } else {
530- lq = 1.0 - uq;
535+ // If no tracking, eye is FULLY OPEN when not blinking
536+ uq = 1.0 ;
537+ lq = 1.0 ;
531538 }
532539 // Dampen eyelid movements slightly
533540 // SAVE upper & lower lid factors per eye,
0 commit comments