PiTFT v2 STMPE610 and ILI9341 combo Touch not working

Status
Not open for further replies.
Hello, i have a Pitft STMPE610 and ILI9341 combo, Adafruit ID:1601
The resistive touchscreen part i want to get working, with a Teensy 3.6 but the appoch from
the sketches does not seem to work, from the documentation it seems the resistive STMPE_CS pin goes to
CE1 and further spi to spi connected and #define TFT_CS 10 goes to CE0
#define TFT_DC 9 goes to BCM25 (pin 22)on the Rpi connector and thats it,
This is from the touchpaint example sketch and the onoffbutton example sketch.
onoffbutton sketch included, touchpaint see your Arduino teensy example sketch folder please
Code:
//This example implements a simple sliding On/Off button. The example
// demonstrates drawing and touch operations.
//
//Thanks to Adafruit forums member Asteroid for the original sketch!
//
#include <SPI.h>
#include <Wire.h>
#include <ILI9341_t3.h>
#include <Adafruit_STMPE610.h>

// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000

#define STMPE_CS 8
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);
#define TFT_CS 10
#define TFT_DC  9
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC);

boolean RecordOn = false;

#define FRAME_X 210
#define FRAME_Y 180
#define FRAME_W 100
#define FRAME_H 50

#define REDBUTTON_X FRAME_X
#define REDBUTTON_Y FRAME_Y
#define REDBUTTON_W (FRAME_W/2)
#define REDBUTTON_H FRAME_H

#define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W)
#define GREENBUTTON_Y FRAME_Y
#define GREENBUTTON_W (FRAME_W/2)
#define GREENBUTTON_H FRAME_H

void drawFrame()
{
  tft.drawRect(FRAME_X, FRAME_Y, FRAME_W, FRAME_H, ILI9341_BLACK);
}

void redBtn()
{ 
  tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_RED);
  tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_BLUE);
  drawFrame();
  tft.setCursor(GREENBUTTON_X + 6 , GREENBUTTON_Y + (GREENBUTTON_H/2));
  tft.setTextColor(ILI9341_WHITE);
  tft.setTextSize(2);
  tft.println("ON");
  RecordOn = false;
}

void greenBtn()
{
  tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, ILI9341_GREEN);
  tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, ILI9341_BLUE);
  drawFrame();
  tft.setCursor(REDBUTTON_X + 6 , REDBUTTON_Y + (REDBUTTON_H/2));
  tft.setTextColor(ILI9341_WHITE);
  tft.setTextSize(2);
  tft.println("OFF");
  RecordOn = true;
}

void setup(void)
{
  Serial.begin(9600);
  tft.begin();
  if (!ts.begin()) { 
    Serial.println("Unable to start touchscreen.");
  } 
  else { 
    Serial.println("Touchscreen started."); 
  }

  tft.fillScreen(ILI9341_BLUE);
  // origin = left,top landscape (USB left upper)
  tft.setRotation(1); 
  redBtn();
}

void loop()
{
  // See if there's any  touch data for us
  if (!ts.bufferEmpty())
  {   
    // Retrieve a point  
    TS_Point p = ts.getPoint(); 
    // Scale using the calibration #'s
    // and rotate coordinate system
    p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height());
    p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width());
    int y = tft.height() - p.x;
    int x = p.y;

    if (RecordOn)
    {
      if((x > REDBUTTON_X) && (x < (REDBUTTON_X + REDBUTTON_W))) {
        if ((y > REDBUTTON_Y) && (y <= (REDBUTTON_Y + REDBUTTON_H))) {
          Serial.println("Red btn hit"); 
          redBtn();
        }
      }
    }
    else //Record is off (RecordOn == false)
    {
      if((x > GREENBUTTON_X) && (x < (GREENBUTTON_X + GREENBUTTON_W))) {
        if ((y > GREENBUTTON_Y) && (y <= (GREENBUTTON_Y + GREENBUTTON_H))) {
          Serial.println("Green btn hit"); 
          greenBtn();
        }
      }
    }

    Serial.println(RecordOn);
  }  
}
The touch part does not work, the screen part is working okay, very nice.
Where can i look to get the touch part working, any help is fine, Dian from the Netherlands
And Ps on the Rpi the touch part works
 
Might help to see actual picture of your setup.

I could not tell from your description, do you have the display configured with the pin26 on the connector(CE1) going to the Teensy pin 8? Which is what your program implies.

Also I need to look at library again to see how and when it is configured to use an interrupt pin from the STMPE...
From the Schematic: https://cdn-learn.adafruit.com/asse...riginal/raspberry_pi_piplussch.png?1431968295
Looks like this would be on pin 18 on the connector (RPI GPIO24). Not sure if you are hooked up to use this or not.

Maybe I need to dig through my pile of stuff to see if mine is working... Probably in the RPI box
 
Hello, KurtE thanks for the reply,
Indeed this goes to pin 8 on the Teensy : display configured with the pin26 on the connector(CE1) going to the Teensy pin 8 STMPE_CS pin, i forgot the 8. you are thoroughly, thats good cause thats needed.
And now we go in the right direction because i missed this pin to connect
"pin 18 on the connector (RPI GPIO24)" That's the pin that i missed.
The pdf that came with the PiTFT stated: Uses SPI and 4 GPIO pins that are CE0, CE1,
GPIO#25, GPIO#24.
i just checked the pdf, it's called adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi.
And indeed again GPIO#24 is the RT interrupt that's what they call it on the https://pinout.xyz/pinout/pitft_plus_35#
So i need to look for this "use an interrupt pin from the STMPE... " Stands RT interrupt for Resistive Touch interrupt.
The interrupt for the STMPE610 controller, i did not find that in the sketches i was looking at the last week, so i you can help me out here, i wil be very glad,
and about the foto of my setup, the pin(GPIO#24) i want to use is not connected yet, so i leave this right now.
Thanks, Dian
 
What i find strange in the hole story: why do the sketches use SPI-pins, and TFT_CS 10 with it,
and TFT_DC 9, and STMPE_CS 8
Non of the sketches use a RT_INT pin,
and this pitft screen and controller is using the same components, the smtpe610 and the ili9341.
Thanks for your help
 
Status
Not open for further replies.
Back
Top