Dionysus
Active member
In November of 2018 there was a post about an SPI conflict between the audio sheild and the touchscreen. Has anything changed since then? It sounds like folks are getting touchscreens to work with the audio board, right?
I'm posting my modified TouchTest code—I just added in the Audio library and a I2S object. When I comment those lines out, it works fine. With them in there, it prints a bunch of garbage data and then freezes up. Hopefully I've just missed an obvious thing? Thanks!
I'm posting my modified TouchTest code—I just added in the Audio library and a I2S object. When I comment those lines out, it works fine. With them in there, it prints a bunch of garbage data and then freezes up. Hopefully I've just missed an obvious thing? Thanks!
Code:
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#include <Audio.h>
AudioOutputI2S i2s1; //xy=994,343
#define CS_PIN 14
// MOSI=11, MISO=12, SCK=13
//XPT2046_Touchscreen ts(CS_PIN);
#define TIRQ_PIN 1
//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.tirqTouched()) {
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();
}
}