TFT library performance bugfix

In the current version of your TFT library, there is an unnecessary loop inside the drawString() function (lines 548-564 in the TFT.cpp source file). This is the current code:

[code]void TFT::drawString(char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor)
{
while(*string)
{
for(unsigned char i=0;i<8;i++)
{
drawChar(*string, poX, poY, size, fgcolor);
}
*string++;

    if(poX < MAX_X)
    {
        poX+=8*size; // Move cursor right
    }

}

}[/code]

The ‘for i’ loop is unnecessary; probably an accidental cut-and-paste from the drawChar() function, which needs a loop to draw the 8x8 character matrix. As a result, strings display properly, but take eight times longer than they need to to draw.

Simply deleting the loop as follows speeds string display up by a factor of eight:

[code]void TFT::drawString(char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor)
{
while(*string)
{
drawChar(*string, poX, poY, size, fgcolor);
*string++;

    if(poX < MAX_X)
    {
        poX+=8*size; // Move cursor right
    }

}

}[/code]

This makes a huge difference: on my 328-based Seeeduino, drawing strings goes from being a fairly slow process that you can actually see happening, to a much faster process that feels close to instantaneous.

May I suggest that you update the library to reflect this change? Anyone using the current version can fix this themselves by editing the TFT.cpp file in {Your Arduino work directory}/libraries/TFT/

:astonished: ,Many thanks.

We will upload a new version TFT library with new functions soon.
New function added:

drawNumber(long long_num,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor) drawFloat(float floatNumber,unsigned char decimal,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor) drawFloat(float floatNumber,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor)//2 digits

Thanks
Albert