0

UncannyEyes and Teensy T4.0
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

UncannyEyes and Teensy T4.0

by KurtE on Fri Aug 23, 2019 5:39 pm

As you mentioned on the product video for the Teensy 4.0. I few of us who were on the T4 beta list have been playing around with the uncannyEyes sketch.

It has turned into an interesting test case, As for example we have our own version of the ST7735 and now as well ST7789 library that is based off of the Adafruit libraries. But some of the underlying stuff has been sped up for the Teensy 3.x as well now for the 4.x boards, by taking better advantage of the underlying SPI FIFO queues. This includes also now includes the ability to turn on a frame buffer, which you can use to update everything in one short and with that the ability to use DMA to update the displays...

The libraries ship with Teensyduino. However some of us are still in the process of debugging some stuff associated with this sketch and have some fixes for the T4, that I have not yet issued a PR to pull back into Paul's master branch. My WIP branch is: https://github.com/KurtE/ST7735_t3/tree/T4_DMA_LOW

Some of the interesting things this sketch uncovered was I have not tested any of these drivers when the object was created like: mytft = new ILI9341_t3(...).
Which is very interesting on T4 as this puts the object into a completely different section of memory (Most variables go into the DTCM area of FlexRam... Where heap goes into the OCRAM)... Won't bore you with details, but the new left uninitialized member variables uninitialized, where if you simply had tft = ILI9341_t3()... Like all of our normal example apps, these areas are zeroed out...

But questions, reasons why I am posting here is, wondering...
a) In my test version of the sketch (been hacked up a lot), when I enable the DMA updates for the eyes, it works fine for the terminator eyes, but for normal or dragon, the first eye does not display anything... Did you run into this at all with your new two eyed mask? If so any hints on what was the issue?

b) I just received my 2nd Adafruit ST7789 220x220 display today, and thought I would try it out (again like your new mask), and currently the code still only outputs 128x128. Wondering in your code (which I don't think is released yet), If you either scaled the pixels, from 128 up to 220 or did you have some new images which you converted to larger sizes?

c) Wondering at some point if it would make sense to try to integrate some of the speedups of the Teensy libraries like ili9341_t3 and st7735_t3, ... into the Adafruit versions? Probably into the spitft level?

Thanks
Kurt Eckhardt (KurtE up on Teensy and Github)
Attachments
uncannyEyes_async_st7735-190823a.zip
(943.54 KiB) Downloaded 5 times

KurtE
 
Posts: 23
Joined: Fri Apr 25, 2014 8:10 pm

Re: UncannyEyes and Teensy T4.0

by KurtE on Sun Aug 25, 2019 10:13 am

Quick update:

I figured out the problem with DMA version. Turned out I was using the same pin(0) for the CS for SPI1 as well as the Wink pin in the defines. Was not a problem when not using DMA as when checking this state, it was not logically pressed so both eyes worked. But in the DMA case, when I startup processing for second eye, the CS of SPI1 is asserted when it is still doing the DMA and as such the other eye thinks you are pressing the wink button.

And found out that you have a different project for the uncanny eyes for the ST7789 project. But for the heck of it, I am trying to scale up the default eye images and as such the generated data, in the uncanny eye project and have it part way working. Had to update the python... And then working through some of the issues like where code assumed 128x128 or index < 256...

Not sure how far I will take it, as I fixed or identified the issues that I was concerned about related to the T4

KurtE
 
Posts: 23
Joined: Fri Apr 25, 2014 8:10 pm

Re: UncannyEyes and Teensy T4.0

by adafruit_support_mike on Sun Aug 25, 2019 1:03 pm

Thanks for posting the information and the follow-up. I’m glad to hear the issue was something simple, since you probably know more about the Teensy 4’s internals than we do. ;-)

adafruit_support_mike
 
Posts: 58843
Joined: Thu Feb 11, 2010 2:51 pm

Re: UncannyEyes and Teensy T4.0

by KurtE on Sun Aug 25, 2019 1:32 pm

Thanks,

I have made a little more progress on getting the uncannyEyes to scale up to your ST7789 display like your new mask has.

Currently this version is using the code like you have in uncannyEyes github project and not the new mask code, which is doing things a lot differently. But I simply scaled up some of the images, plus updated your conversion Python... And it is drawing pretty good when iScale passed into the draw eye function is about > 500, else I have an issue which I am tracking down...

FYI - when I last tried with ST7735 display with the T4 running both eyes DMA on two different SPI busses. It was showing the refresh rate a little over 100

KurtE
 
