Sandro
Well-known member
Hi all, I'm trying to get a 2.8TFT SPI 240x320 touch display working with T41, SPI1.
If I use this code:
the result is a continuous print, even without any touch:
If I use this code:
and also add a line in XPT2046_Touchscreen.cpp:
then the result is a gain a continuous output without any touch:
Just for completeness, everything works with stadard SPI connection; using this code/connections:
the touch functionality is perfect:
Cannot find the mistake... Any suggestion would be appreciated.
Thanks in advance
If I use this code:
Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
// T_CLK --> 27
#define CS_PIN 35 // T_CS
// T_DIN --> 26
// T_DO --> 39
#define TIRQ_PIN 33 // T_IRQ
XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
// XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
// XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
void setup()
{
Serial.begin(38400);
ts.begin(SPI1);
ts.setRotation(0);
while (!Serial && (millis() <= 1000));
}
void loop()
{
if (ts.touched())
{
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
delay(30);
Serial.println();
}
}
the result is a continuous print, even without any touch:
Code:
Pressure = 4095, x = 4095, y = 0
Pressure = 4095, x = 4095, y = 0
Pressure = 4095, x = 4095, y = 0
Pressure = 4095, x = 4095, y = 0
Pressure = 4095, x = 4095, y = 0
Pressure = 4095, x = 4095, y = 0
Pressure = 4095, x = 4095, y = 0
Pressure = 4095, x = 4095, y = 0
Pressure = 4095, x = 4095, y = 0
If I use this code:
Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
// T_CLK --> 27
#define CS_PIN 35 // T_CS
// T_DIN --> 26
// T_DO --> 39
#define TIRQ_PIN 33 // T_IRQ
// XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
// XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
void setup()
{
Serial.begin(38400);
ts.begin(SPI1);
ts.setRotation(0);
while (!Serial && (millis() <= 1000));
}
void loop()
{
if (ts.touched())
{
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
delay(30);
Serial.println();
}
}
and also add a line in XPT2046_Touchscreen.cpp:
Code:
void isrPin( void )
{
XPT2046_Touchscreen *o = isrPinptr;
o->isrWake = true;
Serial.println("$"); // <-- Added this line
}
then the result is a gain a continuous output without any touch:
Code:
Pressure = 4095, x = $
4095, y = 0
$
$
$
$
$
$
$
$
$
$
Pressure = 4095, x = $
4095, y = 0
Just for completeness, everything works with stadard SPI connection; using this code/connections:
Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#define CS_PIN 8
// MOSI=11, MISO=12, SCK=13
//XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN 2
XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
void setup() {
Serial.begin(38400);
ts.begin();
ts.setRotation(1);
while (!Serial && (millis() <= 1000));
}
void loop() {
if (ts.touched()) {
TS_Point p = ts.getPoint();
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
delay(30);
Serial.println();
}
}
the touch functionality is perfect:
Code:
Pressure = 2431, x = 599, y = 1384
Pressure = 1618, x = 547, y = 1332
Pressure = 2147, x = 539, y = 1344
Pressure = 2219, x = 537, y = 1348
Pressure = 2153, x = 531, y = 1336
Pressure = 2026, x = 530, y = 1330
Pressure = 1800, x = 531, y = 1320
Pressure = 1744, x = 534, y = 1314
Pressure = 1845, x = 533, y = 1312
Pressure = 1903, x = 533, y = 1304
Pressure = 1920, x = 534, y = 1304
Cannot find the mistake... Any suggestion would be appreciated.
Thanks in advance