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 :)

Committer:
Fuzball
Date:
Mon Jan 16 19:47:48 2012 +0000
Revision:
0:fbba596f1039
Child:
2:e448efb1fa68

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Fuzball 0:fbba596f1039 1 // Project: Nokia5110 - Controlling a NK5110 display from an NXP LPC1768
Fuzball 0:fbba596f1039 2 // File: main.cpp
Fuzball 0:fbba596f1039 3 // Author: Chris Yan
Fuzball 0:fbba596f1039 4 // Created: January, 2012
Fuzball 0:fbba596f1039 5 // Revised:
Fuzball 0:fbba596f1039 6 // Desc: A basic LCD output test which uses the NXP LPC1768's SPI interface to
Fuzball 0:fbba596f1039 7 // display pixels, characters, and numbers on the Nokia 5110 LCD.
Fuzball 0:fbba596f1039 8 // Created using a sparkfun breakout board with integrated Phillips 8544 driver
Fuzball 0:fbba596f1039 9 // for 48x84 LCDs.
Fuzball 0:fbba596f1039 10
Fuzball 0:fbba596f1039 11 #include "mbed.h"
Fuzball 0:fbba596f1039 12 #include "NOKIA_5110.h"
Fuzball 0:fbba596f1039 13
Fuzball 0:fbba596f1039 14 int main()
Fuzball 0:fbba596f1039 15 {
Fuzball 0:fbba596f1039 16 // Init the data structures and NokiaLcd class
Fuzball 0:fbba596f1039 17 LcdPins myPins;
Fuzball 0:fbba596f1039 18 myPins.sce = p8;
Fuzball 0:fbba596f1039 19 myPins.rst = p9;
Fuzball 0:fbba596f1039 20 myPins.dc = p10;
Fuzball 0:fbba596f1039 21 myPins.mosi = p11;
Fuzball 0:fbba596f1039 22 myPins.miso = NC;
Fuzball 0:fbba596f1039 23 myPins.sclk = p13;
Fuzball 0:fbba596f1039 24
Fuzball 0:fbba596f1039 25 NokiaLcd myLcd( myPins );
Fuzball 0:fbba596f1039 26
Fuzball 0:fbba596f1039 27 // Start the LCD
Fuzball 0:fbba596f1039 28 myLcd.InitLcd();
Fuzball 0:fbba596f1039 29
Fuzball 0:fbba596f1039 30 // Draw a test pattern on the LCD and stall for 15 seconds
Fuzball 0:fbba596f1039 31 myLcd.TestLcd( 0xAA );
Fuzball 0:fbba596f1039 32 wait( 15 );
Fuzball 0:fbba596f1039 33
Fuzball 0:fbba596f1039 34 // Turn off the LCD and enter an endless loop
Fuzball 0:fbba596f1039 35 myLcd.ShutdownLcd();
Fuzball 0:fbba596f1039 36 while( 1 )
Fuzball 0:fbba596f1039 37 {
Fuzball 0:fbba596f1039 38 //dance
Fuzball 0:fbba596f1039 39 }
Fuzball 0:fbba596f1039 40 }