Software

Before you start soldering, get all your software running and uploaded to your Teensy microcontroller.  Getting the code loaded up first will make it easier to troubleshoot any soldering or build issues later on.  

Software setup is fully covered in the Uncanny Eyes project here.  Make sure you have installed everything listed below before moving on.

  • Arduino IDE
  • Teensyduino Installer 
  • Libraries (installed via the Arduino IDE and NOT the Teensyduino installer):
    • Adafruit_GFX
    • Adafruit_SSD1351
    • Adafruit_ST7735
  • Python PIL Library (only if you want to add your own custom images)

Once all that is installed, download and open the sketch. 

Then, make sure to select 72 mhz as your CPU speed.   If your eyes look grainy, this could be your problem.  It doesn't work right at the default CPU "overclock" speed.

Code Download

The code will download as a .zip file.  Inside you'll find a folder called "convert" that contains several different image folders and a python script, and another folder called "uncannyEyes" that contains the Arduino sketch.  Start by uploading the code as-is, for testing purposes.  Make sure it works before making changes.

Look at the uncannyEyes.ino sketch.  Right at the top you'll find several different eye options.  Uncomment the #include "newtEye.h" line to turn on the newt eye option, and comment out the #include "defaultEye.h" line. There can be only one!

#include <Adafruit_GFX.h>      // Core graphics lib for Adafruit displays
// Enable ONE of these #includes -- HUGE graphics tables for various eyes:
//#include "defaultEye.h"        // Standard human-ish hazel eye
//#include "noScleraEye.h"       // Large iris, no sclera
//#include "dragonEye.h"         // Slit pupil fiery dragon/demon eye
//#include "goatEye.h"           // Horizontal pupil goat/Krampus eye
#include "newtEye.h"           // Eye of Newt

This code defaults to rendering to two eyes.  Since we only have one eye, we can turn off the second one to make the code run faster.  Scroll down in the code to just before the "setup" function and comment out the second "displayType" line:

struct {
  displayType display; // OLED/TFT object
  uint8_t     cs;      // Chip select pin
  eyeBlink    blink;   // Current blink state
} eye[] = { // OK to comment out one of these for single-eye display:
  displayType(SELECT_L_PIN,DISPLAY_DC,0),SELECT_L_PIN,{WINK_L_PIN,NOBLINK},
  //displayType(SELECT_R_PIN,DISPLAY_DC,0),SELECT_R_PIN,{WINK_R_PIN,NOBLINK},
};

Customizing the Graphics

I wanted to make an eyeball that looked as much like a real newt's eye as possible.  I did an image search and found one I liked.

I used photoshop to "unroll" the eyeball so the software can draw it correctly.  After some cropping, zooming, and judicious use of the "Liquify" tool, here's what I ended up with.

The sclera (the white part of the eye) on a human looks really different from a reptilian eye.  I wanted a more newt-like look, so I inverted the colors in Photoshop, then added a black circle to the center to keep the pupil dark.

It took me several tries to get it right, but I'm really happy with the end result.  These images are included with the code download, and the process is explained thoroughly over at the Uncanny Eyes guide.  Go nuts and create your own unique look.

Eye Orientation

There's one more change we can make in the code to change the orientation of the image.  If your build comes out sideways or upside-down, and you want to rotate the eye to compensate, look for this line in the code, at the very end of the setup function:

#else // OLED
  eye[0].display.writeCommand(SSD1351_CMD_SETREMAP);
  eye[0].display.writeData(0x76);
#endif

To rotate the eye 90 degrees, change (0x76) to (0x77) or (0x75).  Or to rotate it 180 degrees, use (0x66).

I personally like this eye rotated 180 degrees to upside-down from the original image.  I think It makes the eye look like it's up to something crafty, which is really what I'm looking for in my Eye of Newt.

Troubleshooting

If you're having trouble, head over to the Uncanny Eyes guide and take a look at some of the troubleshooting ideas.

If you see an eye on your display but it looks snowy and pixelated, check to be sure you've selected 72 mHz as your CPU speed as noted above.  

Last updated on 2017-10-19 at 01.38.58 PM Published on 2017-10-19 at 05.00.52 PM