Hi to all, I'm a newbie so I beg apologize if I put some nonsense. I'm testing the example "TouchTest" of the XPT2046_Touchscreen 1.2.0 library with Arduino IDE 1.8.5:
The results and problems are:
A) The function if (ts.touched()) doesn't work correctly because it doesn't wait for the interruption to arrive.
The initial value for Pressuree, x and y are, 4095, 4080, 0, respectively. I think that x should be 0, too, as for y.
B) By touching, approximately, in the center of the screen, x and y acquire the values 1984 and 1952. The screen is 320x240 but I have not found in XPT2046_Touchscreen where the width and height of the screen can be fixed.
C) Two Warnings related to the SPI clock frequency appear in my simulator.
D) Using the debugging capabilities of my simulator I get the following:
It may be that everything is due to some SPI control problem of the XPT2046_Touchscreen 1.2.0 library but I think there must be some problem in the initial value of x and how to set the resolution of the screen, in this case 320x240.
Paul or any of the forum gurus can help me?
Thank you for your time and attention.
Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
//XPT2046_Touchscreen ts(CS_PIN);
#define CS_PIN 14
// MOSI=11, MISO=12, SCK=13 UNO
// MOSI=51, MISO=50, SCK=52 MEGA
//XPT2046_Touchscreen ts(CS_PIN); // Param 2 - NULL - No interrupts
//XPT2046_Touchscreen ts(CS_PIN, 255); // Param 2 - 255 - No interrupts
#define TIRQ_PIN 15
XPT2046_Touchscreen ts(CS_PIN, TIRQ_PIN); // Param 2 - Touch IRQ Pin - interrupt enabled polling
void setup() {
Serial.begin(9600);
ts.begin();
while (!Serial && (millis() <= 1000));
}
void loop() {
if (ts.touched()) {
TS_Point p = ts.getPoint();
Serial.print("P= ");Serial.print(p.z);Serial.print(", x= ");Serial.print(p.x);
Serial.print(", y= ");Serial.print(p.y);Serial.println();
delay(300);
}
}
A) The function if (ts.touched()) doesn't work correctly because it doesn't wait for the interruption to arrive.
The initial value for Pressuree, x and y are, 4095, 4080, 0, respectively. I think that x should be 0, too, as for y.
B) By touching, approximately, in the center of the screen, x and y acquire the values 1984 and 1952. The screen is 320x240 but I have not found in XPT2046_Touchscreen where the width and height of the screen can be fixed.
C) Two Warnings related to the SPI clock frequency appear in my simulator.
D) Using the debugging capabilities of my simulator I get the following:
It may be that everything is due to some SPI control problem of the XPT2046_Touchscreen 1.2.0 library but I think there must be some problem in the initial value of x and how to set the resolution of the screen, in this case 320x240.
Paul or any of the forum gurus can help me?
Thank you for your time and attention.