Hello!
I am currently working on a project where I want to use Audio Shield's synthesizer capabilities to generate custom waves. For the waves I already bought a Touch Screen Display (2.8 Inch ILI9341 240x320 SPI TFT LCD Display Touch Panel SPI Serial Port Module v1.2). I have no problems understanding how the Audio Shield works but I cant seem to work out how to use the Display with my Teensy 4.0. I tried every kind of examples but almost none of them works. An error I often get is: Error compiling for board Teensy 4.0. I would really appreciate any kind of help! I want the values of the drawn wave in an array, so that I can use my Audio Shield to interpret it as a sound wave.

It's a code I can run on Teensy and I can actually see the color-rectangles. No touch-draw function though..

Code:
/***************************************************

This is our GFX example for the Adafruit ILI9341 Breakout and Shield
  ----> http://www.adafruit.com/products/1651
 
  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!
 
  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************
 
  This is a free software with NO WARRANTY.
  https://simple-circuit.com/
 
 ****************************************************/
 
 
#include <Adafruit_GFX.h>       // include Adafruit graphics library
#include <Adafruit_ILI9341.h>   // include Adafruit ILI9341 TFT library
#include <SPI.h>
#include <Wire.h>      // this is needed even tho we aren't using it

#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000 
#define TFT_CS    8      // TFT CS  pin is connected to arduino pin 8
#define TFT_RST   9      // TFT RST pin is connected to arduino pin 9
#define TFT_DC    10     // TFT DC  pin is connected to arduino pin 10
#define TIRQ_PIN  2

// initialize ILI9341 TFT library
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;
 
void setup() {
  Serial.begin(38400);
  Serial.println("ILI9341 Test!"); 
 
  tft.begin();
 
  // read diagnostics (optional but can help debug problems)
  uint8_t x = tft.readcommand8(ILI9341_RDMODE);
  Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDMADCTL);
  Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDPIXFMT);
  Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDIMGFMT);
  Serial.print("Image Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(ILI9341_RDSELFDIAG);
  Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); 


  tft.fillScreen(ILI9341_BLACK);
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);

  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
  currentcolor = ILI9341_RED;
}
 
 
void loop(void) {

}

