Simple Electronic Angle Meter and Spirit Level.

Dependencies:   MMA8452 mbed

Embed: (wiki syntax)

« Back to documentation index

N5110 Class Reference

N5110 Class Reference

Library for interfacing with Nokia 5110 LCD display (https://www.sparkfun.com/products/10168) using the hardware SPI on the mbed. More...

#include <main.h>

Public Member Functions

 N5110 (PinName pwrPin, PinName scePin, PinName rstPin, PinName dcPin, PinName mosiPin, PinName sclkPin, PinName ledPin)
 Create a N5110 object connected to the specified pins.
void init ()
 Initialise display.
void turnOff ()
 Turn off.
void clear ()
 Clears.
void normalMode ()
 Turn on normal video mode (default) Black on white.
void inverseMode ()
 Turn on inverse video mode (default) White on black.
void setBrightness (float brightness)
 Set Brightness.
void printString (const char *str, int x, int y)
 Print String.
void setPixel (int x, int y)
 Set a Pixel.
void clearPixel (int x, int y)
 Clear a Pixel.
void refresh ()
 Refresh display.
void drawCircle (int x0, int y0, int radius, int fill)
 Draw Circle.
void drawLine (int x0, int y0, int x1, int y1, int type)
 Draw Line.

Detailed Description

Library for interfacing with Nokia 5110 LCD display (https://www.sparkfun.com/products/10168) using the hardware SPI on the mbed.

Acknowledgements to Chris Yan's Nokia_5110 Library.

Definition at line 49 of file main.h.


Constructor & Destructor Documentation

N5110 ( PinName  pwrPin,
PinName  scePin,
PinName  rstPin,
PinName  dcPin,
PinName  mosiPin,
PinName  sclkPin,
PinName  ledPin 
)

Create a N5110 object connected to the specified pins.

Functions used to display characters and shapes.

Parameters:
pwrPin connected to Vcc on the LCD display (pin 1)
scePin connected to chip enable (pin 3)
rstPin connected to reset (pin 4)
dcPin connected to data/command select (pin 5)
mosiPin connected to data input (MOSI) (pin 6)
sclkPin connected to serial clock (SCLK) (pin 7)
ledPin connected to LED backlight (must be PWM) (pin 8)

Acknowledgements to Dr.Craig A. Evans's code.

Definition at line 541 of file main.cpp.


Member Function Documentation

void clear (  )

Clears.

Clears the screen.

Definition at line 745 of file main.cpp.

void clearPixel ( int  x,
int  y 
)

Clear a Pixel.

This function clears pixel in the display. A call to refresh() must be made to update the display to reflect the change in pixels.

Parameters:
x- the x co-ordinate of the pixel (0 to 83)
y- the y co-ordinate of the pixel (0 to 47)

Definition at line 688 of file main.cpp.

void drawCircle ( int  x0,
int  y0,
int  radius,
int  fill 
)

Draw Circle.

This function draws a circle at the specified origin with specified radius to the display. Uses the midpoint circle algorithm.

See also:
http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
Parameters:
x0- x-coordinate of centre
y0- y-coordinate of centre
radius- radius of circle in pixels
fill- 0 transparent (w/outline), 1 filled black, 2 filled white (wo/outline)

Definition at line 763 of file main.cpp.

void drawLine ( int  x0,
int  y0,
int  x1,
int  y1,
int  type 
)

Draw Line.

This function draws a line between the specified points using linear interpolation.

Parameters:
x0- x-coordinate of first point
y0- y-coordinate of first point
x1- x-coordinate of last point
y1- y-coordinate of last point
type- 0 white,1 black,2 dotted

Definition at line 804 of file main.cpp.

void init (  )

Initialise display.

Powers up the display and turns on backlight (50% brightness default). Sets the display up in horizontal addressing mode and with normal video mode.

Definition at line 557 of file main.cpp.

void inverseMode (  )

Turn on inverse video mode (default) White on black.

Definition at line 589 of file main.cpp.

void normalMode (  )

Turn on normal video mode (default) Black on white.

Definition at line 582 of file main.cpp.

void printString ( const char *  str,
int  x,
int  y 
)

Print String.

Prints a string of characters to the display. String is cut-off after the 83rd pixel.

Parameters:
x- the column number (0 to 83)
y- the row number (0 to 5) - the display is split into 6 banks - each bank can be considered a row

Definition at line 717 of file main.cpp.

void refresh (  )

Refresh display.

This functions refreshes the display to reflect the current data in the buffer.

Definition at line 697 of file main.cpp.

void setBrightness ( float  brightness )

Set Brightness.

Sets brightness of LED backlight.

Parameters:
brightness- float in range 0.0 to 1.0

Definition at line 620 of file main.cpp.

void setPixel ( int  x,
int  y 
)

Set a Pixel.

This function sets a pixel in the display. A call to refresh() must be made to update the display to reflect the change in pixels.

Parameters:
x- the x co-ordinate of the pixel (0 to 83)
y- the y co-ordinate of the pixel (0 to 47)

Definition at line 680 of file main.cpp.

void turnOff (  )

Turn off.

Powers down the display and turns of the backlight. Needs to be reinitialised before being re-used.

Definition at line 603 of file main.cpp.