Show Posts
Pages: [1]
1  Community / Exhibition / Gallery / Re: High speed vector graphics engine. 3.2" TFT Lcd screen. on: March 28, 2013, 10:02:15 am
And you can optimize :
Replace "delayMicroseconds(1);" by many "__asm__("nop\n\t");"
try until it's work. I need 3 nop, perhaps for you it's 4 or 5.
2  Community / Exhibition / Gallery / Re: High speed vector graphics engine. 3.2" TFT Lcd screen. on: March 28, 2013, 05:27:43 am
Hi Rivinoo,

With the original lib, do you use this constructor "UTFT myGLCD(ITDB32S,38,39,40,41);" ?
Youre screen is really ITDB32S compatible ?

If it's, I think it's a timming problem.
Try this :
Edit HW_AVR_defines.h
change this line :
Code:
#define pulse_low_WR PORTG &= ~(1<<2); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); PORTG |= (1<<2)
by it :
Code:
#define pulse_low_WR PORTG &= ~(1<<2); delayMicroseconds(1); PORTG |= (1<<2)
3  Community / Exhibition / Gallery / Re: High speed vector graphics engine. 3.2" TFT Lcd screen. on: March 28, 2013, 04:27:37 am
Salut Vincent,
Les forums internationaux sont souvent plus intéressant et riches, en plus ils nous font bosser notre anglais smiley-wink

I've the same result than you before I replace macros. Now I can't optimize more.
pYro_65 certainly has the best results.
pYro_65, what do you think about these times ? have you try the bench ? Are you here ? smiley
4  Community / Exhibition / Gallery / Re: High speed vector graphics engine. 3.2" TFT Lcd screen. on: March 27, 2013, 09:11:59 am
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 :

Code:
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  smiley-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. smiley

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

bye.
Maël.
5  Community / Exhibition / Gallery / Re: High speed vector graphics engine. 3.2" TFT Lcd screen. on: March 27, 2013, 05:42:58 am
this is Icon.h

And I'm preparing a zip archive of my UTFT version.
Maël.
6  Community / Exhibition / Gallery / Re: High speed vector graphics engine. 3.2" TFT Lcd screen. on: March 27, 2013, 05:38:27 am
This is my bench sketch :

Code:
//Bench.ino
//Maël - 01/03/2013
//Mesure le temps de différentes methodes des lib UTFT et UTouch et envoi les temps sur le port Serie (115200 bauds)

#include <UTFT.h>
#include <UTouch.h>

#include "icon.h"

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];

// Tft, touchscreen for Arduino Mega
UTFT myGLCD(ITDB32S,38,39,40,41);  
UTouch myTouch(6,5,4,3,2);

extern unsigned int icon[0x400];

//pointeur de fonction simple
typedef void TFunction(void);

typedef struct  
{
  TFunction * process; //pointeur sur la methode à chronometrer
  String text;         //nom du test (apparaitra sur la console)
} TProcessInfo;

void InitTFT()
{
// Setup the LCD, touch screen
  myGLCD.InitLCD(LANDSCAPE);
  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_LOW); //PREC_MEDIUM
  
  myGLCD.clrScr();
}

void MeasureDrawPixel(void)
{
  myGLCD.drawPixel(0,0);
}

void MeasureDraw10Pixels(void)
{
  for (int i = 0; i < 10; i++)
    myGLCD.drawPixel(i,i);
}

void MeasureSetColor()
{
  myGLCD.setColor(255, 255, 255);
}

void MeasureSetBackColor()
{
  myGLCD.setBackColor(64, 64, 64);
}

void MeasureFillRoundRect()
{
  myGLCD.fillRoundRect(10, 10, 50, 50);
}

void MeasureDrawRoundRect()
{
  myGLCD.drawRoundRect(110, 10, 150, 50);
}

void MeasureDrawLine()
{
  myGLCD.drawLine(210, 10, 250, 50);
}

