Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: T3.2 with Capacitive Touch Problem

  1. #1

    T3.2 with Capacitive Touch Problem

    Iím trying to use Teensy 3.2 with ER-TFTM050A2-2 5Ē 480X272 TFT display capacitive touchscreen and RA8875 library version 0.7b11p11 by Max MC Costa for sumotoy.

    I have the SPI-based display part working perfectly.

    I cannot get the i2C-based capacitive touchscreen part to do anything.

    Iíve uncommented the USE_FT5206_TOUCH line in RA8875UserSettings.h

    My i2C wiring is:
    Teensy TFTM050A2-2
    2 Touch interrupt JP1-33
    18 SDA0 JP1-34
    19 SCL0 JP1-35

    Iíve set pull-up resistors on pins 18 and 19 by setting their pinMode to INPUT_HIGH.

    I can find no documentation on it but I am assuming the RA8875 library uses the default SDA0 and SCL0 pins (18 & 19 per the Teensy 3.2 pinout card).

    None of the RA8875 library example sketches for the Teensy that use the capacitive touchscreen respond to touches; only the display part works.

    What am I missing? What am I doing wrong?

  2. #2
    Senior Member
    Join Date
    Nov 2015
    Location
    Cold hollow VT
    Posts
    139
    You must use external resistors on the I2C lines. Tie them to 5v or 3.3v (whatever the FT5206 uses). Just configuring the I2C pins with a 'INPUT-PULLUP' won't work as the I2C driver reconfigures the pins.

    Sharing your code and wiring may get you some more help.

  3. #3
    Thank you grease_lighting.

    For now I'm just trying to get the FT5206_touchScreen.ino example in the RA8875-0.7b11 library to work.
    With changes to the Chip Select and Interrup pins this example DOES detect screen touches for me but does not return touch coordinates. tft.getTouches() returns 0 and returned coordinates are 0.
    I have 4.7K-ohm pull-ups on SDA0 (pin 18) and SCL0 (pin 19). I'm guessing the touch interrupt to pin 2 is working but i2c data is not.

    Code:
    /*
    An example of the internal support for the capacitive touch screen
    that use FT5206.
    Using FT5206 instead resistive RA8875 one give more precision, don't need any calibration
    and you have max 5 concurrent touches plus gesture and more...
    */
    
    #include <SPI.h>
    #include <RA8875.h>
    #include <Wire.h>
    
    
    #define RA8875_CS         6 
    #define RA8875_RESET    255                 
    #define RA8875_INT        2
    
    #define MAXTOUCHLIMIT     5//1...5
    
    RA8875 tft = RA8875(RA8875_CS, RA8875_RESET);
    
    
    void setup(){
      /*
      Serial.begin(38400);
      long unsigned debug_start = millis ();
      while (!Serial && ((millis () - debug_start) <= 5000)) ;
      */
      tft.begin(RA8875_480x272);
      #if defined(USE_FT5206_TOUCH)
      tft.useCapINT(RA8875_INT);//we use the capacitive chip Interrupt out!
      //the following set the max touches (max 5)
      //it can be placed inside loop but BEFORE touched()
      //to limit dinamically the touches (for example to 1)
      tft.setTouchLimit(MAXTOUCHLIMIT);
      //tft.setRotation(0);//this works in any rotation mode!
      tft.enableCapISR(true);//capacitive touch screen interrupt it's armed
      #else
      tft.print("you should open RA8875UserSettings.h file and uncomment USE_FT5206_TOUCH!");
      #endif
      tft.setTextColor(RA8875_WHITE,RA8875_BLACK);
    }
    
    void loop(){
      #if defined(USE_FT5206_TOUCH)
      if (tft.touched()){//if touched(true) detach isr
      //at this point we need to fill the FT5206 registers...
        tft.updateTS();//now we have the data inside library
        tft.setCursor(CENTER,CENTER);
        tft.print("                              ");
        tft.setCursor(CENTER,CENTER);
        tft.print("touches:");
        tft.print(tft.getTouches());
        tft.print(" | gesture:");
        tft.print(tft.getGesture(),HEX);
        tft.print(" | state:");
        tft.print(tft.getTouchState(),HEX);
        //you need to get the coordinates? We need a bidimensional array
        uint16_t coordinates[MAXTOUCHLIMIT][2];//to hold coordinates
        tft.getTScoordinates(coordinates);//done
        
        // Serial prints for debugging
        Serial.print("getTouches() returned "); Serial.print(tft.getTouches());
        Serial.print(" Touched coords[0] "); Serial.print(coordinates[0][0]); Serial.print(","); Serial.println(coordinates[0][1]);
        
        //now coordinates has the x,y of all touches
        //now draw something....
        uint16_t tempCol;
        for (uint8_t i=1;i<=tft.getTouches();i++){
          if (i == 1)tempCol = RA8875_RED;
          if (i == 2)tempCol = RA8875_GREEN;
          if (i == 3)tempCol = RA8875_MAGENTA;
          if (i == 4)tempCol = RA8875_CYAN;
          if (i == 5)tempCol = RA8875_YELLOW;
          tft.fillCircle(coordinates[i-1][0],coordinates[i-1][1],10,tempCol);
        }
        tft.enableCapISR();//rearm ISR if needed (touched(true))
        //otherwise it doesn't do nothing...
      }
      #endif
    }

  4. #4
    NEVER MIND! I had SDA connected to the wrong pin on the display. All working great now!

  5. #5
    Hi

    I'm trying the exact same thing as you but with a Teensy 3.6 but can't find the RA8875 library you use.

    Do you have a link to it?

    Regards
    Hans

  6. #6
    I’m using this: https://github.com/sumotoy/RA8875

    With the #define USE_FT5206_TOUCH line in RA8875UserSettings.h un commented.

    I downloaded this library and put it my “libraries” folder. But it turns out there is also a copy of this in the C:\Programs\Arduino\... directory. So I’m thinking it’s included in the libraries for the Teensy. And I had to also edit the RA8874UserSettings.h in the C:\Programs\Arduino\... directory.

  7. #7
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,628
    Note: I don't remember if sumotoys library was updated to properly work with the T3.6... I know it did not work with the T4... So a few of us updated and extended it.

    Our latest stuff is up at: https://github.com/mjs513/RA8875/tree/RA8875_t4

    And I believe that the version now installed with the latest beta of teensyduino is up to date with this version.

  8. #8
    Ok, thanks for your replies. Will test and ser whats happen.

Posting Permissions

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