Drawing FFT spectrum smoothly on TFT

frohr

Well-known member
Hey all,
I have Teensy 4.0 with adxl sensor and I want draw FFT spectrum smoothly in realtime.
Now I use something like:

Code:
x_pos = 0;
for (int k = 0 ; k < 299; k++)
{
tft.drawLine(x_pos,70, x_pos, 70- sensor_value, ILI9341_GREEN);     
 x_pos++;
       if (x_pos > 299)
     {       
       x_pos=0;
     }   
}
tft.fillScreen(ILI9341_BLACK);

Of course, this it wrong and display is blinking. How to re-draw smoothly withou blinking and fast?
I need draw 300 or 780 bars / lines / bins - according TFT size.
One TFT I have is 800x480, RA8875, second TFT is ILI9341, 320x240, both SPI.

examples what I mean:
https://www.youtube.com/watch?v=gJxs3Rm0aTU&ab_channel=BenjaminKBenjaminK
or
https://www.youtube.com/watch?v=Xkov499IYvo&ab_channel=IanWallIanWall

Thanks a lot for help.

Michal
 
Filling the screen every pass is the issue.

You should draw the line to the designated sensor value like you are doing, then in the next line draw a black line from the designated sensor value to the end of the line. This will eliminate flicker. Consider using drawFastVLine, or drawFastHLine.

And it will do something like this (around the 0:20 mark), this code draws boxes, but same concept
https://www.youtube.com/watch?v=tCUUaf6nYE8

Source code at:
https://github.com/KrisKasprzak/SampleCode/blob/master/CanonMicProcessor_05.ino
 
This seems much better than I had before.

Code:
 for (int k = 1 ; k < BUFFER_SIZE ; k++)
  {
  tft.drawFastVLine(k, 99, 100, (ILI9341_BLACK));
  tft.drawFastVLine(k, 100, random(100), (ILI9341_GREEN));
  }

or is anything better?

Thanks
Michal
 
I think you might still see a bit of a flickering problem the key is to start the black line where the green line stopped.
 
Back
Top