I try to build something on a Cheap Yellow Display device. So far, I have programmed the display
and reading a file from a SD-Card
.
I now want to use Touch
, but have some issues. I always read the maximum values, event if it's not touched at all.
I assume it's because the SPI
for accessing the SD-Card. I was able to run an example TouchTest sketch, but when I add the same code to my main sketch it's not working.
There's also some hint that the sd-card is using VSPI while the display is using HSPI (no idea, if that has something to do with my issue).
Here's the extract (which I assume is part of the issue):
#include <SPI.h>
#include <SD.h>
#include <XPT2046_Touchscreen.h>
#include <TFT_eSPI.h>
#define XPT2046_IRQ 36
#define XPT2046_MOSI 32
#define XPT2046_MISO 39
#define XPT2046_CLK 25
#define XPT2046_CS 33
SPIClass touchSpi = SPIClass(VSPI);
XPT2046_Touchscreen ts(XPT2046_CS, XPT2046_IRQ);
TFT_eSPI tft = TFT_eSPI();
void setup() {
// TOUCH
touchSpi.begin(XPT2046_CLK, XPT2046_MISO, XPT2046_MOSI, XPT2046_CS);
ts.begin(touchSpi);
ts.setRotation(1);
// TFT_eSPI
tft.init();
tft.setRotation(1);
if (SD.begin(5) && SD.exists("/setlist.csv")) {
// …
}
}
void loop() {
if (ts.tirqTouched() && ts.touched()) {
TS_Point p = ts.getPoint();
printTouchToSerial(p);
delay(100);
}
}
void printTouchToSerial(TS_Point p) {
Serial.print("Pressure = ");
Serial.print(p.z);
Serial.print(", x = ");
Serial.print(p.x);
Serial.print(", y = ");
Serial.print(p.y);
Serial.println();
}
The output is always:
Pressure = 4095, x = 8191, y = 8191
I pushed my changes to gitlab (or take a look at the changeset) for the full source-code.
I'd be happy for some ideas.