If you are trying to text wrap with the gLCD library, that feature will be built into v3.1 which should be ready tonight or tomorrow.
I'm curious how you will handle this.
There are many little issues and options related to wrapping, newline vs <CR> processing, and how
to handle things when you reach the very last character of a line and the bottom line of a text area.
For example, does <CR> wrap back to column 0? To allow easy over writing of the line.
If so, you can can't drop the cursor position to the next line until you print the next character *after*
the wrap point.
Otherwise you won't be able to draw a full line of text and overwrite it by using <CR>.
Does the full line of text on the line being wrapped to get fully erased when an auto wrap/newline occurs?
Then there is the issue of how to handle wrapping of the very last line.
Does the text area scroll after that, does the text wrap to the top line or does it just start
throwing away the text.
The most painful to deal with is supporting a single line text area.
Users want and expect to be able to do this:
lcd.println("my new line");
And have each line show up erasing the previous line.
But technically if you process the newline as you see it, and support scrolling, or automatically
erasing a line that is wrapped to, you end up scrolling out the very line that they just printed.
In the big picture, handling this single line case is the same as having to deal with allowing
printing of a full line when you support erasing the line wrapped to.
You have to defer the wrap and newline processing until *after* the next character after the wrap
point is printed.
Lots of little details to think about.
Basically text wrapping is part of the font. In order to have compatibility with older programs that don't expect wrapping:
prints the font with text wrapping disabled.
To turn it on, you would use this:
Where wrapText is a #defined constant. It will automatically turn off again next time you set the font.
If the text goes beyond the bottom of the screen, in the current version it is just truncated. The size returned from the write() function in arduino 1.0+ is reduced to the number of characters actually printed.
When the end of a line is reached, if there is not enough space on the line for another character, the rest of the line from the end of the prior character to the edge of the screen is filled with the background colour (unless the background is transparent), and the character is printed just below on the next line.
Conversely if a '\n' is used to drop to a new line, the end of the line (from the end of the last character on the line to the edge of the screen) is not filled in the background colour.
At the moment it doesn't account for whole words, so it just chops the string mid word. In future versions I may add the ability to wrap in a way which keeps whole words together, but to keep printing as fast as possible, this is not yet implemented.
Furthermore, the last line of a wrapped string does not currently blank the full line, only what is needed. I might add an option to allow the bounding box of the printed text to be set to the background colour.