Go Down

Topic: Nokia LCD display shield question (Read 10086 times) previous topic - next topic


Sure. I'll give you a copy of what I'm making when I'm done... probably this week.

Thanks very much.


I'd like a little guidance with how to write this if that is okay. I'm going to type it out how I think it should be structured (to get text scrolling).

We don't know how big the char string will be as it is variable in length depending on the tweet we are displaying.
We are printing at the following location

Code: [Select]
graphic.Box (1,70,128,79,0);
      graphic.setForeColour(GLCD_CYAN); //Text is coloured CYAN
      graphic.print(dataStr); //This is stationary text

so I think it should go like this (roughly). .

graphic.setForeColour(GLCD_CYAN);       //set the text colour
graphic.setCoordinate(1,70);                //set the coordinates for the string to be drawn
tempString = dataStr[i+1];                       //create a temporary string to use as the display. Put an extra character on the end

while (tempString >1 char in length){
graphic.Box (1,70,128,79,0);                      //first clear the screen section from the last tweet
graphic.print(tempString);                   //print the tempString
tempString (Magically cut the first char out of the tempString) //perform magic

As you can see, help. Please. Thank you.

Tom Carpenter

Oct 12, 2012, 01:40 am Last Edit: Oct 12, 2012, 01:46 am by Tom Carpenter Reason: 1
I have simplified one of the functions from my my MP3 Player. This basically displays data from a string which you supply, scrolling it around by 1 character each time the function is called.
Code: [Select]
//Scroll through songInfo, shifting 1 characters each time
void printScroll(char* songInfo, byte infoLength, boolean start = false);
void printScroll(char* songInfo, byte infoLength, boolean start){
 static unsigned int tagPosition = 0;
   tagPosition = 0;
 char stringRecover[23] = {0};
 strncpy(stringRecover,&songInfo[tagPosition], 22); //22 character substring starting at [tagPosition]
 tagPosition += 1;
 if (tagPosition >= infoLength - 21){ //subtracting 21 as the last 21 characters are the same as the first.
   tagPosition = 0;

The function does not check the length of the string you supply (I took too much time for my particular project), so you need to ensure that the string is at least 43 characters long, and that the last 21 characters are the same as the first. For example:

"Hello, this string is more than 22 characters longHello, this string is"; //Noting that the last 21 characters are the same as the first.
"Hello,                    Hello,                   "; //This string is padded with spaces to ensure that it is the correct length.

You could use something like this function to automatically format the string and scroll it:
Code: [Select]

 //This code calls the scroll funtion
 char string[] = "Hello, this is the string I wan't to scroll around the screen";
 scrollString(string, 50); //scroll the string 50 places to the right (will loop around as necessary).


void scrollString(char* suppliedString, byte n){ //Formats then scrolls the string around the screen n times.
 int length = strlen(suppliedString);

 char string[length < 22? 44: length + 22];  //create a longer buffer of minimum size 44 characters (22 + 21 + null).

 strcpy(string, suppliedString); //Copy the supplied string into the new buffer

 //check the length of the string:
 if (length < 22){
   //String is too short!
   memset(string + length, ' ', 22 - length); //so pad with spaces up to the required length
   string[22] = 0; //re null terminate (we just overwrote the null with a ' ')
   length = 22; //string is now 22 characters long
 //Now append the first 21 characters to the end to allow wrap around (so the string can scroll around the screen continuously)
 char stringRecover[22] = {0};
 sprintf(string + length,"%s",stringRecover); //Add the first 21 chars onto the end of songInfo to make it easier to loop through later

 length = strlen(string);
 printScroll(string, length, true); //initial print to the screen, reset loop position to the start.

 for (byte i = 0; i < n - 1; i++){
    printScroll(string, length); //shift around the screen n times.

(Just to note, the formatting function hasn't been tested beyond it compiling as I don't have a screen to hand, but I know the printing function works).


Hey Guys...

With this tutorial (Link) i put the LCD to work, however everything appears in mirror and upside down. How can I solve this problem?


Tom Carpenter

Are you using their library (ColorLCDShield), or mine (gLCD)?



Thanks for your quick reply...

Im using ColorLCDShield.


Dec 30, 2012, 08:26 pm Last Edit: Dec 30, 2012, 08:33 pm by NesquickPT Reason: 1
Hey Again...

I tried your library (gLCD) and do the same thing, and i don't understand why...

Tom Carpenter

with the gLCD library, are you using PHILLIPS or EPSON? If the former, then there are four options to choose from:
It is a case of trial and error as to which one produces the desired results.

If you have an EPSON display and it is mirrored, then you have come across a display I haven't seen before, in which case I would have to add a new definition into the library.


I'm using EPSON...
I tried all option and the PHILLIPS ones doesn't work at all.

One more thing, the LCD works with:
//graphic.begin(0,0,0,EPSON); //Normal Epson
//graphic.begin(0,0,0,EPSON_4); //Normal Epson

But its mirrored and upside down.

Tom Carpenter

Could you post a picture of what the basic functions example sketch prints?


This is the results with Basic Functions example...


That's not mirrored, and your picture is upside-down.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Tom Carpenter

Unfortunately with EPSON displays, that is the correct way up. If you have ever taken apart a 6100 phone you will find that the connector is at the top. It's beyond me why Sparkfun put the display the way up they did.

I am yet to find a way which rotates the screen 180 degrees without causing the image to muddled up.

The closest I got if I remember correctly is to call:


But it wasn't very successful, so I haven't documented it.

Tom Carpenter

I have now added the ability to rotate the screen either 0, 90, 180 or 270 degrees clockwise. (as of Version 3.4).

It should be noted that doing so reduces the performance of the display in any mode other than 0degrees because the coordinates have to be remapped before being send to the screen.
The impact is mostly confined to text and drawing lines.
Filling areas such as with Clear() or Box() doesn't require remapping so is unaffected.


Go Up