Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 39

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

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    5

    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):
    Click image for larger version. 

Name:	IMG_0469.jpg 
Views:	4077 
Size:	126.3 KB 
ID:	1222

    Bad Rendering (w/ Teensy 3.1):
    Click image for larger version. 

Name:	IMG_0468.jpg 
Views:	1448 
Size:	161.7 KB 
ID:	1223

    Thanks in advance!
    Last edited by slgonzalez; 12-16-2013 at 01:54 AM.

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    2,775
    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.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    5
    Quote Originally Posted by MichaelMeissner View Post
    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.
    They are using hardware SPI.

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    2,775
    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.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,203
    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.

  6. #6
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,574
    An easy thing to try: in the library's textWrite(), make the delay(1) unconditional ....

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,203
    @maitou, you called it... I just dug through the code and found this myself. Shoulda read your comment first!!

    Here's a fixed copy.

    https://github.com/PaulStoffregen/Adafruit_RA8875

  8. #8
    Junior Member
    Join Date
    Dec 2013
    Posts
    5
    Thank you so much for taking the time for this! It works now!

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,203
    Adafruit has merged this fix into the official library.

  10. #10
    Junior Member
    Join Date
    Jul 2014
    Posts
    1

    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.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,203
    8 bit mode with the UTFT library is very fast.

  12. #12
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,574
    Quote Originally Posted by vcaha View Post

    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.
    I don't have newer SPI version, but this thread has some results for 8-data lines on DUE, UNO, maple and teensy 3*
    http://forum.pjrc.com/threads/16798-...ll=1#post50374

  13. #13
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86

    tft.begin(RA8875_800x480) not working

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

    Quote Originally Posted by slgonzalez View Post
    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 Code:
    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 by local_dani_21; 11-08-2014 at 07:08 PM.

  14. #14
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86
    I got TextMode right - sorry to bother you. I now tried even another version of RA8875 library; the Adafruit_RA8875 library that was changed by Paul: https://github.com/PaulStoffregen/Adafruit_RA8875. With this library, Arduino IDE 1.0.6, teensy 3.1, the 5" TFT and adafruit's RA8875 breakout board, it all works well. Dani
    Last edited by local_dani_21; 11-09-2014 at 09:06 AM.

  15. #15
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86
    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

  16. #16
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86
    I just found out with adafruit rick's help (https://forums.adafruit.com/viewtopi...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 Code:
    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 by local_dani_21; 11-15-2014 at 09:05 AM.

  17. #17
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86
    PS: When I use a teensy 3.1 and Pauls version of the RA8875 library https://github.com/PaulStoffregen/Adafruit_RA8875 in Arduino IDE 1.0.6, then the terminal output differs slightly:
    HTML Code:
    RA8875 start
    Found RA8875
    RA8875 2 start
    RA8875 2 Not Found!
    Last edited by local_dani_21; 11-15-2014 at 09:19 AM.

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,203
    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....

  19. #19
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86
    My setup looks as follows:
    HTML Code:
    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
    Click image for larger version. 

Name:	2ra8875s_teensy3.1.jpg 
Views:	366 
Size:	150.0 KB 
ID:	2948

    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

  20. #20
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86
    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 by local_dani_21; 11-17-2014 at 07:14 AM.

  21. #21
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,203
    Ok, I've ordered a 2nd RA8875 and 5 inch LCD. If you don't hear from me by next Monday, post a reminder...

  22. #22
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86
    Quote Originally Posted by PaulStoffregen View Post
    Ok, I've ordered a 2nd RA8875 and 5 inch LCD. If you don't hear from me by next Monday, post a reminder...
    I'll be glad to!

  23. #23
    Member
    Join Date
    Jan 2013
    Location
    Zürich, Switzerland
    Posts
    86
    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

  24. #24
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,203
    Also being discussed on Adafruit's forum. My main reference is this forum, so here's a link to the latest over there... so I remember to follow up in both places.

    https://forums.adafruit.com/viewtopi...322091#p322091

  25. #25
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,203
    Quote Originally Posted by local_dani_21 View Post
    If you're still into looking to port the bridge to other communication protocols or processors - I'm standing by to help/test.
    How about this?

    https://github.com/PaulStoffregen/Bridge

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •