Nokia LCD

An interface for controlling a 130x130 Nokia mobile phone display.

Nokia LCD

There are a number of different hardware breakouts available for these panels. See:

The LCD panels themselves also vary, particularly whether they use an Epson or Philips driver. This library aims to support both types. Fiddle with the type parameter if yours doesn't seem to work.

Hello World!

Import program

00001 // Hello World! for Nokia LCD, sford
00002 // - LCD6610 is for newest Sparkfun breakout
00003 
00004 #include "mbed.h"
00005 #include "NokiaLCD.h"
00006 
00007 NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type
00008 
00009 int main() {
00010     lcd.background(0x0000FF);
00011     lcd.cls();
00012     lcd.fill(2, 51, 128, 10, 0x00FF00);
00013     lcd.fill(50, 1, 10, 128, 0xFF0000);
00014     lcd.locate(0,3);
00015     lcd.printf("Hello World!");
00016     for (int i=0; i<130; i++) {
00017         lcd.pixel(i, 80 + sin((float)i / 5.0)*10, 0x000000);
00018     }
00019 }

/media/uploads/simon/mobilelcdschematic1.png /media/uploads/simon/mobilelcdphoto.jpg

On other displays, you may also have to wire e.g. VBATT (the screen backlight) to 3.3v

Library

Import library

Public Types

enum   LCDType { LCD6100 , LCD6610 }
 

LCD panel format.

More...

Public Member Functions

  NokiaLCD (PinName mosi, PinName sclk, PinName cs, PinName rst, LCDType type=LCD6100)
  Create and Nokia LCD interface, using a SPI and two DigitalOut interfaces.
int  putc (int c)
  Write a character to the LCD.
int  printf (const char *format,...)
  Write a formated string to the LCD.
void  locate (int column, int row)
  Locate to a screen column and row.
void  cls ()
  Clear the screen and locate to 0,0.
void  pixel (int x, int y, int colour)
  Set a pixel on te screen.
void  fill (int x, int y, int width, int height, int colour)
  Fill an area of the screen.
void  foreground (int c)
  Set the foreground colour.
void  background (int c)
  Set the background colour.

Other Reference




1 related question:


29 comments:

05 Dec 2010

I have the new Sparkfun Nokia LCD breakout board with the 6610 instead of the 6100. I noticed a few things when I tested out the Hello World code.

1) The two leftmost columns of pixels appeared whitish and were not affected by the lcd.background() command. I modified NokiaLCD.cpp line 118 from x1=x+2 to x1=x+0 and the whitish pixels went away.

2) The sine wave seems to create some problem for the lcd.fill() command. If I display a green rectangle before the sine wave is drawn then it displays OK. But if I display a green rectangle after the sine wave is drawn then it is displayed as a red & blue striped rectangle.

3) The display appears to be 130x132 instead of 130x130. The reason I think this is because I drew a box pattern using the following code and noticed there are two rows of pixels visible below the bottom green border.

    lcd.fill(0, 0, 130, 1, 0x00FF00);
    lcd.fill(129, 0, 1, 130, 0x00FF00);
    lcd.fill(0, 0, 1, 130, 0x00FF00);
    lcd.fill(0, 129, 130, 1, 0x00FF00);

These two rows appear to be a slightly darker blue than the 0x0000FF background. I tried changing the NOKIALCD_HEIGHT parameter but I was still not able to access those rows.

25 Dec 2010

lcd.pixel is not working correct with board 6610. Adding some code solved the problem

void NokiaLCD::pixel(int x, int y, int colour) {
    _cs = 0;
    _window(x, y, 1, 1);
     switch (_type) {
        case LCD6100:
        case PCF8833:
           
                _putp(colour);
            
            break;
        case LCD6610:
           
                int r4 = (colour >> (16 + 4)) & 0xF;
                int g4 = (colour >> (8 + 4)) & 0xF;
                int b4 = (colour >> (0 + 4)) & 0xF;
                int d1 = (r4 << 4) | g4;
                int d2 = (b4 << 4) | r4;
                int d3 = (g4 << 4) | b4;
                data(d1); 
                data(d2);   
                data(d3);
            
            break;
            }
    _cs = 1;
}
17 Feb 2011

I can confirm that my new Sparkfun boards that just came in today appear to have the 6610 (6100 type killed it when I tried) and they needed both patches to the library code from the two previous comment posts. They fixed most of the strange issues....

But the two bottom rows still do not change - so it also looks to me like 132 vs 130.

Here is a video

I added some code to print characters and draw random rectangles after the Hello Word screen.

Couple of quick notes on the new Sparkfun modules:

