Nokia 5110 LCD C Driver for PIC Microcontrollers

Graphic displays are quite common nowadays, particularly those recovered from old mobile phones. Given their very low cost and great versatility they are a welcome addition to any electronic project that requires some level of interaction with the user. Here you can find a driver to use a particular LCD model, the one found in Nokia 5110 phones.

The Nokia 5110 graphic display can be found in various sites over the web, at a very low prices. Using it, however, may resut quite challenging for some unexperienced users, due to the particular addressing structure, which requires some calculations in order to properly set or clear any particular pixel.

While there are several drivers available for platforms such as Arduino, the PIC microcontrollers' users are left with almost no drivers available. In an attempt to satisfy such need, this driver has been created in CCS C to be used with most PIC microcontrollers, simply including it at the beginning of your program, as shown below:

#include "Nokia_5110.c"

The included functions let the user show all ASCII characters and address each individual pixel, therefore being able to draw lines, boxes, bars, circles, and whatever image that will fit within the LCD dimensions.

Here is the list of functions; the full driver is available in the Download section.

Conventions about coordinates:
(x,y) means x=0..83 y=0..47
[x,y] means x=0..83 y=0..5

nokia_init()

Initializes the lcd. Must be called before any other function.

nokia_refresh()

Dumps video memory map to lcd.

nokia_write_command(c)

Sends command c to lcd.

nokia_write_data(c)

Sends data c to lcd.

nokia_write_dorc(c)

Sends data/command to lcd.

nokia_clean_buffer()

Initialize video memory map.

nokia_contrast(contrast)

Sets lcd contrast (0..127).

nokia_gotoxy(x,y)

Sets cursor [x,y] position on video memory map.

nokia_printchar(c)

Draws character c at cursor position on video memory map.

nokia_printstr(char* m)

Draws a string of characters at cursor position on memory map. If the string is longer than the lcd width, it continues in next row.

nokia_bigc(c)

Displays 10x12 pixels numerical characters (-. 0123456789).

nokia_plot(x,y,color)

Draws a pixel in video memory map at coordinates (x,y). It draws it on or off depending on the value of color, 1 or 0.

nokia_line(x1,y1,x2,y2,color)

Draws a line between (x1,y1) and (x2,y2), on or off depending on color.

nokia_box(x1,y1,x2,y2,fill,c)

Draws a box of corners (x1,y1) and (x2,y2), filled/empty depending on fill and on or off depending on c.

nokia_bar(x1,y1,x2,y2,w,c)

Draws a bar from (x1,y1) to (x2,y2) with a width of w and on or off depending on c.

nokia_circle(x,y,r,f,c)

Draws a circle with center (x,y) and radius r, and filled depending on f. On or off depending on c.

nokia_bitmap(rom *bitmap,bx,by,xdim,ydim,color,align)

Draws a bitmap stored in ROM, origin (bx,by), dimensions (xdim,ydim), align (LSB UP = 0). The bytes are stored vertically, so the variable align indicates whether the LSB is up (0) or down (1).