teensy 3.0 and RA8875

Status
Not open for further replies.

tony666

Member
Hi , I have a RA8875 based display board that i can't get to work with my Teensy 3.0. I'm using to what I know the latest Adafruit RA8875 and GFX libraries. What I definitely find strange is that the serial debug monitoring doesn't work ? The code sends to the serial console wether the RA8875 is found or not , but nothing is happening here ? The serial console is working with the hello world example ... so it does work ... So is there any reason why this code shouldn't work ?

Code:
/***************************************************************************************
Capacitive multitouch demo for 7" LCD connected to Arduino.
Written 15 February 2014 by Helge Langehaug.
Depends on RA8875 library from Adafruit.

Tested with ER-TFTM070-5 (LCD) from EastRising (bought from buydisplay.com)
Follow the LCD manual and set resistors and jumpers according to
4 wire SPI interface for RA8875.
Connect LCD SPI to Arduino UNO SPI(using ICSP pins)
Tested with R1-R3 open instead of 10Kohm as stated in manual.
RA8875 communication, connect:
TFTM070(40 pin) Arduino UNO pin Description
1,2 GND
3,4 VCC
5 10 SPI SELECT
6 ICSP_MISO SDO / SPI_MISO
7 ICSP_MOSI SDI / SPI_MOSI
8 ICSP_SCK CLK
33 2 CTP_INT touch data ready be read
from FT5x06 touch controller
34 A4 I2C for FT5x06 (preconfigured)
35 A5 I2C for FT5x06 (preconfigured)
12 (why?) 9 TFTM070 board is not stable if this pin is not connected.
Could be a soldering or wire fault on my board ??
The Adafruit library puts a reset pulse on that pin but
according to board pin 12 is not connected...
So this could be different on other boards...
To be examined.

****************************************************************************************/

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


// Arduino pin
#define RA8875_CS 10 // RA8875 chip select for ISP communication
#define RA8875_RESET 16 // Adafruit library puts a short low reset pulse at startup on this pin.
                               // Not relevant for TFTM070 according to doc.
#define CTP_INT 20 // touch data ready for read from FT5x06 touch controller

#define SERIAL_DEBUG_ENABLED true // set to true if you want debug info to serial port

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
FT5x06 cmt = FT5x06(CTP_INT);


void serialDebugOutput(int nr_of_touches, word *coordinates) {
  for (byte i = 0; i < nr_of_touches; i++){

    word x = coordinates[i * 2];
    word y= coordinates[i * 2 + 1];
    
    Serial.print("x");
    Serial.print(i);
    Serial.print("=");
    Serial.print(x);
    Serial.print(",");
    Serial.print("y");
    Serial.print(i);
    Serial.print("=");
    Serial.print(y);
    Serial.print(" ");
  }
}

void printRawRegisterValuesToSerial(byte *registers) {
    // print raw register values
    for (int i = 0;i < FT5206_NUMBER_OF_REGISTERS ; i++){
      Serial.print(registers[i],HEX);
      Serial.print(",");
    }
    Serial.println("");
}

void setup()
{
  Serial.begin(9600);
  Serial.println("Trying to initialize RA8875 though SPI");
  if (!tft.begin(RA8875_800x480)) {
    Serial.println("RA8875 Not Found!");
    while (1);
  }
  Serial.println("Found RA8875");

  //cmt.printInfo();

  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);
  tft.fillScreen(RA8875_GREEN);
  
  tft.textMode();
  tft.textSetCursor(10, 10);
  tft.textTransparent(RA8875_WHITE);
  tft.textEnlarge(1);
  tft.textWrite("Capacitive touch sensor demo. Touch me !");
  
  cmt.init(SERIAL_DEBUG_ENABLED);
  
  Serial.println("Setup done.");
}

word prev_coordinates[10]; // 5 pairs of x and y
byte nr_of_touches = 0;

void loop()
{
    byte registers[FT5206_NUMBER_OF_REGISTERS];

    word coordinates[10];
    
    byte prev_nr_of_touches = 0;
    
    if (cmt.touched()){
    cmt.getRegisterInfo(registers);
    nr_of_touches = cmt.getTouchPositions(coordinates, registers);
    prev_nr_of_touches = nr_of_touches;

    if (SERIAL_DEBUG_ENABLED){
      printRawRegisterValuesToSerial(registers);
      serialDebugOutput(nr_of_touches, coordinates);
    }

    // remove previous touches on screen
    for (int i = 0 ; i < prev_nr_of_touches; i++){
      word x = prev_coordinates[i * 2];
      word y = prev_coordinates[i * 2 + 1];
      tft.fillCircle(x, y, 70, RA8875_GREEN);
    }
    
    // mark touches on screen
    for (byte i = 0; i < nr_of_touches; i++){
      word x = coordinates[i * 2];
      word y = coordinates[i * 2 + 1];
      
      // Mark touches on screen
      tft.fillCircle(x, y, 70, RA8875_BLUE);
      tft.fillCircle(x, y, 50, RA8875_WHITE);
      tft.fillCircle(x, y, 30, RA8875_WHITE);
    }
    delay(10);
    memcpy(prev_coordinates, coordinates, 20);


    }
  
}
 
I previously tested Adafruit_RA8875. It worked, with one minor bug (since fixed) in text rendering.

Here's the prior conversation.

http://forum.pjrc.com/threads/24668-Teensy-3-*-Text-rendering-issue-with-RA8875-TFT-display

I don't know if that really helps, but at least you can see it did work a few months ago.

Since then, Adafruit has made only this one minor change.

https://github.com/adafruit/Adafruit_RA8875/commit/08681bb1972237e1b403583c1a03bf8c48bdd5ba

You could try to revert that change, or work some git magic to download a copy of the code as it was before that change on Jan 3rd.
 
I tried my Teensy++2.0 board and the LCD worked.

I changed a jumper setting (5v <-> 3.3v) on the display PCB. Now I can see 2 situations why the Teensy 3.0 didn't work : a power issue of the display PCB when Vin is 3.3V or a Teensy 3.0 issue ?

Did you test it on a 3.0 or 3.1 Teensy ?
 
Status
Not open for further replies.
Back
Top