Connect Vbat (the backlight to 5V*) or you will never see a display image. DIO on PCB is Sdata

  • Update: Even though they say up to 6V for the backlight on the Sparkfun site, the reg IC seems to get a bit too hot to me and it looks like 3.3V works better on the ones we have. There are some posts about overheating in the Sparkfun forums. Apparently the inductor is underrated for the current levels it is seeing.

Update to my update: they have a new version now with a larger inductor that fixed this issue - see later comment with photo.

19 Feb 2011

please help ...

I have ordered on sparkfun a Nokia Breakout board 08600 with the following pins :

s1

s2

cs - to p8

sck - to p7

gio - to p5

reset - to p9

stat2

stat1

stat0

gnd - to mbed gnd

3.3v - to 3.3 V mbed

vbatt - to 5.0v mbed

don't print nothing ..

any suggestion ?

I have loaded an compiled the Nokia Epson sample, and tried the NokiaLcd_Helloword .. without success

20 Feb 2011

That seems to be what I did. We got four last week from Sparkfun and they all seem to work fine.

NokiaLCD lcd(p5, p7, p8, p9, NokiaLCD::LCD6610); // mosi, sclk, cs, rst, type

Might be a bad connection somewhere. Is the display dark? Did you try the other type LCD6100 yet? Sounds like older boards had this other type. Mine has a red PCB.

20 Feb 2011

Hi,

Seems my LCD board has a defect .. because nothing happens when I connect +3.3v and GND (even the VBATT) ...

Screen stay dark.

26 Feb 2011

Working with a PCF8833. Adjusted the color to use 24bit color, and shift to 565 The follow code produces correct colors on the LCD I have, but differs from the Philips datasheet for the controller (R and B interchanged) for the 565 dithered mode.

void NokiaLCD::_putp(int colour) {
// USE 24Bit RGB, and shift to 565
//    [R7R6R5R4R3R2R1R0][G7G6G5G4G3G2G1G0][B7B6B5B4B3B2B1B0]
    int rg = ((colour      ) & 0xF8)  //  [B7B6B5B4B3______]
           | ((colour >> 13) & 0x07); //  [__________G7G6G5] 
    int gb = ((colour >> 19 ) & 0x1F) //  [______R7R6R5R4R3]
           | ((colour >> 5 ) & 0xE0); //  [G4G3G2__________]
    data(rg);
    data(gb);
}

The above code results in bright colors,only 6 volts on the backlight. (My last post had errors)

26 Feb 2011

It works now .. that was the LCD screen (received broken :(

But I still have 2 questions :

1) the screen is reversed .. pixel 0,0 is located on bottom right ... How to reverse ? Via the command/data I think ..

2) the backlight is working weel, but a little bit too much, or this is a problem with the contrast ? Is difficult to read "Hello World" when I'm front of the screen.

any suggestion will be appreciated.

15 Sep 2011

Jon Kerwin wrote:

3) The display appears to be 130x132 instead of 130x130. The reason I think this is because I drew a box pattern using the following code and noticed there are two rows of pixels visible below the bottom green border.

    lcd.fill(0, 0, 130, 1, 0x00FF00);
    lcd.fill(129, 0, 1, 130, 0x00FF00);
    lcd.fill(0, 0, 1, 130, 0x00FF00);
    lcd.fill(0, 129, 130, 1, 0x00FF00);

These two rows appear to be a slightly darker blue than the 0x0000FF background. I tried changing the NOKIALCD_HEIGHT parameter but I was still not able to access those rows.

To correct the last two rows you need to change the line data(31); to data(32); in the reset function.

06 Oct 2011

If you have the recent Sparkfun Nokia LCD breakout boards, you still need the patches from the first two comments and the one in the previous comment.

13 Oct 2011

Students have a BMP and JPG converter running on mbed for the Nokia LCD

http://mbed.org/users/XkLi/notebook/digital-photo-frame/

/media/uploads/4180_1/_scaled_nokia_bmp.png

01 Dec 2011

Didier Solheid wrote:

It works now .. that was the LCD screen (received broken :(

But I still have 2 questions :

1) the screen is reversed .. pixel 0,0 is located on bottom right ... How to reverse ? Via the command/data I think ..

2) the backlight is working weel, but a little bit too much, or this is a problem with the contrast ? Is difficult to read "Hello World" when I'm front of the screen.

any suggestion will be appreciated.

I had a similar problem. I noticed the ribbon cable that connects the LCD to the board was broken. I ended up replacing having to replace it. Fortunately, SparkFun sells the LCD separately.

Buyer beware: This device is pretty fragile.

16 Feb 2012

http://www.sparkfun.com/products/11062 is the new Sparkfun version of the Nokia LCD breakout board that just came out today. It looks like they fixed the super hot burns your finger inductor issue and it has an improved power circuit for the backlight. Notice the larger inductor on the new breakout.

