Library for interfacing to Nokia 5110 LCD display (as found on the SparkFun website).

Dependents:   LV7_LCDtest LV7_Grupa5_Tim003_Zadatak1 lv7_Grupa5_Tim008_zad1 LV7_PAI_Grupa5_tim10_Zadatak1 ... more

This library is designed to make it easy to interface an mbed with a Nokia 5110 LCD display.

These can be found at Sparkfun ( and Adafruit (

The library uses the SPI peripheral on the mbed which means it is much faster sending data to the display than other libraries available on other platforms that use software SPI.

The library can print strings as well as controlling individual pixels, meaning that both text and primitive graphics can be displayed.


RevisionDateWhoCommit message
51:32f9ffeafb6d 2020-01-22 eencae Undo overloaded constructor default tip
50:e73cd097fdcb 2020-01-22 eencae Added overloaded constructor for Gamepad2
49:93355c01e261 2018-03-19 eencae Changed default contrast (0.55). This seems to work better with the majority of screens.
48:af12980ac515 2018-02-21 eencae Re-generated documentation.
47:2eb1a863ebed 2017-12-20 eencae Added floating-point literals to remove warnings. Added in setContrast method.
46:6de3ebf5b195 2017-11-27 eencae Remove deprecated tag for drawSprite (used in ELEC1620 teaching).; ; Updated example code to use new setPixel(x,y,state) format.
45:97e54ea40dac 2017-11-06 eencae Added example for new setContrast method. This can be used to set contrast in range of 0.0 to 1.0. 0.4 appears to be a decent default, but may need tweaking for different displays.; ; The init method also includes private methods that can be tweaked.
44:57f9d32fb521 2017-11-01 eencae Separated out contrast, bias and temp coefficient methods. Modified init method to take this into account. Can now dynamically control contrast at run-time which makes it easier to account for natural variation between individual LCD displays.
43:c2598020fcac 2017-03-21 valavanisalex Fix line rendering when direction is negative
42:596c207519de 2017-03-21 valavanisalex setPixel() now accepts a state parameter. clearPixel() deprecated
41:6c046786be6c 2017-03-08 valavanisalex Fix Bitmap error checking
40:c9262294f2e1 2017-03-08 valavanisalex Add Bitmap rendering code
39:5998f0d22113 2017-03-08 valavanisalex merge
38:92fad278c2c3 2017-03-08 valavanisalex Added Bitmap class to simplify sprite support
37:c708b92609aa 2017-03-07 eencae Updated example code.
36:00ebd449b6f3 2017-03-07 eencae Changed 'glyph' to sprite. Added docs.
35:2d5931a66fba 2017-03-07 eencae Added sprite support (untested).
34:626b873e6362 2017-03-01 eencae Re-merge
33:d80e568a2e18 2017-02-16 valavanisalex Use enumerations to make fill-types more self-explanatory
32:c9643726edca 2017-02-16 valavanisalex Use initialiser lists instead of constructor body
31:8a0c21042f82 2017-02-16 valavanisalex Add a destructor to free allocated memory
30:11986573659e 2017-02-08 eencae Change default Temp value in init as gives better performance.
29:5bc91bd44c77 2017-02-16 valavanisalex Add const safety to prevent unintentional modification of parameters, and set types to unsigned int where appropriate
28:4091516537e4 2017-02-15 valavanisalex getPixel should be const (i.e., it doesn't modify anything in the LCD object)
27:0d8d90936b4c 2017-02-07 eencae Fixed bug in drawRect() that causes sizes to be off by 1 pixel.
26:36be85c20ef4 2017-02-07 eencae Updated docs.
25:444e55e2e419 2017-02-07 eencae Fixed docs.
24:342bdb6679a1 2017-02-07 eencae Moved refresh() out of clear/printString/printChar methods. ; ; At every frame update, the buffer should be cleared using 'clear', then the frame constructed using printString/draw methods etc. Finally a call to refresh() will update the display.
23:eb7e6632fc9e 2017-02-01 eencae Check for NULL pointer on pwrPin, use memset to zero out buffer. Ensure all pointers initialised to allow use with 'new' operator.
22:31c54fc61f12 2017-02-01 eencae Moved 'initSPI' method call to init() method from constructor.
21:4cbdc20fea9f 2017-01-28 eencae Added overloaded constructor that doesn't include the power pin being connected to GPIO. In this instance, the Vcc of the LCD must be tied directly to +3V3.
20:8db6aa25f55e 2017-01-19 eencae Added f to literals for brightness check to change them to float literals and get rid of compiler warning.
19:ba8addc061ea 2015-04-23 eencae 1) Replaced literal values in library with WIDTH, HEIGHT, BANKS etc.; 2) User now needs to manually call refresh() after drawing lines/circles/rects. Was previously in drawLine() and so sent the entire buffer to display after every line - very slow.
18:1af393359298 2015-04-22 eencae printString() and printChar() updated so that strings/chars are cut-off after the 83rd pixel and fit on the display. Previously this would cause the buffer array to go out of bounds and cause a crash.
17:780a542d5f8b 2015-03-17 eencae Added functions for drawing primitive shapes (lines, circles and rectangles). Can draw white, black and dotted lines. Can draw transparent (with outline), black fill and white fill circles and rectangles.
16:b37a3a260598 2015-03-10 eencae Updated docs.
15:ee645611ff94 2015-03-10 eencae (none)
14:520a02fc12aa 2015-03-10 eencae Expanded example and modified printChar().
13:908644099648 2015-03-10 eencae Modified printChar() so that the character pixel data is written to the buffer, rather than being sent directly to the display. Means chars and setPixel() can be used together.; ; Expanded example code.
12:022993561fd8 2015-03-10 eencae clear() method now clears on-board RAM on LCD.
11:fc7d89b33e4c 2014-09-17 eencae Changed LED pin number to match custom PCB.
10:6f3abb40202b 2014-07-16 eencae Added example code to show how to use sprintf() to print data variables on the display.
9:7701f0126ba7 2014-05-20 eencae printString() has been modified. Rather than sending the string to the display using the printChar(), it now writes the character bitmap data to the screen buffer and refreshes the display. This means that pixels and strings can now be used together.
8:40abe5736eca 2014-05-19 eencae Added plot function (untested).
7:3010f24e0a81 2014-05-19 eencae Modified refresh() function so that the address is reset to (0,0) before sending the entire screen buffer to the display. Ensures the origin of the buffer coincides with the top-left pixel. This may not be the case after printing strings.
6:adb79338d40f 2014-01-27 eencae Documentation complete. Functions are all tested. Note that strings and characters are deleted from the display if the refresh() function is called.; ; TODO:; ; Instead of printing strings and characters to the display, they are written to the buffer.
5:6ea180eef702 2014-01-26 eencae Updated docs.
4:e923c54c1c7d 2014-01-26 eencae Updated docs.
3:f90dd1042d17 2014-01-26 eencae Added documentation.
2:e93021cfb0a9 2014-01-26 eencae Added documentation and additional testing.
1:df68f34cd32d 2014-01-26 eencae Started to add documentation. This commit is to test the publishing and documentation.
0:d563e74f0ae9 2014-01-26 eencae Initial commit of library.; ; Testing and documentation to do.