Posts: 23
Joined: Fri Apr 25, 2014 8:10 pm

Re: UncannyEyes and Teensy T4.0

by KurtE on Wed Aug 28, 2019 11:09 am

Another quick update: I still have not tracked down the iris display issue I mentioned.

I did post a zip file with current stuff up on Teensy forum, that runs on T4 using two SPI busses (one for each eye), and it can be configured for ST7735 or ST7789 (also can setup to use the ST7789 displays that don't have CS pins...).

I also pushed up, the changes I did to the python script and stretched images up to the uncanny eye project in a different branch: https://github.com/KurtE/Uncanny_Eyes/tree/ST7789

Another question to self, Adafruit and others: Is we now have several derivative display libraries based at least originally off of the Adafruit ones, that have been optimized to run on T3.x and now some T4.0 boards. For example the ili9341_t3 which @PaulStoffregen did which several of us have enhanced and done similar ones. For example the one mentioned earlier for this thread. That is we have one for the ST7735 and ST7789 displays.

And then yesterday I saw a question up on PJRC forum about how many frames per second could one do on the SSD1351 with a T4... And for some reason it caught my eye, so I hacked up a new library: SSD1351_t3 (up at my https://github.com/KurtE/SSD1351_t3), which is a cross between the ST7735_t3 code and your SSD1351 library. And then did a quick and dirty test...
Code: Select all | TOGGLE FULL SIZE
//#define USE_ADAFRUIT_SSD1351
#include <Adafruit_GFX.h>    // Core graphics library
#include <SPI.h>
#define TFT_SCLK 13  // SCLK can also use pin 14
#define TFT_MOSI 11  // MOSI can also use pin 7
#define TFT_CS   10  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define TFT_DC    9  //  but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define TFT_RST   8  // RST can use any pin

#ifdef USE_ADAFRUIT_SSD1351
#include <Adafruit_SSD1351.h>
Adafruit_SSD1351 tft = Adafruit_SSD1351(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
#define SSD1351_BLACK   0x0000
#define SSD1351_BLUE    0x001F
#define SSD1351_RED     0xF800
#define SSD1351_GREEN   0x07E0
#define SSD1351_CYAN    0x07FF
#define SSD1351_MAGENTA 0xF81F
#define SSD1351_YELLOW  0xFFE0
#define SSD1351_WHITE   0xFFFF

#else
#include <SSD1351_t3.h> // Hardware-specific library
SSD1351_t3 tft = SSD1351_t3(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
#endif

void setup(void) {
  pinMode(TFT_CS, INPUT_PULLUP);

  while (!Serial && millis() < 5000) ;
  Serial.begin(9600);
  Serial.print("Start simple Frames Per Second test");

  Serial.printf("CS:%d DC:%d MOSI:%d SCLK:%d RST:%d\n", TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
  tft.begin() ;  //
}

uint16_t color_list[] = {SSD1351_RED, SSD1351_GREEN, SSD1351_BLUE, SSD1351_WHITE, SSD1351_BLACK,
                         SSD1351_YELLOW, SSD1351_MAGENTA, SSD1351_CYAN
                        };
void loop() {
  uint16_t color_index = 0;
  uint16_t frame_count = 0;
  elapsedMillis em = 0;

  // How many frames per second?
  while (em < 1000) {
    tft.fillScreen(color_list[color_index++]);
    if (color_index >= (sizeof(color_list)/sizeof(color_list[0]))) color_index = 0;
    frame_count++;
  }
  Serial.printf("Frames: %d in %d ms\n", frame_count, (uint32_t)em); 
}

With the T4 with the Adafruit_SSD1351 library I was seeing something like 48fps and with this one 72. On T3.6, I ran into SPI overrunning the display at 20mhz but at 15+ with new library I was seeing about 54 and default with Adafruit library of about 27...

Question is, does it make sense to try to integrate some of these speed ups from the _t3 libraries and try to put more Teensy 3.x/4 support directly into probably Adafruit_GFX (spitft)? Where is the best place to discuss? Forum ? or Github? or????

KurtE
 
Posts: 23
Joined: Fri Apr 25, 2014 8:10 pm

Re: UncannyEyes and Teensy T4.0

by adafruit2 on Wed Aug 28, 2019 2:21 pm

we'd love to have teensy 3/4 speedups in SPITFT.cpp, we chatted with paul about this but he got very busy. we did update all our libraries as he requested to use 'transactions' for sending commands and data. there's definitely room for speedups, even if its not as fast as can possibly be :)

adafruit2
Site Admin
 
Posts: 18659
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.