|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
GLCD + TEXT ROUTINE |
Posted: Thu Aug 17, 2006 9:14 am |
|
|
Hi forum.
What’s the best way to send text to graphic lcd? If I could do a matrix and simple read the correspondent line to a specific character would be great. Anybody have any idea?
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 17, 2006 1:43 pm |
|
|
Quote: | What’s the best way to send text to a graphic lcd ? |
Look at the glcd_text57() function in these two CCS driver files:
c:\program files\picc\drivers\glcd.c
c:\program files\picc\drivers\graphics.c |
|
|
manoel_filho Guest
|
|
Posted: Fri Aug 18, 2006 10:11 am |
|
|
Ok, I already know these files, the problem is that its a little bit confuse to me. In fact I did a routine very simple that works fine, but i have to send byte by byte to each character I want, and its becomes very big of course. I just want to understand how I can make a matrix and pick the five bytes of a specific line, and send it to my routine. I will reduce the memory space a lot, because there are several characters that I didn't use.
Like this:
const BYTE TEXT [n][m] =
{0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
0x04, 0x02, 0x7F, 0x00, 0x00, // 1
0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x22, 0x41, 0x49, 0x49, 0x36, // 3
0x18, 0x14, 0x12, 0x7F, 0x10, // 4
0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x3E, 0x49, 0x49, 0x49, 0x32, // 6
0x01, 0x01, 0x71, 0x09, 0x07, // 7
0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x26, 0x49, 0x49, 0x49, 0x3E, // 9
0x00, 0x36, 0x36, 0x00, 0x00, // :
0x7E, 0x09, 0x09, 0x09, 0x7E, // A
0x7F, 0x49, 0x49, 0x49, 0x36, // B
0x3E, 0x41, 0x41, 0x41, 0x22, // C
0x7F, 0x41, 0x41, 0x41, 0x3E, // D
0x7F, 0x49, 0x49, 0x49, 0x41, // E
0x7F, 0x09, 0x09, 0x09, 0x01, // F
AND SO ON……
So I address this matrix and pick for example the letter “A” and send the five bits to my routine, that’s all.
In these examples I couldn’t understand the function of the matrix, because it seams to me that at the end of routine it sends the data do each pixel of the display, I think it’s become much slow and much difficult to “guess” every address of the every start point of the text, and my application use a lot of fast transitions on the numbers.
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 18, 2006 1:40 pm |
|
|
You can have a shorter font table which just has a subset of the
characters that CCS has in the example file. You can then subtract
the proper offset from the ASCII character, before using it as an index
into the font array. Also, you can do some tests on the ASCII character
value, to see which font array is the proper one to use.
If you look at the code at the start of the glcd_text57() function, you
can see that CCS does this already. For example, CCS doesn't have
font data for any of the character values that are less than an ASCII
space (these are called "control characters"). So CCS subtracts the
offset for a space (' ' or 0x20) from the index. Suppose that you
want to display a '$' character. Its ASCII value is 0x24. But the
font array only starts at the ASCII space (0x20). So you can't use
0x24 as an index into the array. You would get the wrong font bytes.
So you need to adjust the index by subtracting 0x20 from it. This
give a value of 4, and if you look at the font table in GLCD.C, you will
see that for an index of 4, you will get the bytes to make a '$' character.
Also, there is a limitation in the CCS compiler for the size of a constant
array. For this reason, the example file splits the font data into two
arrays. Then code must be added so check the character index and
make sure that the proper array is used to get the font data. You can
see how CCS does this in their code below:
Code: | if(textptr[i] < 'S') // Checks if the letter is in the first text array
memcpy(pixelData, TEXT[textptr[i]-' '], 5);
else if(textptr[i] <= '~') // Check if the letter is in the second array
memcpy(pixelData, TEXT2[textptr[i]-'S'], 5);
else
memcpy(pixelData, TEXT[0], 5); // Default to space |
|
|
|
manoel_filho Guest
|
|
Posted: Tue Aug 22, 2006 9:24 am |
|
|
Ok, I see. Now I want to do some thing with my variables, like a clock. So I have my variables, like seconds for example. How can I show this variables on LCD?
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 22, 2006 3:51 pm |
|
|
Look in this CCS example file:
c:\program files\picc\examples\ex_glcd.c
It has three examples of calling the glcd_text57() function. These are
near the start of the file. Note that a pointer to a RAM array must
be passed to the glcd_text57() function. A string can be assigned to
the array at compile time (in the array declaration statement) or it
can be put into the array at run-time with sprintf() or strcpy().
The EX_GLCD.C file has examples of both of these methods. |
|
|
manoel_filho Guest
|
|
Posted: Wed Aug 23, 2006 5:31 am |
|
|
OK,
void displayVoltage(int adc) {
char voltage[9]; //is this necessary?
sprintf(voltage, "%f", (float)adc * .01960784);
voltage[4] = '\0'; //is this necessary?
}
This 0.1960784 What does it means ?
I think I will do something like:
int seconds=0;
void clock()
{
.
.
.//here I send some comands to positioning LCD
.
.
sprintf(seconds, "%2u");
}
is that correct?
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 23, 2006 12:22 pm |
|
|
No it's not correct.
You need to study the C language, with regard to arrays and strings.
You need to get a book or take a class on C. |
|
|
manoel_filho Guest
|
|
Posted: Thu Aug 24, 2006 5:03 am |
|
|
That’s correct, but I already made this, in fact I read 5 books and I didn’t understudy this part of C language. But thanks anyway, I will go back and use my old LCD 16 x 4, it’s more easy to me.
Later, when I fully understand this part of C I come back to use it.
Thank´s |
|
|
|
|
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
|