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 (https://www.sparkfun.com/products/10168) and Adafruit (http://www.adafruit.com/product/338).

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.

Revision:
1:df68f34cd32d
Parent:
0:d563e74f0ae9
Child:
2:e93021cfb0a9
--- a/N5110.cpp	Sun Jan 26 18:55:16 2014 +0000
+++ b/N5110.cpp	Sun Jan 26 19:30:09 2014 +0000
@@ -1,7 +1,7 @@
 #include "mbed.h"
 #include "N5110.h"
 
-N5110::N5110(PinName pwrPin, PinName ledPin, PinName scePin, PinName rstPin, PinName dcPin, PinName mosiPin, PinName sclkPin)
+N5110::N5110(PinName pwrPin, PinName scePin, PinName rstPin, PinName dcPin, PinName mosiPin, PinName sclkPin, PinName ledPin)
 {
     
     spi = new SPI(mosiPin,NC,sclkPin); // create new SPI instance and initialise
@@ -18,24 +18,36 @@
 void N5110::init()
 {
     turnOn();    // power up
-    reset();     // reset LCD
+    reset();     // reset LCD - must be done within 100 ms
 
     // function set - extended
     sendCommand(0x20 | CMD_FS_ACTIVE_MODE | CMD_FS_HORIZONTAL_MODE | CMD_FS_EXTENDED_MODE);
 
-    sendCommand(CMD_VOP_7V38);    // operating voltage
+    sendCommand(CMD_VOP_7V38);    // operating voltage - these values are from Chris Yan's Library
     sendCommand(CMD_TC_TEMP_2);   // temperature control
     sendCommand(CMD_BI_MUX_48);   // bias
 
     // function set - basic
     sendCommand(0x20 | CMD_FS_ACTIVE_MODE | CMD_FS_HORIZONTAL_MODE | CMD_FS_BASIC_MODE);
+    normalMode();  // normal video mode by default
     sendCommand(CMD_DC_NORMAL_MODE);  // black on white
-    //sendLCDCommand(CMD_DC_INVERT_VIDEO);  // white on black
+    //sendCommand(CMD_DC_INVERT_VIDEO);  // white on black
 
     // RAM is undefined at power-up so clear
     clearRAM();
 
 }
+ 
+// sets normal video mode (black on white) 
+void N5110::normalMode() {
+     sendCommand(CMD_DC_NORMAL_MODE);  
+   
+}
+
+// sets normal video mode (white on black) 
+void N5110::inverseMode() {
+    sendCommand(CMD_DC_INVERT_VIDEO); 
+}
 
 // function to power up the LCD and backlight
 void N5110::turnOn()
@@ -183,6 +195,8 @@
         sendData(font5x7[(c - 32)*5 + j]);
         // array is offset by 32 relative to ASCII, each character is 5 pixels wide
     }
+    
+    sendData(0); // send an empty byte to introduce space between characters
 
 }