Audio adaptor boad + ST7735 (Using hardware SPI)

Status
Not open for further replies.

Stendall

Well-known member
Hi guys,

I have lying around some ST7735 TFTs (160x128), some Teensys 3.1 and one Teensy audio adaptor boad.
I've been trying to build up some kind of realtime audio spectrum view. Like this:
View attachment 3478

With less resolution and acuracy, but you get the idea.
This is the TFT module:
View attachment 3479
I'm stuck trying to drive the TFT display (using hardware SPI) when the Teensy has the companion audio board attached.
I can't find the correct pins configuration for the TFT while using the audio board so it doesn't interfere.

Code:
// Default pins in the ST7735 Examples.
// No audio data in myFFT.read().                                                                                  <------------------
#define sclk 13  // SCLK can also use pin 14
#define mosi 11  // MOSI can also use pin 7
#define cs   10  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define dc   9   //  but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define rst  8   // RST can use any pin

/* Alternate Pins. I think are correct but the display don't work with this ones.
#define sclk 14  //SCLK can also use pin 14+
#define mosi 7   //MOSI can also use pin 7
#define cs   2   //CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define dc   6   //but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define rst  8   //RST can use any pin
*/

#define DISPLAY_WIDTH 128
#define DISPLAY_HEIGHT 160

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>  
#include <Adafruit_ST7735.h>

Adafruit_ST7735 display = Adafruit_ST7735(cs, dc, rst);

AudioInputI2S          audioInput;         // audio shield: mic or line-in
AudioAnalyzeFFT256      myFFT;
AudioConnection        patchCord1(audioInput, myFFT);
AudioControlSGTL5000   audioShield;

void setup()   {   
  display.initR(INITR_REDTAB);
  display.fillScreen(ST7735_BLACK);
  AudioMemory(12);
  audioShield.enable();
  audioShield.inputSelect(AUDIO_INPUT_MIC);
  myFFT.windowFunction(AudioWindowHanning256);
}

/********************************************/

void loop (){  
  float n;
  int i;
  if (myFFT.available())
    for (i=1; i<128; i++) {
      n = myFFT.read(i);
      display.drawFastVLine(i,0,DISPLAY_HEIGHT,ST7735_BLACK);
      display.drawFastVLine(i,0,n*DISPLAY_HEIGHT,ST7735_WHITE);
    }
}

So far I've know there's only one SPI port in the teensy 3.1 with some alternate pins avalaible (and a lot of CS).
I think that audio board do not use SPI apart from SD socket and the W25Q128FV memory. So I've tried without luck the pins (among others) 14 (sck) , 7(mosi) , 6(cs), 15(dc) and 4(rst).

I'm sure I am doing something terribly wrong. Any enlightenment will be greatly apreciated.

Luis M. Ruiz
 
Thank you cartere.
I've tried but still don't work. The display just lights up.
The ST7735 constructor won't take 2 parameters like the example (ILI9341_t3(TFT_CS, TFT_DC)). The display it's a ST7735;
And with 3 parameters and RST assigned to any free pin (pin 4) fails too.
Code:
#define sclk 14  // SCLK can also use pin 14
#define mosi 7  // MOSI can also use pin 7
#define cs   21  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define dc   20   //  but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define rst  4   // RST can use any pin

Adafruit_ST7735 display = Adafruit_ST7735(cs, dc, rst);
I've used the asignement functions of the example in the setup block:
Code:
SPI.setMOSI(7);
SPI.setSCK(14);

I've tryed with rst connected to 3.3v and reconect the microusb plug.
 
Sorry to bump up this oldie, but I still don't give up on using ST7735 tft (hardware SPI) and audio shield at the same time.
The problem is that there's no begin() function on ST7735 library and I can't call SPI.setMOSI() and SPI.setSCK() outside the setup block.
Someone has a working code example on ST7735 (hardware SPI) and audio shield working together?.
Thanks.
 
Status
Not open for further replies.
Back
Top