My step sequencer code:

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform2;      //xy=161,336
AudioSynthWaveform       waveform3;      //xy=161,367
AudioSynthWaveform       waveform4;      //xy=161,398
AudioSynthWaveform       waveform1;      //xy=162,304
AudioEffectEnvelope      envelope4;      //xy=297,396
AudioEffectEnvelope      envelope3;      //xy=299,366
AudioEffectEnvelope      envelope1;      //xy=301,303
AudioEffectEnvelope      envelope2;      //xy=301,334
AudioMixer4              mixer1;         //xy=439,347
AudioOutputI2S           i2s1;           //xy=633,351
AudioConnection          patchCord1(waveform2, envelope2);
AudioConnection          patchCord2(waveform3, envelope3);
AudioConnection          patchCord3(waveform4, envelope4);
AudioConnection          patchCord4(waveform1, envelope1);
AudioConnection          patchCord5(envelope4, 0, mixer1, 3);
AudioConnection          patchCord6(envelope3, 0, mixer1, 2);
AudioConnection          patchCord7(envelope1, 0, mixer1, 0);
AudioConnection          patchCord8(envelope2, 0, mixer1, 1);
AudioConnection          patchCord9(mixer1, 0, i2s1, 0);
AudioConnection          patchCord10(mixer1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=289,51
// GUItool: end automatically generated code

int b1 = 0;
int b2 = 0;
int b3 = 0;
int b4 = 0;

float att1 = 200;
float dec1 = 200;
float sus1 = 200;
float rel1 = 200;

float att2 = 200;
float dec2 = 200;
float sus2 = 200;
float rel2 = 200;

float att3 = 200;
float dec3 = 200;
float sus3 = 200;
float rel3 = 200;

float att4 = 200;
float dec4 = 200;
float sus4 = 200;
float rel4 = 200;

float att = 200;
float dec = 200;
float sus = 200;
float rel = 200;


int led12 = 12;
int led11 = 11;
int led10 = 10;
int led8 = 8;

int amp1 = 1;
int amp2 = 1;
int amp3 = 1;
int amp4 = 1;

int freq1 = 500;
int freq2 = 700;
int freq3 = 900;
int freq4 = 1100;

float fourth = 1.0 / 4.0;
float one_sixth = 1.0 / 6.0;
int bpm = 120;
int modulo = 1000 * (60.0 / bpm); // in milli
// int fourth_modulo = fourth * modulo;
int previousA2 = 0; // previously sent poti values, to detect changes
int minBPM = 30;
int maxBPM = 220;

const int numReadings = 5;     // Anzahl der Readings
int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int inputPin = A1;              // Analog input
int average_bpm = 0;
int average_bpm_alt = 0;

void setup() {
  Serial.begin(38600); // 38600 symbols per second
  pinMode(led12, OUTPUT);
  pinMode(led11, OUTPUT);
  pinMode(led10, OUTPUT);
  pinMode(led8, OUTPUT);

  pinMode(1, INPUT_PULLUP); // b1
  pinMode(2, INPUT_PULLUP); // b2
  pinMode(3, INPUT_PULLUP); // b3
  pinMode(4, INPUT_PULLUP); // b4

  AudioMemory(20);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.4);
  mixer1.gain(0, 0.03);
  mixer1.gain(1, 0.03);
  mixer1.gain(2, 0.03);
  mixer1.gain(3, 0.03);
  waveform1.begin(WAVEFORM_SINE); // WAVE 1
  waveform1.amplitude(amp1);
  waveform1.frequency(freq1);
  waveform2.begin(WAVEFORM_SINE); // WAVE 2
  waveform2.amplitude(amp2);
  waveform2.frequency(freq2);
  waveform3.begin(WAVEFORM_SINE); // WAVE 3
  waveform3.amplitude(amp3);
  waveform3.frequency(freq3);
  waveform4.begin(WAVEFORM_SINE); // WAVE 4
  waveform4.amplitude(amp4);
  waveform4.frequency(freq4);

}
void loop() {

  int att = analogRead(A2);
  int dec = analogRead(A0);
  int rel = analogRead(A4);
  int sus = analogRead(A3);

  ADSR(att, dec, rel, sus);

  // ----------------- SMOOTHING TEMPLATE -----------------

  static float bpm = {120}; // wird wegen static nur einmal initialisiert
  int modulo = 1000 * (60.0 / average_bpm); // in milli
  int fourth_modulo = fourth * modulo;
  int n1 = analogRead(A1);
  int current_time = millis();
  int modulo_time = current_time % modulo;

  // subtract the last reading:
  total = total - readings[readIndex] ; // Alle Analoge inputwerte zusammenaddiert, wobei der Wert der neuen Loop abgezogen wird (zieht den nullten Wert ab)
  // read from the sensor:
  readings[readIndex] = analogRead(inputPin);

  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;

    // calculate the average:
    average = total / numReadings;
    average_bpm = map(average, 0, 1023, 50, 280);
    if (average_bpm != average_bpm_alt) {
      // Serial.println(average_bpm);

    }
    average_bpm_alt = average_bpm;
    Serial.println(average_bpm);
  


  // ----------------- MODULO BASED SEQUENCER -----------------
  if (modulo_time == 0) {
    digitalWrite(led12, HIGH);
    digitalWrite(led8, LOW);

    envelope4.noteOff();
    envelope1.noteOn();

    waveform1.amplitude(amp1);
    waveform1.frequency(freq1);

  }
  else if (modulo_time == fourth_modulo) {
    digitalWrite(led12, LOW);
    digitalWrite(led11, HIGH);

    envelope1.noteOff();
    envelope2.noteOn();

    waveform2.amplitude(amp2);
    waveform2.frequency(freq2);

  }
  else if (modulo_time == 2 * fourth_modulo) {
    digitalWrite(led11, LOW);
    digitalWrite(led10, HIGH);

    envelope2.noteOff();
    envelope3.noteOn();

    waveform3.amplitude(amp3);
    waveform3.frequency(freq3);

  }
  else if (modulo_time == 3 * fourth_modulo) {
    digitalWrite(led10, LOW);
    digitalWrite(led8, HIGH);

    envelope3.noteOff();
    envelope4.noteOn();

    waveform4.amplitude(amp4);
    waveform4.frequency(freq4);
  }
}
}