Teensy 3.* - Text rendering issue with RA8875 TFT display

Hello,

I am a really big fan of the Teensy family and have been using the Teensy 2, 2++ for quite a while now. I recently bought a pair of Teensy 3.1s and am amazed at the speed and power of these tiny boards.

I have a 5" TFT touch display from Adafruit (http://www.adafruit.com/products/1596), controlled through SPI by an RA8875 driver board (http://www.adafruit.com/products/1590), programmed using their library (https://github.com/adafruit/Adafruit_RA8875). On an Arduino Uno and a Teensy 2, everything works just as expected. I tried running the same program on a Teensy 3.1 and everything works fine, except that the text rendering is screwed up. Rendered text shows up as a jumble (not even real characters). I get this issue both with my custom program and the library's example program. I feel this might have to do with the Teensy 3.1 having a 32-bit processor.

Expected (w/ Arduino Uno):
IMG_0469.jpg

Bad Rendering (w/ Teensy 3.1):
IMG_0468.jpg

Thanks in advance!
 
Last edited:
I took a quick scan at the RA8875 and GFX libraries, and the current version looks like it does not use int or unsigned int at all. All integers look like they are declared as uint8_t, int16_t, etc. The only place char was used was as a text string (chars are unsigned by default in Arm processors, and signed in AVR processors, so if you use char as a small signed int, it would be a problem). Just to be sure, you might want to see if you have the latest version of the RA8875 and GFX libraries.

The only other thing that comes to mind is it does SPI. You might check if they are using hardware SPI or software SPI. I imagine if they are doing software SPI, you might need to adjust timings.
 
Given there have been some issues with Teensy 3.1 and 1.17, I suspect you might want to wait for the 1.18. Perhaps it is one of the bugs Paul has found since 1.17 came out.
 
Except for OctoWS2811, all known problems manifest as compile errors. This is something new.

Constantin send me one of these LCDs, which just recently arrived. I'll probably work with it on Wednesday or Thursday. Sorry, I just can't get to this sooner.
 
Is TFT faster with Teensy?

I'm looking at the feasability using one of these TFT's for an application that involves full-screen text with scrolling. I've got the Adafruit 2.8" TFT shield (https://www.adafruit.com/products/1651) on a Duemilanove using SPI, and the speed at which it can draw a screenful of characters is too slow, but not by a huge margin. This shield is only set up for SPI, but I also have Adafruit's 2.8" TFT breakout version which supports an 8-bit mode that uses more pins but Adafruit says is faster (not sure how much until I test).

Do these TFT screens update any faster with the Teensy (compared to Uno/Duemilanove or Mega)? I did find this youtube video (link) comparing TFT refresh speeds of a Due vs Mega (the Due is fast enough for my needs, Mega is not). I would assume the Teensy 3.x should be in the same neighborhood as the Due, right?

Has anyone compared
  • TFT on regular Arduino with SPI
  • TFT on regular Arduino in 8-bit mode
  • TFT on Teensy with SPI
  • TFT on Teensy in 8-bit mode

Thanks.
 
tft.begin(RA8875_800x480) not working

Hi, I'm trying to do the same as slgonzalez:

I have a 5" TFT touch display from Adafruit (http://www.adafruit.com/products/1596), controlled through SPI by an RA8875 driver board (http://www.adafruit.com/products/1590), programmed using their library (https://github.com/adafruit/Adafruit_RA8875). On an Arduino Uno and a Teensy 2, everything works just as expected. I tried running the same program on a Teensy 3.1 and everything works fine...

