Hi Defrayster, I have referenced a long thread back in 2016 started by Duncabar inwhich he posted the same problem of not being able to play audio SD along with TFT 2.8 Touchscreen ili9241_t3 lib (see
https://forum.pjrc.com/threads/34424-Teensy-3-2-with-Audio-Board-and-ILI9341-2-8-inch-Touch-Screen). Not sure if that is the same as the XPT2046 issue I am having, but maybe so. Anyway, several things were stated in the thread concerning the SPI mapping/connections and that is one thing I am still confussed about. In the original Tutorial Part 3-3: the TFT Display uses the MOSI=7, MISO=12 and SCLK=14. However, Duncabar change his usage of the Audio Board to the Wiz820 and used the normal MISO=12, MOSI=11 and SCK=13. So if I stay with Paul's original code using the audio board and ili9241/xpt2046 combination, do I stay with the original pin mapping?
Secondly, the partial code below starts to execute but gets stuck in the SD card while loop at the end. Do you see any reason for this? Is there a issue with the order in which the SD card is executed relative to the pin and labruary declarations? This code works with the exclusion of the XPT2036 references.
// Advanced Microcontroller-based Audio Workshop
// Commented out guitar code per defragster form post suggestion
// Part 3-1: Fourier Transform
//Last Change Date: 1/5/2016 Time: 14:13
#include <Bounce.h>
//#include "AudioSampleGuitar.h"
Bounce button0 = Bounce(0, 15);
Bounce button1 = Bounce(1, 15); // 15 = 15 ms debounce time
Bounce button2 = Bounce(3, 15);
//int ledPins[] = {6}; //Set LED for transmission indicator
///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////
#include <XPT2046_Touchscreen.h> //New
#include <ILI9341_t3.h>
#include <font_Arial.h> // from ILI9341_t3
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=254,251
AudioPlaySdWav playSdWav1; //xy=257,155
AudioMixer4 mixer1; //xy=454,195
AudioOutputI2S i2s1; //xy=622,168
AudioAnalyzeFFT1024 fft1024_1; //xy=629,211
AudioConnection patchCord1(waveform1, 0, mixer1, 3); //Sine wave actuated by button 3
AudioConnection patchCord2(waveform1, 0, mixer1, 2); //Sine wave actuated by button 2 (random)
AudioConnection patchCord3(playSdWav1, 0, mixer1, 0); //SD card sterio input
AudioConnection patchCord4(playSdWav1, 1, mixer1, 1); //SD card sterio input
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer1, 0, i2s1, 1);
AudioConnection patchCord7(mixer1, fft1024_1);
AudioControlSGTL5000 sgtl5000_1; //xy=466,287
// GUItool: end automatically generated code
char freq[2]; //Create frequency bin #
char avalue[2]; //Create audio FP string array
int freqamp; //Create int variable for freq float
const int audioprc = 6; //Create processed output pin
int audval[32]; //Initialize audio int value array
int ch1audval = 0;
int ch2audval = 0;
int ch3audval = 0;
int ch4audval = 0;
int ch5audval = 0;
int ch6audval = 0;
int ch7audval = 0;
int ch8audval = 0;
int rcvflag = 0; //Set receive flag pin
int audioflag = 0; //Create audio received flag
// SPI COMMON assumed :: MOSI=11, MISO=12, SCK=13
//#define TFT_CS 10
//#define TFT_DC 9
#define TFT_DC 20
#define TFT_CS 21
#define TFT_RST 255 // 255 = unused, connect to 3.3V
#define TFT_MOSI 7
#define TFT_SCLK 14
#define TFT_MISO 12
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);
// set this to the hardware serial port you wish to use
#define SIZE 10 //Was 10
elapsedMillis msecs;
int height = 20; //Set mode button height
int Audmode = 0;
int Seqmode = 0;
int Ranmode = 0;
int Cnvmode = 0;
int Hltmode = 0;
int Spmode = 0;
//const int audioprc = 3; //Create processed output pin
#define CS_PIN 8
#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(9600); //SERIAL USB buad rate
while ( !Serial && (millis() < 3000));
pinMode(audioprc, OUTPUT); //Transmit flag
// delay(500);
ts.begin(); //Added for touch display
tft.begin();
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.setFont(Arial_10);
tft.setTextSize(3);
tft.setCursor(40, 8);
tft.println("LIGHTING CONTROL");
AudioMemory(10);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(7);
SPI.setSCK(14);
if (!(SD.begin(10))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}