void MeasureDrawVLine()
{
  myGLCD.drawLine(270, 10, 270, 50);
}

void MeasureDrawHLine()
{
  myGLCD.drawLine(230, 20, 270, 20);
}

void MeasureFillRect()
{
  myGLCD.fillRect(100, 100, 50, 150);
}

void MeasureSetSmallFont()
{
  myGLCD.setFont(SmallFont);
}

void MeasurePrintText()
{
  myGLCD.print("001", 1, 1);    
}

void MeasurePrintTextAbc()
{
  myGLCD.print("Abc", 1, 1);    
}

void MeasureSetBigFont()
{
  myGLCD.setFont(BigFont);
}

void MeasureclrScr()
{
  myGLCD.clrScr();
}

void MeasureBitmap()
{
 myGLCD.drawBitmap (200, 10, 32, 32, icon);
}

void MeasurePrintNum()
{
  int num = 123;
  myGLCD.printNumI(num, 200, 100);
}

void MeasureTouch_dataAvailable()
{
  boolean b = myTouch.dataAvailable();
}

void MeasureTouch_read()
{
  myTouch.read();
}

void MeasureTouch_getxy()
{
  int x=myTouch.getX();
  int y=myTouch.getY();
}

//Liste des méthodes à mesurer
#define LIST_COUNT 22
TProcessInfo ListOfMeasures[LIST_COUNT] = {
  { MeasureclrScr, "clrScr" },
  { MeasureDrawPixel, "DrawPixel" },
  { MeasureDraw10Pixels, "DrawPixel x 10" },
  { MeasureSetColor, "SetColor" },
  { MeasureSetBackColor, "SetBackColor" },
  { MeasureFillRoundRect, "FillRoundRect 40x40" },
  { MeasureDrawRoundRect, "DrawRoundRect 40x40" },
  { MeasureDrawLine, "drawLine 40x40" },
  { MeasureDrawVLine, "draw Vertical Line 40" },
  { MeasureDrawHLine, "draw Horizontal Line 40" },
  { MeasureFillRect, "FillRect 40x40" },
  { MeasureSetSmallFont, "SetSmallFont" },
  { MeasurePrintText, "Print 001" },
  { MeasurePrintTextAbc, "Print Abc" },
  { MeasurePrintNum, "printNumI(123)" },
  { MeasureSetBigFont, "SetBigFont" },
  { MeasurePrintText, "Print 001" },
  { MeasurePrintNum, "printNumI(123)" },
  { MeasureBitmap, "draw bitmap 32x32" },
  //Mesure des optimisations sur UTouch (en debogage)
  { MeasureTouch_dataAvailable, "Touch Screen DataAvailable"},
  { MeasureTouch_read, "Touch Screen Read"},
  { MeasureTouch_getxy, "Touch Screen getX, getY"}
  };

void Measure()
{
  Serial.println("start...");
  unsigned long ChronoAll = micros();
  for (int i = 0; i < LIST_COUNT; i++)
  {
    if ( ListOfMeasures[i].process != NULL)
    {
      unsigned long ChronoOne = micros();
      ListOfMeasures[i].process();
      ChronoOne = micros() - ChronoOne;
      Serial.print(ChronoOne, DEC);
      Serial.print(" us : ");
      Serial.println(ListOfMeasures[i].text);
    }
  }
  ChronoAll = micros() - ChronoAll;
  Serial.print("finish in ");
  Serial.print(ChronoAll, DEC);
  Serial.println(" us.");
}

void setup()
{
  Serial.begin(115200);
  Serial.println("ready.");
  InitTFT();
  
  Measure();
}

void loop()
{
}

Maël.
7  Community / Exhibition / Gallery / Re: High speed vector graphics engine. 3.2" TFT Lcd screen. on: March 26, 2013, 12:00:45 pm
hi mael,

already done on my side to clean all the unnecessary code in UTFT  smiley-grin

