Audio and ILI9341_t3 library conflict

Status
Not open for further replies.

CapranDreams

New member
I am using a Teensy 3.6 and trying to use both the audio library with the touchscreen tft lcd library. I have the Color 320x240 TFT Touchscreen and am following the hookup instructions on that page under "Usage With Audio Board Connections". For the audio side, I am using Audio Adaptor Board for Teensy connected to an amplifier from Adafruit which is then connected to a small 4ohm speaker.

Uploading the example sketches from the Arduino IDE to the Teensy for both the LCD and the Audio work fine and as expected. Even combining them they are fine so long as I do the LCD stuff before the audio stuff. The problem begins the moment I try to change the LCD after initializing the Audio board. The problem manifests as the speaker playing a screeching noise or farting noise sometimes before becoming screeching. The tone sounds different each time but I don't have a trained ear to resolve this.

I assume that these have been used together since there is a note about changing pins on the website but can't seem to figure this one out. I have simplified the sketch into the below code for people to reproduce. Any suggestions? :confused:

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

#include "AudioSampleGong.h"  // sample file from example "SamplePlayer"

#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);

AudioPlayMemory    sound4;
AudioMixer4        mix2;  
AudioOutputI2S     headphones;
AudioConnection    c6(sound4, 0, mix2, 1);
AudioConnection    c8(mix2, 0, headphones, 0);
AudioControlSGTL5000 audioShield;


void setup() {
  tft.begin();
  tft.setRotation(0);
  tft.fillScreen(ILI9341_BLACK);
 
  AudioMemory(10);
  audioShield.enable();
  audioShield.volume(0.4);
  mix2.gain(1, 0.4);
}

void loop() {
    sound4.play(AudioSampleGong);
    delay(1000);
    Serial.println("test point 1");
    tft.fillScreen(ILI9341_GREEN);  // problem begins on this line
    delay(1000);
    Serial.println("test point 2");
}
 
For a working example, take a look at the last part of the audio tutorial.

https://www.pjrc.com/store/audio_tutorial_kit.html

That part starts on page 30 of the PDF. In the walkthrough video, you can see it working starting at 45:30. The tutorial code is available in Arduino by clicking File > Examples > Audio > Tutorial.

You can see it definitely does update the display with those 2 level bars & text, while the audio library is also using the same SPI pins to access the SD card, and of course playing the sound through the audio shield. Hopefully a known good example helps?
 
I read through the tutorial (very good tutorials btw!) and started with the Part_3_03_TFT_Display sketch. I do not have an SD on hand so I had to change it to read from memory. Unfortunately, I saw the same screeching behavior. Since I did change it to play from memory, maybe that is different? I will hunt down an SD to try that next.
 
Status
Not open for further replies.
Back
Top