![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
MikeP
Joined: 07 Sep 2003 Posts: 49
|
Text draw speed |
Posted: Sun May 26, 2013 1:17 pm |
|
|
Using this Color TFT display http://www.adafruit.com/products/335
PIC18F4550 at 20mhz/48mhz clock
CCS C: V1.140
My text drawing speed is really slow. Can you look at my code and comment on it.
Now if I used a ST25VF064C-80-4I-S3AE memory for my font data and copied the 5 bytes to ram needed for each char before drawing them do you think I would see a speed up? Reading my font data from program memory very slow right? Would reading the font data from SPI be faster?
Do you think the 8bit bus and the PICs speed is the limiting factor here?
Code: |
// standard ascii 5x7 font
const unsigned char font[] = { // size is 1275
0x00, 0x00, 0x00, 0x00, 0x00,
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
0x18, 0x3C, 0x7E, 0x3C, 0x18,
0x1C, 0x57, 0x7D, 0x57, 0x1C,
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
............
};
void drawChar( signed int16 x, signed int16 y, unsigned char c,
unsigned int16 color, unsigned int16 bg, unsigned int8 size)
{
int8 i,j;
unsigned int8 line;
unsigned int16 test;
for (i=0; i<6; i++ )
{
if (i == 5)
line = 0x0;
else
{
test = ((unsigned int8)c*(unsigned int16)5)+i; //FORCE 16bit math
line = font[ test ]; // ((int16)((char)c*5)+i)
// printf("line: %c %Lu\r\n", c, test );
}
for (j = 0; j<8; j++)
{
if (line & 0x1)
{
if (size == 1) // default size
drawPixel(x+i, y+j, color);
else
{ // big size
fillRect(x+(i*size), y+(j*size), size, size, color);
}
}
else if (bg != color)
{
if (size == 1) // default size
drawPixel(x+i, y+j, bg);
else
{ // big size
fillRect(x+(i*size), y+(j*size), size, size, bg);
}
}
line >>= 1;
}
}
}
void drawPixel(int16 x, int16 y, unsigned int16 color)
{
CS_ACTIVE;
int16 t;
switch(tftinfo.rotation) {
case 1:
t = x;
x = TFTWIDTH - 1 - y;
y = t;
break;
case 2:
x = TFTWIDTH - 1 - x;
y = TFTHEIGHT - 1 - y;
break;
case 3:
t = x;
x = y;
y = TFTHEIGHT - 1 - t;
break;
}
writeRegister16(0x0020, x);
writeRegister16(0x0021, y);
writeRegister16(0x0022, color);
CS_IDLE;
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
drolleman
Joined: 03 Feb 2011 Posts: 116
|
|
Posted: Sun May 26, 2013 6:52 pm |
|
|
You will never get any speed from a 18f part to draw on a tft screen. I use a 33ep part and it is just acceptable. There is a lot of data moving to get the job done. The code is inefficient and needs to cleaned up. |
|
![](templates/subSilver/images/spacer.gif) |
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Mon May 27, 2013 10:46 am |
|
|
I don't know how the screen bitmap is organized and how the processor has access to it, but could you write characters to it one row or column at a time, instead of with drawPixel? Also, if you could accept less flexibility in color or character size, that might make the routine run faster. |
|
![](templates/subSilver/images/spacer.gif) |
MikeP
Joined: 07 Sep 2003 Posts: 49
|
|
Posted: Mon May 27, 2013 12:46 pm |
|
|
You may be on to something there.
Read all of the font data in for the current row and write them as a bitmap could maybe equal up to a 50% speed up.
draw bitmap 16bit color full screen from USB data: 400ms
draw text full screen from USB data: 1200ms
I could also have the PC side do the heavy lifting for text/font generating.
It works now. These ideas have been added to my todo list to look into.
Looking at moving to a PIC24EP256GU810. Can one for the most part take a pic18 project and move to a pic24. I can port my code to use the 16bit mode. This PIC should be a nice speed improvement. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|