📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 3 Day orders by 11am ET Friday December 13 📬❄️📦
0

teensy 3.2 and uncanny eyes
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

teensy 3.2 and uncanny eyes

by Kidkill on Sun Nov 24, 2019 11:04 am

Hello,
I've put together the uncanny eyes project and I'm getting weird results. I've triple checked the connections. Please find the attached photo. There is some animation happening in the screens, just not right though.
Attachments
20191123_201457.jpg
20191123_201457.jpg (142.49 KiB) Viewed 104 times

Kidkill
 
Posts: 42
Joined: Mon Mar 18, 2019 7:21 pm

Re: teensy 3.2 and uncanny eyes

by XRAD on Sun Nov 24, 2019 4:32 pm

did you try the adafruit TFT test display(it's in the arduino examples section) ? did it work?

XRAD
 
Posts: 567
Joined: Sat Nov 19, 2016 3:28 pm

Re: teensy 3.2 and uncanny eyes

by Kidkill on Sun Nov 24, 2019 9:53 pm

I tried that, similar results. I noticed the example had numerous different screen settings, I'm using the 240x240 ips tft displays, once I selected the correct one it worked fine, so some setting in the uncanny eyes ino needs to be changed but I'm not sure what. I changed the library from 7735 to 7789 and it improved, but it's still not right. The photo shows the improvement, the white bit at the top is trying to blink and stuff.
Attachments
20191124_184216_resized.jpg
20191124_184216_resized.jpg (693.32 KiB) Viewed 90 times

Kidkill
 
Posts: 42
Joined: Mon Mar 18, 2019 7:21 pm

Re: teensy 3.2 and uncanny eyes

by michaelmeissner on Tue Nov 26, 2019 2:34 am

I'm not sure what is going on here. It might be helpful to post your config.h file (and if you changed the main uncannyEyes.ino file what changes you made to that), what Teensy you are using, and what clock speed you are using.

The uncannyEyes project was made for the Teensy 3.2 and two 128x128 displays (either the OLED displays or the TFT displays). You are using it with the 240x240 displays. I would have thought that you would only see a 128x128 image on the larger display. I didn't think the 3.2 had enough memory to support the 240x240 display.

Now I have run uncannyEyes on several Teensys and with several of the displays. I have run the 3.2, 3.5, and 3.6 with the 128x128 displays, and I have run the 4.0 with a variant of uncannyEyes that users in the PJRC forums have done to support the 240x240 display.

I have found that the uncannyEyes program can be real sensitive to SPI bus speeds. In the past, I had to adjust config.h to use a slower SPI bus speed, particularly on the faster 3.5 and 3.6. Before changing the SPI bus speeds, I was having to set the processors to lower CPU clock speeds, particularly on the faster 3.5/3.6 processors. When I started adjusting the SPI bus speed, it allowed me to run at maximum processor clock speed and I could drive both displays without corruption.

After adjusting the SPI bus speeds I ran across a paper of how to better do SPI bus design by Paul Stoffregen (main creator of the Teensy):

In it he mentioned that adding a pull-up resistor on each CS pin helped on shared SPI bus system. I added 2.2K pull-up resistors for each of the two CS pins on the displays. I also did the shared D/C pin for good measure. Adding the pull-up resistors allowed me to boost the SPI bus speed higher before corruption stepped in or the display just couldn't keep up. Note, a pull-up resistor is a resistor that goes from the pin in question to the 3.3v power line that is in parallel with the data connection. If the pin isn't set, it tends to make it go high instead of floating between high/low. I now currently use a SPI bus speed of 19 Mhz for the OLED displays and 24 Mhz for the 128x128 TFT display on the Teensy 3.2/3.5/3.6. On the Teensy 4.0, using a hacked version of uncannyEyes, I use 48 Mhz SPI bus speed for the 240x240 TFT display.

You might want to look at these thread also:

michaelmeissner
 
Posts: 1397
Joined: Wed Aug 29, 2012 12:40 am

Re: teensy 3.2 and uncanny eyes

by XRAD on Wed Nov 27, 2019 2:45 pm

Good. If you got the TFT example to work, it really helps to make sure your pins are correct and screen x,y is correct. keep looking through the config.h file for what you need to change, and make sure you have the most up to date eye .ino and other files. I was able to get the eyes to work with several different processors and screens. For example:

Code: Select all | TOGGLE FULL SIZE
// Optional: enable this line for startup logo (screen test/orient):
#if !defined(ADAFRUIT_HALLOWING)    // Hallowing can't always fit logo+eye
  #include "graphics/logo.h"        // Otherwise your choice, if it fits
#endif

XRAD
 
Posts: 567
Joined: Sat Nov 19, 2016 3:28 pm

Re: teensy 3.2 and uncanny eyes

by Kidkill on Sun Dec 01, 2019 9:44 pm

Here is the config.h. I'm using the teensy 3.2. Line 84 is where I switched to the 7789 library. I didn't change anything in the .ino. CPU speed 72MHz.

Code: Select all | TOGGLE FULL SIZE
// Pin selections here are based on the original Adafruit Learning System
// guide for the Teensy 3.x project.  Some of these pin numbers don't even
// exist on the smaller SAMD M0 & M4 boards, so you may need to make other
// selections:

// GRAPHICS SETTINGS (appearance of eye) -----------------------------------

// If using a SINGLE EYE, you might want this next line enabled, which
// uses a simpler "football-shaped" eye that's left/right symmetrical.
// Default shape includes the caruncle, creating distinct left/right eyes.
// Hallowing, with one eye, does this by default
#if defined(ADAFRUIT_HALLOWING) || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(ARDUINO_NRF52840_CIRCUITPLAY)
  #define SYMMETRICAL_EYELID
#else                     // Otherwise your choice, standard is asymmetrical
  //#define SYMMETRICAL_EYELID
#endif

// Enable ONE of these #includes -- HUGE graphics tables for various eyes:
#include "graphics/defaultEye.h"      // Standard human-ish hazel eye -OR-
//#include "graphics/dragonEye.h"     // Slit pupil fiery dragon/demon eye -OR-
//#include "graphics/noScleraEye.h"   // Large iris, no sclera -OR-
//#include "graphics/****Eye.h"       // Horizontal pupil ****/Krampus eye -OR-
//#include "graphics/newtEye.h"       // Eye of newt -OR-
//#include "graphics/terminatorEye.h" // Git to da choppah!
//#include "graphics/catEye.h"        // Cartoonish cat (flat "2D" colors)
//#include "graphics/owlEye.h"        // Minerva the owl (DISABLE TRACKING)
//#include "graphics/naugaEye.h"      // Nauga googly eye (DISABLE TRACKING)
//#include "graphics/doeEye.h"        // Cartoon deer eye (DISABLE TRACKING)

// Optional: enable this line for startup logo (screen test/orient):
#if !defined(ADAFRUIT_HALLOWING)    // Hallowing can't always fit logo+eye
  #include "graphics/logo.h"        // Otherwise your choice, if it fits
#endif

// EYE LIST ----------------------------------------------------------------

// This table contains ONE LINE PER EYE.  The table MUST be present with
// this name and contain ONE OR MORE lines.  Each line contains THREE items:
// a pin number for the corresponding TFT/OLED display's SELECT line, a pin
// pin number for that eye's "wink" button (or -1 if not used), and a screen
// rotation value (0-3) for that eye.

eyeInfo_t eyeInfo[] = {
#if defined(ADAFRUIT_HALLOWING)
  { 39, -1, 2 }, // SINGLE EYE display-select and wink pins, rotate 180
#elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(ARDUINO_NRF52840_CIRCUITPLAY)
  { A6, -1, 2 }, // SINGLE EYE display-select and wink pins, rotate 180
#elif defined(ADAFRUIT_TRINKET_M0)
  {  0, -1, 0 }, // SINGLE EYE display-select, no wink, no rotation
#else
  {  9, 0, 0 }, // LEFT EYE display-select and wink pins, no rotation
  { 10, 2, 0 }, // RIGHT EYE display-select and wink pins, no rotation
#endif
};

// DISPLAY HARDWARE SETTINGS (screen type & connections) -------------------

#if defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)
  #define TFT_SPI        SPI1
  #define TFT_PERIPH     PERIPH_SPI1
#else
  #define TFT_SPI        SPI
  #define TFT_PERIPH     PERIPH_SPI
#endif

#if defined(ADAFRUIT_HALLOWING)
  #include <Adafruit_ST7735.h>  // 128x128 TFT display library
  #define DISPLAY_DC        38  // Display data/command pin
  #define DISPLAY_RESET     37  // Display reset pin
  #define DISPLAY_BACKLIGHT  7
  #define BACKLIGHT_MAX    128
  //#define SYNCPIN         A2  // I2C sync if set, GND this pin on receiver
  //#define SYNCADDR      0x08  // I2C address of receiver
                                // (Try disabling SYMMETRICAL_EYELID then)
#elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(ARDUINO_NRF52840_CIRCUITPLAY)
  #include <Adafruit_ST7789.h> // 240x240 TFT display library
  #define DISPLAY_DC        A7 // Display data/command pin
  #define DISPLAY_RESET     -1 // Display reset pin
  #define DISPLAY_BACKLIGHT A3
  #define BACKLIGHT_MAX    255
#else
  // Enable ONE of these #includes to specify the display type being used
  //#include <Adafruit_SSD1351.h>  // OLED display library -OR-
  #include <Adafruit_ST7789.h>  // TFT display library (enable one only)
  #if defined(ADAFRUIT_TRINKET_M0)
    #define DISPLAY_DC       1
    #define DISPLAY_RESET   -1 // Use MCU reset pin
  #else
    #define DISPLAY_DC       7  // Data/command pin for ALL displays
    #define DISPLAY_RESET    8  // Reset pin for ALL displays
  #endif
#endif

#if defined(_ADAFRUIT_ST7735H_) || defined(_ADAFRUIT_ST77XXH_)
 #if defined(ARDUINO_ARCH_NRF52)
  #define SPI_FREQ 32000000    // TFT: use max SPI
 #else
  #define SPI_FREQ 24000000    // TFT: use max SPI
 #endif
#else // OLED
  #if !defined(ARDUINO_ARCH_SAMD) && (F_CPU <= 72000000)
    #define SPI_FREQ 24000000  // OLED: 24 MHz on 72 MHz Teensy only
  #else
    #define SPI_FREQ 12000000  // OLED: 12 MHz in all other cases
  #endif
#endif

// INPUT SETTINGS (for controlling eye motion) -----------------------------

// JOYSTICK_X_PIN and JOYSTICK_Y_PIN specify analog input pins for manually
// controlling the eye with an analog joystick.  If set to -1 or if not
// defined, the eye will move on its own.
// IRIS_PIN speficies an analog input pin for a photocell to make pupils
// react to light (or potentiometer for manual control).  If set to -1 or
// if not defined, the pupils will change on their own.
// BLINK_PIN specifies an input pin for a button (to ground) that will
// make any/all eyes blink.  If set to -1 or if not defined, the eyes will
// only blink if AUTOBLINK is defined, or if the eyeInfo[] table above
// includes wink button settings for each eye.

//#define JOYSTICK_X_PIN A0 // Analog pin for eye horiz pos (else auto)
//#define JOYSTICK_Y_PIN A1 // Analog pin for eye vert position (")
//#define JOYSTICK_X_FLIP   // If defined, reverse stick X axis
//#define JOYSTICK_Y_FLIP   // If defined, reverse stick Y axis
#define TRACKING            // If defined, eyelid tracks pupil
#define AUTOBLINK           // If defined, eyes also blink autonomously
#if defined(ADAFRUIT_HALLOWING)
  #define LIGHT_PIN      A1 // Hallowing light sensor pin
  #define LIGHT_CURVE  0.33 // Light sensor adjustment curve
  #define LIGHT_MIN      30 // Minimum useful reading from light sensor
  #define LIGHT_MAX     980 // Maximum useful reading from sensor
#elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(ARDUINO_NRF52840_CIRCUITPLAY) // TFT Gizmo
  #define LIGHT_PIN      A8 // CPX light sensor pin
  #define LIGHT_CURVE  0.33 // Light sensor adjustment curve
  #define LIGHT_MIN      30 // Minimum useful reading from light sensor
  #define LIGHT_MAX     980 // Maximum useful reading from sensor
  #define BLINK_PIN       4 // Pin for manual blink button (BOTH eyes)
  #define PIXEL_DOUBLE      // Use 2x2 pixels on 240x240 display
#elif defined(ADAFRUIT_TRINKET_M0)
  #define BLINK_PIN      -1 // No blink pin
  #define LIGHT_PIN      -1 // No photocell
#else
  #define BLINK_PIN       1 // Pin for manual blink button (BOTH eyes)
  #define LIGHT_PIN      A2 // Photocell or potentiometer (else auto iris)
//#define LIGHT_PIN_FLIP    // If defined, reverse reading from dial/photocell
  #define LIGHT_MIN       0 // Lower reading from sensor
  #define LIGHT_MAX    1023 // Upper reading from sensor
#endif
#define IRIS_SMOOTH         // If enabled, filter input from IRIS_PIN
#if !defined(IRIS_MIN)      // Each eye might have its own MIN/MAX
  #define IRIS_MIN      120 // Iris size (0-1023) in brightest light
#endif
#if !defined(IRIS_MAX)
  #define IRIS_MAX      720 // Iris size (0-1023) in darkest light
#endif

Kidkill
 
Posts: 42
Joined: Mon Mar 18, 2019 7:21 pm

Re: teensy 3.2 and uncanny eyes

by michaelmeissner on Thu Dec 05, 2019 10:01 am

FWIW, I can replicate your issue with both a Teensy 3.2 and with a Teensy 3.6.

Unfortunately, in looking at the code, it will need serious surgery to use that display on any Teensy.

I have a version of the code modified by the display hackers over at PJRC.COM that works for the Teensy 4.0 with two of the 240x240 displays. In order to run it on the T4, you have to solder wires underneath the T4 to bring out the 2nd or 3rd SPI buses. Note, the uncanny eye code did not use the library to draw the image, instead it dived in and used all of the Teensy 3.x hardware directly. That hardware is completely different in the Teensy 4. If/when I get time, I will upload it and post a link (right now I am kind of busy).

One problem is the 240x240 display uses 4 times the memory as the 128x128 displays the code was written for. There are changes in the code to double each pixel, and essentially treat it as a 120x120 display. This works on the Adafruit SAMD M4 boards like the Hallowing M4, but the support was never backported to the Teensy. I enabled the code to double the pixels, but it only worked partially as most of the code doing the doubling is in the SAMD section. There was a narrow band where the eyes were done, but it didn't fill the display.

I tried it on the Teensy 3.6 which has more memory, but it still fails in the same way. So I suspect there are other places where it is expecting the 128x128 displays.

Note in your config.h file, the D/C pin should really be on one of the special hardware accelerated pins like the two CS pins. In doing my tests, I moved it from pin 7 to pin 15/A1. The special pins are:
  • Pin 2 or pin 10 (you can't use the other pin for SPI);
  • Pin 6 or pin 9;
  • Pin 15/A1;
  • Pin 20/A6 or pin 23/A9; (or)
  • Pin 21/A7 or pin 22/A8.

michaelmeissner
 
Posts: 1397
Joined: Wed Aug 29, 2012 12:40 am

Please be positive and constructive with your questions and comments.