High speed vector graphics engine. 3.2" TFT Lcd screen.

Here is my UTFT version with optimizations speed of execution and ROM space used.

BE CAREFUL : It's work only with SSD1289 screen on Arduino Mega.
Screen : SainSmart 3.2" TFT LCD Display+Touch Panel+PCB adapter SD Slot for Arduino 2560,
Shield : SainSmart TFT LCD Adjustable Shield for Arduino Mega 2560 R3 1280 A082 Plug.

To optimize I examined the most frequently used functions.
For example:
drawPixel calls SetXY, SetXY makes a test on the target screen and calls LCD_Write_COM, it calls LCD_Write_COM and LCD_Write_DATA, they test the type of transfer and call LCD_Writ_Bus. LCD_Writ_Bus tests the type of target screen and then writes the data to the destination ports of the screen !!!
LCDxxx methods are called very often then it is they need to optimize.
I remove the tests "switch (mode)" or "if (display_transfer_mode! = 1)", which become useless if I still have the same screen.
I'm simplifying and removing cascades calls are expensive (passing parameters to the stack, context switching, etc.).

In the zip archive, I put a new example : Bench.ino (use this one to test), I removed some tools.

I also made a mode "x terminal" which sending display information to the serial port.
I wrote a program (in C #) that runs on the PC, he receives display information and draws on the PC screen: this is a simulator screen.
I left this feature in the code archive. It is off by a compiler directive (so this code is disabled).
Example :

void UTFT::drawPixel(int x, int y)
{
//don't worry about this code. this code is not compiled (Terminal_x not defined)
#ifdef TERMINAL_X
  //terminal x
  //0x81 [ID], [size], [datas]  
  uint8_t Trame[7];
  Trame[0] = 0x81; //ID de Terminal X
  Trame[1] = sizeof(Trame)-1; //taille de la sous-trame (à partir de cet endroit, on compte la size mais pas l'ID termX
  Trame[2] = TX_DRAWPIXEL; //ID ordre d'aff pixel
  Trame[3] = x >> 8; //MSB x1
  Trame[4] = x; //LSB x1
  Trame[5] = y >> 8;
  Trame[6] = y; 
  Serial.write(Trame, sizeof(Trame));
  //return;
#endif
...

If anyone is interested, I can share my C # program...
I preferred share code in the current state, because if I take the time to clean it before, it will never be perfect and finally I will send nothing :wink:

Finally, Perhaps the best is make a depot GIT.
I hope that pYro_65 will could give us his optimizations or ideas for a common version. :slight_smile:

(Sorry if I speak bad English, I took lessons :wink: )

bye.
Maël.

UTFT.zip (161 KB)