A basic LCD output test which uses the NXP LPC1768\'s SPI interface to display pixels, characters, and numbers on the Nokia 5110 or Nokia 3310 LCD.

Dependencies:   mbed NOKIA_5110

Quick and versatile LCD screen control. Works as a great alternative to serial consoles!

---------

/media/uploads/Fuzball/debug_gui_1.jpg

Inverted-color text function makes easy menus and borders

/media/uploads/Fuzball/oscil_1.jpg

Uses a simple SetXY(char, char) function to draw data-plots or patterns

- Wiring -

/media/uploads/Fuzball/debug_gui_2.jpg

LCD's connections from left to right:

1) +3.3v (V_lcd) - mbed's VOUT

2) GND - mbed's GND

3) SCE (chip select) - mbed's p8

4) RST (reset) - mbed's p9

5) DC (data/command) - mbed's p10

6) MOSI - mbed's p11

7) SCLK (serial clock) - mbed's p13

8) +3.3v (V_backlight) - mbed's VOUT

The code for this setup would be...

LcdPins myPins;

myPins.sce = p8;

myPins.rst = p9;

myPins.dc = p10;

myPins.mosi = p11;

myPins.miso = NC;

myPins.sclk = p13;

or more easily...

LcdPins myPins = { p11, NC, p13, p10, p8, p9 };

Init the NokiaLcd class using the above struct...

NokiaLcd myLcd( myPins );

then start the LCD using...

myLcd.InitLcd();

Simple text output is achieved with either of these functions:

void DrawString(char* str);

void DrawChar(char character);

------

Better documentation, pre/post conditions, and extended draw functions are coming soon :)

Files at this revision

API Documentation at this revision

Comitter:
Fuzball
Date:
Fri Jan 10 19:57:40 2014 +0000
Parent:
1:e25ab356dc9b
Child:
3:41063eb2a040
Commit message:
Cleaned up some non-code stuff and updated to use the newer mbed libs

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbed.lib Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Jan 16 19:51:19 2012 +0000
+++ b/main.cpp	Fri Jan 10 19:57:40 2014 +0000
@@ -1,40 +1,40 @@
-// Project: Nokia5110 - Controlling a NK5110 display from an NXP LPC1768
-// File: main.cpp
-// Author: Chris Yan
-// Created: January, 2012
-// Revised: 
-//  Desc: A basic LCD output test which uses the NXP LPC1768's SPI interface to 
-//      display pixels, characters, and numbers on the Nokia 5110 LCD.
-//      Created using a sparkfun breakout board with integrated Phillips 8544 driver
-//      for 48x84 LCDs.
-
-#include "mbed.h"
-#include "NOKIA_5110.h"
-
-int main()
-{
-    // Init the data structures and NokiaLcd class
-    LcdPins myPins;
-    myPins.sce  = p8;
-    myPins.rst  = p9;
-    myPins.dc   = p10;
-    myPins.mosi = p11;
-    myPins.miso = NC;
-    myPins.sclk = p13;
-    
-    NokiaLcd myLcd( myPins );
-    
-    // Start the LCD
-    myLcd.InitLcd();
-    
-    // Draw a test pattern on the LCD and stall for 15 seconds
-    myLcd.TestLcd( 0xAA );
-    wait( 15 );
-    
-    // Turn off the LCD and enter an endless loop
-    myLcd.ShutdownLcd();
-    while( 1 )
-    {   
-        //dance
-    }
+// Project: Nokia5110 - Controlling a NK5110 display from an NXP LPC1768
+// File: main.cpp
+// Author: Chris Yan
+// Created: January, 2012
+// Revised: 
+//  Desc: A basic LCD output test which uses the NXP LPC1768's SPI interface to 
+//      display pixels, characters, and numbers on the Nokia 5110 LCD.
+//      Created using a sparkfun breakout board with integrated Phillips 8544 driver
+//      for 48x84 LCDs.
+
+#include "mbed.h"
+#include "NOKIA_5110.h"
+
+int main()
+{
+    // Init the data structures and NokiaLcd class
+    LcdPins myPins;
+    myPins.sce  = p8;
+    myPins.rst  = p9;
+    myPins.dc   = p10;
+    myPins.mosi = p11;
+    myPins.miso = NC;
+    myPins.sclk = p13;
+    
+    NokiaLcd myLcd( myPins );
+    
+    // Start the LCD
+    myLcd.InitLcd();
+
+    // Draw a test pattern on the LCD and stall for 15 seconds
+    myLcd.TestLcd( 0xAA );
+    wait( 15 );
+    
+    // Turn off the LCD and enter an endless loop
+    myLcd.ShutdownLcd();
+    while( 1 )
+    {   
+        //dance
+    }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jan 10 19:57:40 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5364839841bd
\ No newline at end of file
--- a/mbed.lib	Mon Jan 16 19:51:19 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/projects/libraries/svn/mbed/trunk@35
\ No newline at end of file