LCD TFT with Ili9341 chipset way to slow

Hy Fellows,

I got myself a 320x240 pixel TFT, I want to create a game with it. It has a Ili9341 chip on it.
Now that I got it working, i made some little sketches. I use a "standard" library for it. There are commands like, drawPixel, or drawCircle. I made a little quick and dirty pong for example, but with the standard commands this is all to slow and flickering because for example the "clear" function draws every black pixel for each own, all 320x240. it is not the arduino, it is the way the grafics are drawn. I got the PDF for the display where all commands and registers are shown. There are some commands, where for example you can scroll the stuff in display memory then put it on display. But my experience level is to low for that. Does someone has some advice, for example there is the command: 33h, which you could send by sendCMD(0x33), in the manual it is called Vertical Scroll Definition, and there is a flow-chart for an Continous Scroll, but I don´t understand how to use it. I made a litte sketch, then moved the displayed stuff up ( with command 37h ) . But i am not doing it right, but I saw the effect, it was only moved in DisplayRam, really quick and didn´t need a clear-screen. That would be a speedup if I move everything down 1, then only draw one line instead of clearing and redraw everything seen.

Here is my sketch:

#include <stdint.h>
#include <TFTv2.h>
#include <SPI.h>


void setup()
{   
    TFT_BL_ON;                                          //turn on the background light 
    
    Tft.TFTinit();                                      //init TFT library             
    
    Tft.drawCircle(120,160,50,0xffff);
    Tft.drawCircle(50,50,50,0xff00);
    Tft.drawCircle(190,50,50,0x00ff);
    Tft.drawCircle(50,269,50,0xf00f);
    Tft.drawCircle(190,269,50,0x0ff0);
    
    delay(1000);
    
    Tft.sendCMD(0x37); //Vertical Scrolling Start Adress
    Tft.WRITE_DATA(0x0001);
    Tft.WRITE_DATA(0x0001);
    Tft.sendCMD(0x29); //Display on
}

void loop()
{
}

Any advice is apreciated.
My goal would be a little game, where I need to scroll the stuff on the screen, and have some sprites on it.
Well, maybe it isn´t possible.

Cheers Andre

It's all down to clever programming.

If you erase a graphic by drawing a black square then redraw the graphic somewhere else then it will flicker because there's a moment where the graphic isn't on screen. To fix this you need to draw the graphic in the new position then erase only the part that needs to be erased.

In a pong bat that that moves upwards by two pixels you need to draw two rows of new pixels at the top of the bat then erase two rows of pixels underneath it. If you do it that way it won't flicker at all.

The chip is designed to draw rectangles of pixels (eg text), not single dots. Each rectangle has an overhead of 11 bytes that need to be sent before you can send any pixel data. Drawing a single dot therefore has a lot of overhead (11 bytes of setup, plus a lot of fiddling with I/O pins). If you have a "clear" function that draws 320x240 pixels individually then it will take forever to complete.

I've just been playing around trying to optimize a screen clear function and I can clear the screen about six times per second (which is about as fast as SPI can transfer that much data (6320240*2=921600 bytes/sec)).

The three commands you really need for drawing are 0x2a, 0x2b and 0x2c. All the rest are just for setting up the screen.

fungus,

why haven't i thought of placing (filled) rectangles on the screen to cover up the changing text.
Thank you for your answer. It really helped me.