but still far of what this post promise .
Hi Vincent13,
I coded a workbench to compare my optimizations with the original version.
Here are my results :
Code:
start...
Initial version time - optimized version time - opération
724576 us     - 37248 us   : clrScr
200 us        - 24 us      : DrawPixel
2020 us       - 232 us     : DrawPixel x 10
4 us          - 4          : SetColor
4 us          - 4          : SetBackColor
19856 us      - 5804 us    : FillRoundRect 40x40
2652 us       - 636 us     : DrawRoundRect 40x40
4928 us       - 916 us     : drawLine 40x40
604 us        - 152 us     : draw Vertical Line 40
612 us        - 144 us     : draw Horizontal Line 40
27836 us      - 1480 us    : FillRect 40x40
8 us          - 8          : SetSmallFont
7764 us       - 2300 us    : Print 001
7640 us       - 2300 us    : Print Abc
7892 us       - 2580 us    : printNumI(123)
8 us          - 8          : SetBigFont
14912 us      - 4332 us    : Print 001
15048 us      - 4424 us    : printNumI(123)
11668 us      - 2412 us    : draw bitmap 32x32
Do you have better results ? (do you want my WorkBench sketch ?)
8  Community / Exhibition / Gallery / Re: High speed vector graphics engine. 3.2" TFT Lcd screen. on: January 31, 2013, 10:19:07 am
Hi all,
I'm also eager to see the version of pYro_65.

In the meantime, here is a simple method for optimizing (a little bit) the current version: First download the latest version from the site "henningkarlsen" which dates from January 2013 and contains some optimizations,
then remove all the tests on display_transfer_mode especially in methods such as LCD_Writ_Bus or LCD_Write_COM.
For example, my LCD_Writ_Bus method :

void UTFT::LCD_Writ_Bus(char VH,char VL)
{   
  PORTA = VH;
  PORTC = VL;
  pulse_low(P_WR, B_WR);
}

With this modification, some methods are twice as fast : drawpixel (100µs instead of 200µs), print, DrawBitmap, DrawLine, etc.
Of course my TFT version only works with screen SSD1289 but no problem since it is the only one I have.
This is far from what announces pYro_65 but in the meantime it helps.

9  International / Français / Re: Pb accès carte SD sur MEGA 2560 + TFT ITDB32WD on: October 29, 2012, 02:08:13 pm
Merci Barbudor,
C'est surtout la question des résistances manquantes et ces 10k sur le shield (placé entre le connecteur de la carte LCD et le connecteur de l'Arduino) qui m’intéresse. J'ai fais quelques essais sur une platine : la seule façon pour que ça tourne chez moi c'est un pont diviseur 2k2 / 3k3, alors comment avez-vous fait ?
10  International / Français / Re: Pb accès carte SD sur MEGA 2560 + TFT ITDB32WD on: October 27, 2012, 10:16:10 am
Bonjour,
Je possède depuis peu un TFT LCD Mega Shield V1.0 ainsi qu'une carte TFT_320QVT (écran tactile + connecteur SD) et je rencontre les mêmes problèmes que vous avec la carte SD.
J'ai repéré l'inversion les broches MOSI et SCK, j'ai tenté de changer leur assignation dans HW_AVR.h (de la lib tinyFAT) mais sans succès.
Ma 1ere question : est-il possible de modifier l'assignation des broches du SPI dans le soft ou cela ne dépend t-il que d'un hardware immuable ?
Vous avez résolu le problème en ré-inversant ces 2 broches mais avez-vous rajouté les résistances de tirage à la masse pour les broches 36,37,38 du shield (pour le pont diviseur assurant le 3.3v) ?
Je serais tenter le mettre des 3.3k sur l'emplacement libre (à coté du potard) mais j'ai aussi remarqué que le shield reliait ces broches à l'Arduino via des résistances de 10k alors que faire ?
Merci à vous
@+
Maël
Pages: [1]