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

Thread: Drawing FFT spectrum smoothly on TFT

Hybrid View

  1. #1
    Member
    Join Date
    Nov 2020
    Location
    Czech Republic
    Posts
    45

    Drawing FFT spectrum smoothly on TFT

    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=gJxs...aminKBenjaminK
    or
    https://www.youtube.com/watch?v=Xkov...IanWallIanWall

    Thanks a lot for help.

    Michal

  2. #2
    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/Samp...ocessor_05.ino

  3. #3
    Member
    Join Date
    Nov 2020
    Location
    Czech Republic
    Posts
    45
    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

  4. #4
    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.

Posting Permissions

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