I also have the display running well under 32U4 and teensy++ 2.0, but when I try to use it under teensy 3.1, the program stops at
Code:
tft.begin(RA8875_800x480);
without any notice. I tried both adafruit's ra8875 (https://github.com/adafruit/Adafruit_RA8875) and paul's ra8875 (https://github.com/sumotoy/RA8875) libraries but nothing changed. I power the teensy 3.1 by USB but have tryied it with external power sources - no difference.

My wiring:

HTML:
teensy 3.1 pins | ra8875 breakout from adafruit
________________|_________________________
Vin             | Vin
Gnd             | Gnd
9               | RST
10              | CD
11              | MOSI
12              | MISO
13              | SCK

Slgonzalez: Would you mind giving me your wiring? Or is there anything else that has to be done to teensy 3.1 to make it run the code?

Thank you in advance!

Dani
 
Last edited:
Another question I have though: sumotoy (mentioned above: https://github.com/sumotoy/RA8875) has a few nice sounding examples in his library: mandelbrot, 3D-examples etc. They compile in Arduino IDE 1.0.6 using Paul's library but are not displayed on the TFT. I assume a timing problem somewhere but have no clue where to look. Does anyone have an idea? Thanks, Dani
 
I just found out with adafruit rick's help (https://forums.adafruit.com/viewtopic.php?f=47&t=60533&p=320674#p320674), that the very same code
Code:
/******************************************************************
 This is an example for the Adafruit RA8875 Driver board for TFT displays
 ---------------> http://www.adafruit.com/products/1590
 The RA8875 is a TFT driver for up to 800x480 dotclock'd displays
 It is tested to work with displays in the Adafruit shop. Other displays
 may need timing adjustments and are not guanteed to work.
 
 Adafruit invests time and resources providing this open
 source code, please support Adafruit and open-source hardware
 by purchasing products from Adafruit!
 
 Written by Limor Fried/Ladyada for Adafruit Industries.
 BSD license, check license.txt for more information.
 All text above must be included in any redistribution.
 ******************************************************************/

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"


// Library only supports hardware SPI at this time
// Connect SCLK to UNO Digital #13 (Hardware SPI clock)
// Connect MISO to UNO Digital #12 (Hardware SPI MISO)
// Connect MOSI to UNO Digital #11 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
#define RA8875_INT_2 2
#define RA8875_CS_2 8
#define RA8875_RESET_2 7

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
Adafruit_RA8875 tft2 = Adafruit_RA8875(RA8875_CS_2, RA8875_RESET_2);
uint16_t tx, ty;

void tftSetup(Adafruit_RA8875 *tft)
{
  tft->displayOn(true);
  tft->GPIOX(true);      // Enable TFT - display enable tied to GPIOX
  tft->PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
  tft->PWM1out(255);

  // With hardware accelleration this is instant
  tft->fillScreen(RA8875_WHITE);

  // Play with PWM
  for (uint8_t i=255; i!=0; i-=5 ) 
  {
    tft->PWM1out(i); 
    delay(10);
  }  
  for (uint8_t i=0; i!=255; i+=5 ) 
  {
    tft->PWM1out(i); 
    delay(10);
  }
  tft->PWM1out(255); 
  
  tft->fillScreen(RA8875_RED);
  delay(500);
  tft->fillScreen(RA8875_YELLOW);
  delay(500);
  tft->fillScreen(RA8875_GREEN);
  delay(500);
  tft->fillScreen(RA8875_CYAN);
  delay(500);
  tft->fillScreen(RA8875_MAGENTA);
  delay(500);
  tft->fillScreen(RA8875_BLACK);
  
  // Try some GFX acceleration!
  tft->drawCircle(100, 100, 50, RA8875_BLACK);
  tft->fillCircle(100, 100, 49, RA8875_GREEN);
  
  tft->fillRect(11, 11, 398, 198, RA8875_BLUE);
  tft->drawRect(10, 10, 400, 200, RA8875_GREEN);
  tft->fillRoundRect(200, 10, 200, 100, 10, RA8875_RED);
  tft->drawPixel(10,10,RA8875_BLACK);
  tft->drawPixel(11,11,RA8875_BLACK);
  tft->drawLine(10, 10, 200, 100, RA8875_RED);
  tft->drawTriangle(200, 15, 250, 100, 150, 125, RA8875_BLACK);
  tft->fillTriangle(200, 16, 249, 99, 151, 124, RA8875_YELLOW);
  tft->drawEllipse(300, 100, 100, 40, RA8875_BLACK);
  tft->fillEllipse(300, 100, 98, 38, RA8875_GREEN);
  // Argument 5 (curvePart) is a 2-bit value to control each corner (select 0, 1, 2, or 3)
  tft->drawCurve(50, 100, 80, 40, 2, RA8875_BLACK);  
  tft->fillCurve(50, 100, 78, 38, 2, RA8875_WHITE);

}

void setup() 
{
  Serial.begin(57600);
  while(!Serial){}
  Serial.println("RA8875 start");

  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
  if (!tft.begin(RA8875_800x480)) {
    Serial.println("RA8875 Not Found!");
    while (1);
  }

  Serial.println("Found RA8875");

  Serial.println("RA8875 2 start");

  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
  if (!tft2.begin(RA8875_800x480)) {
    Serial.println("RA8875 2 Not Found!");
    while (1);
  }

  Serial.println("Found RA8875 2");

  tftSetup(&tft);
  tftSetup(&tft2);
  
  pinMode(RA8875_INT, INPUT);
  digitalWrite(RA8875_INT, HIGH);
  
  tft.touchEnable(true);
    
  Serial.print("Status: "); Serial.println(tft.readStatus(), HEX);
  Serial.println("Waiting for touch events ...");
}

void loop() 
{
  float xScale = 1024.0F/tft.width();
  float yScale = 1024.0F/tft.height();

  /* Wait around for touch events */
  if (! digitalRead(RA8875_INT)) 
  {
    if (tft.touched()) 
    {
      Serial.print("Touch: "); 
      tft.touchRead(&tx, &ty);
      Serial.print(tx); Serial.print(", "); Serial.println(ty);
      /* Draw a circle */
      tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 4, RA8875_WHITE);
    } 
  }
}
with the same setup (two RA8875's connected to one a microcontroller) works on a Arduino UNO (ATMEL 328P) but not on a Arduino YUN (32U4) nor a teensy++ 20 (AT90USB1286) nor a teensy 3.1 (MK20DX256) where I always get an error when initializing the first RA8875 on the SPI-bus
HTML:
Terminal output:
RA8875 start
RA8875 Not Found!
.
Does anyone have any idea in what aspects SPI on these processors (32U4, AT90USB1286, MK20DX256) differ from an ATMEL 328P?
 
Last edited:
Ugh, looks like I might have to get a 2nd RA8875 to work on this problem.

Could you please post a photo of the test hardware using Teensy 3.1? Let's at least look quickly at that. Then I'll peek at the code, and if nothing seems obviously wrong, looks like I'll get a 2nd one from Adafruit next week....
 
My setup looks as follows:
HTML:
Teensy 3.1  | RA88751 | RA88752
-------------------------------
5V          | VIN     | VIN
GND         | GND     | GND
10          | CS      |
9           | RST     |
8           |         | CS
7           |         | RST
SCK (13)    | SCK     | SCK
MOSI (11)   | MOSI    | MOSI
MISO (12)   | MISO    | MISO

2ra8875s_teensy3.1.jpg

The post above contains the code I'm trying to run.
As mentioned before, when replacing the teensy 3.1 / teensy++ 2.0 with a barebone Atmega 328P, the setup works well.
Thank you for looking at it. Dani
 
Paul, adafruit support guy Rick was able to reproduce the failure when using an Arduino Yun (32u4); he also found out that the two display setup does work with an Arduino MEGA, but not with plain Arduino LEONARDO's (32u4) [for me: as expected, since same chip as on the YUN]. I don't have any teensy 2.0 anymore, so I cannot check that, but I expect it not to work since it uses the same processor.

Have you had an idea what the problem might be between the implementations of SPI?
 
Last edited:
BTW: So far I'm able to get images from the RPi to the Arduino Mega over http/ethernet. That works ok, but is of course not as elegant as the Bridge-version of the Arduino Yun. If you're still into looking to port the bridge to other communication protocols or processors - I'm standing by to help/test. Regards, Dani
 
Back
Top