/media/uploads/4180_1/_scaled_nokialcd.jpg
New Sparkfun Nokia LCD Breakout Board - needs new code patch that follows in newer comments.

/media/uploads/4180_1/_scaled_oldnokialcd.jpg
Older Sparkfun Nokia LCD Breadkout Board - needs three code patches found in earlier comments. Recent ones were also on a red PCB. Look for the small blue inductor near the center of the board.

03 Mar 2012

Having broken the original ribbon cable on my first LCD, my second my will not display the words "Hello World", but displays something jumbled up instead. The background color and the red and green rectangles are fine, as is the tie-fighter demo. But just cannot get the text to display properly. As a previous poster mentioned, the contrast is such that it now makes the screen unreadable head on - can this be changed in software or is it simply the backlight being too bright?

Any thoughts ideas?

Using the same MBED, breakout board as previously, only the actual LCD is new (eBay sourced).

Regards

03 Mar 2012

Whoops, I change the type of display from being 6610 in the default to 6100 and it now displays the text as I would expect, however, still need to turn down the contrast to make it readable... If anyone has any ideas...

Regards

30 Mar 2012

This is my first adventure into anything embedded, so I suspect I'm doing something wrong.

I'm using the LCD 11062 (sparkfun nokia lcd breakout board), and have attempted to follow both this recipe and another one (http://mbed.org/users/XkLi/notebook/digital-photo-frame/) as the other one uses the same screen.

I've managed to get the backlight working (I think; seems to work when VBATT is connected to either of mbed's Vout or Vu). However, I am unable to get anything to actually display on the screen (e.g. setting background/foreground/pixels/etc. has no effect). I have tried two wire configurations (p5, p7, p8, p9) and (p11, p13, p14, p15), as well as the three supported LCD types: LCD6100, LCD6610, and PCF8833.

Finally, I am using this on a solderless breadboard, manually connecting wires to the LCD. As I am new to this, I don't (yet) have the equipment to measure if anything is actually going through any of the wires.

I would appreciate any help, although I understand that I haven't given much to go on. Thanks.

29 Apr 2012

The latest batch of sparkfun LCDs come with the PCF8833 (or at least the one we got). There are a few differences noted: 1. The screen is 132x132; you will need to modify the global width and height variables. Also, when calling fill() be sure to take this into account, too. Depending on how you modify the above parameters, the _window() function need not be changed. 2. The default library will cause the screen to be flipped sideways and the text to be printed vertically. To fix this, change line 95 to "data(C0);" (mirror x and y) 3. Colors are also off; the default library gives a green background and blue boxes. The fix noted above does change the behavior, but still doesn't fully correct the problem (background is red, vertical box is blue, horizontal box is green). We're not experts with RGB codes and Hex values so any help on this is greatly appreciated.

02 May 2012

Hey,

You have all the changes I've made to get mine working, though you need to replace the pixel function as suggested by Joel Rosiene. You need to take the 24 bit colour and make it into a RGB 565. That will make all the colours nice and bright and then you should be good to go!

04 May 2012

Christopher Lord wrote:

Hey,

You have all the changes I've made to get mine working, though you need to replace the pixel function as suggested by Joel Rosiene. You need to take the 24 bit colour and make it into a RGB 565. That will make all the colours nice and bright and then you should be good to go!

We did, but the color came out the way we described; background is red, vertical box is blue, horizontal box is green.

EDIT: as per request here is the modified NokiaLCD.cpp; note that this only has modifications that will work for the PCF8833, and the color has not been fixed yet. We tested some code and the output looks like this:

Coded colorActual displayed
Red(0xFF0000)Blue
Blue(0x0000FF)Red
Yellow(0xFFFF00)Cyan
Pink(0xFF00FF)Purple
White(0xFFFFFF)White
Black(0x000000)Black

What bugs us the most is that white and black are correct while everything else is wrong...wonder what's up with that EDIT: link removed, see updated version below with colors fixed

06 May 2012

Folks, I have just managed to get this display working - the Library needed several adjustments as many of you noted. I made progress after realising that it was the pcf8833 that was on the sparkfun boards I received in the last couple of weeks (as on Jim Hamblen's picture) Here is a summary of the mods I made to get clear bright (correct) colours: - lines 11 and 12: change width and height to 132 - line 95: in the reset function: change to data(0xC0) - flip x and y and write in RGB order - line 118: change to x1=x (not x1=x + 2) - modify the _putp function to write the data in 5:6:5 colour format. replace lines 147 to 151 with (its a bit messy - but it works): int r5=(colour >> 19) & 0x1F; int g6=(colour >> 10) & 0x3F; int b5=(colour >> 3) & 0x1F; int rg=(r5 << 3) | (g6 >> 3); int gb=((g6 << 2) & 0xE0)| b5; data (rg); data (gb);