Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 4 - FFT1024 from audiolib and ILI9341 display not work

  1. #1
    Junior Member
    Join Date
    Jun 2020
    Posts
    8

    Teensy 4 - FFT1024 from audiolib and ILI9341 display not work

    It seems to work - how can I delete the thread?
    SORRY!!!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,271
    I tested with Teensyduino 1.53, and using ILI9341_t3 since I don't currently have ILI9341_t3n installed.

    I can't reproduce the problem. Audio flows through. I added some printing in loop() and indeed it keeps printing to the serial monitor. This is the exact code I'm running.

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include "SPI.h"
    #include <ILI9341_t3.h>
    
    #define TFT_RST  255
    #define TFT_DC   9
    #define TFT_CS   10
    
    ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST);
    
    // GUItool: begin automatically generated code
    AudioInputI2S            i2s1;           //xy=233,172
    AudioMixer4              mixer1;         //xy=433,245
    AudioOutputI2S           i2s2;           //xy=434,173
    AudioAnalyzeFFT1024      fft1024_1;      //xy=583,245
    AudioConnection          patchCord1(i2s1, 0, mixer1, 0);
    AudioConnection          patchCord2(i2s1, 0, i2s2, 0);
    AudioConnection          patchCord3(i2s1, 1, mixer1, 1);
    AudioConnection          patchCord4(i2s1, 1, i2s2, 1);
    AudioConnection          patchCord5(mixer1, fft1024_1);
    AudioControlSGTL5000     sgtl5000_1;     //xy=245,262
    // GUItool: end automatically generated code
    
    
    void setup(void) {
      AudioMemory(20);
      sgtl5000_1.enable();
      sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
      sgtl5000_1.volume(.5);
    
      tft.begin();
      tft.fillScreen(ILI9341_WHITE);
      tft.setTextColor(ILI9341_BLACK, ILI9341_WHITE);
      tft.setTextSize(2);
      tft.setCursor(0, 0);
      tft.print("TEST");
    }
    
    void loop() {
      static int count=0;
      Serial.printf("count = %d, CPU = %.2f\n", count++, AudioProcessorUsage());
      delay(250);
    }sc
    Here's what I see in the serial monitor. And I'm hearing the line in audio on my headphones.

    Click image for larger version. 

Name:	sc.png 
Views:	4 
Size:	65.5 KB 
ID:	20836

    Please check which version of Teensyduino you're using. In Arduino, click Help > About (or Teensyduino > About if Macintosh) to see the installed version.

    If it's older than 1.53, maybe try installing 1.53.

  3. #3
    Junior Member
    Join Date
    Jun 2020
    Posts
    8
    Dear Paul,

    yes, I use Teensyduino 1.53.
    The bug was sitting in front of the monitor ;o)
    My display does not have a CS connector and there I specified pin 255 in the declaration - that was an error.
    In other programs this works without problems, but with the FFT the program stopped.
    Now I have declared pin 10, but not connected - it works!
    But the waterfall looks a bit strange on the display.

    This works:
    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include "SPI.h"
    #include <ILI9341_t3n.h>
    
    #define TFT_RST  255
    #define TFT_DC   9
    #define TFT_CS   10
    
    static int count = 0;
    static uint16_t line_buffer[320];
    static float scale = 10.0;
    
    ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST);
    
    // GUItool: begin automatically generated code
    AudioInputI2S            i2s1;           //xy=233,172
    AudioMixer4              mixer1;         //xy=433,245
    AudioOutputI2S           i2s2;           //xy=434,173
    AudioAnalyzeFFT1024      fft1024_1;      //xy=583,245
    AudioConnection          patchCord1(i2s1, 0, mixer1, 0);
    AudioConnection          patchCord2(i2s1, 0, i2s2, 0);
    AudioConnection          patchCord3(i2s1, 1, mixer1, 1);
    AudioConnection          patchCord4(i2s1, 1, i2s2, 1);
    AudioConnection          patchCord5(mixer1, fft1024_1);
    AudioControlSGTL5000     sgtl5000_1;     //xy=245,262
    // GUItool: end automatically generated code
    
    
    void setup(void) {
    	AudioMemory(20);
    	sgtl5000_1.enable();
    	sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
    	sgtl5000_1.volume(.5);
    
    	tft.begin(50000000);
    	tft.setRotation(2);
    	tft.fillScreen(ILI9341_WHITE);
    	tft.setTextColor(ILI9341_BLACK, ILI9341_WHITE);
    	tft.setTextSize(2);
    	tft.setCursor(0, 0);
    	tft.print("TEST");
    }
    
    void loop() {
    	if (fft1024_1.available()) {
    		for (int i = 0; i < 240; i++) {
    			line_buffer[240 - i - 1] = colorMap(fft1024_1.output[i]);
    		}
    		tft.writeRect(0, count, 240, 1, (uint16_t*)&line_buffer);
    		tft.setScroll(count++);
    		count = count % 320;
    	}
    }
    
    uint16_t colorMap(uint16_t val) {
    	float red;
    	float green;
    	float blue;
    	float temp = val / 65536.0 * scale;
    
    	if (temp < 0.5) {
    		red = 0.0;
    		green = temp * 2;
    		blue = 2 * (0.5 - temp);
    	}
    	else {
    		red = temp;
    		green = (1.0 - temp);
    		blue = 0.0;
    	}
    	return tft.color565(red * 256, green * 256, blue * 256);
    }
    Best regards
    Bruno

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,271
    Glad you found the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •