This library is designed to make it easy for anyone to get the Nokia 5110 84x48 display 3.3V module up and running without delay It provides a convenient interface for printing single characters or strings of characters and vertical bar graphs, all at various magnifications. It is free to use and modify. I accept NO liability for malfunctions or damage caused by this software I hope it is useful to the community and am open to suggestions for improvement.

Dependents:   5110_Display

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers N_5110_Display.h Source File

N_5110_Display.h

00001 #ifndef N_5110_Display_H
00002 #define N_5110_Display_H
00003 
00004 #include "mbed.h"
00005 
00006 /*
00007  * This library is designed to make it easy for anyone to get the Nokia 5110 display 3.3V module up and running without delay
00008  * It provides a convenient interface for printing single characters or strings of characters and vertical bar graphs, all at various magnifications.
00009  * It is free to use and modify. I accept NO liability for malfunctions or damage caused by this software
00010  * I hope it is useful to the community and am open to suggestions for improvement.
00011  *
00012  *
00013  * ---Example code---
00014  * 
00015  * #include "mbed.h"
00016  * #include "N_5110_Display.h"
00017  *
00018  * N_5110_Display Display( p5, p6, p7, p8, p9, p10 );
00019  *
00020  * int main()
00021  * {
00022  *     Display.setCharPos( 0, 0 );              //x pos = 0, y pos = 0
00023  *     Display.printString( 'Bar', 2, 3 );      //output string with char width 2, char height 3
00024  *
00025  *     Display.setCharPos( 0, 3 );              //x pos = 0, y pos = 3
00026  *     Display.printString( 'Graph', 2, 3 );    //output string with char width 2, char height 3
00027  *
00028  *     Display.setCharPos( 11, 0 );             //x pos = 11, y pos = 0 .... X pos is 11 to allow for a bar graph with width 3
00029  *     Display.VertBarGraph( 40, 3, 6 );        //generate a vertical bar graph 40% full with width = 3 char, height = 6 char
00030  *
00031  *     while (1)
00032  *     {
00033  *
00034  *     }
00035  * }
00036  *
00037  *
00038  * ---End of example code
00039 */
00040 class N_5110_Display {
00041 
00042     public:
00043 
00044         //mosi, miso, sclk, Data/Command, Reset, ChipSelect
00045         N_5110_Display(  PinName _mosi, PinName _miso, PinName _sclk, PinName _dc, PinName _reset, PinName _cs);
00046         int print1char( unsigned char c, unsigned char Xmag, unsigned char Ymag );
00047         void printString( char * str2prt, unsigned char Xmag, unsigned char Ymag);
00048         void VertBarGraph( int Percentage, unsigned char Xmag, unsigned char Ymag );
00049         void initDisplay( void );
00050         void clrDisp( void );
00051         int setCharPos( int x, int y );                                             //x axis position (0 to 13) y axis position (0 to 5)
00052         
00053     private:
00054     
00055         void clrMagArray( unsigned char Xmag, unsigned char Ymag, bool FullWidth );
00056         void magChar( unsigned char c, unsigned char Xmag, unsigned char Ymag );
00057         void smoothEdges( unsigned char Xmag, unsigned char Ymag );
00058         void setDispPos( int DispX, int DispY );                                    //DispX axis (0 to 84) DispY axis (0 to 5)
00059         int outputMagData (unsigned char Xmag, unsigned char Ymag, bool FulWidth);
00060 
00061         DigitalOut dc;
00062         DigitalOut rst;
00063         DigitalOut cs;
00064         SPI spi;
00065         unsigned char PixX, CharX, CharY;
00066         unsigned char magData[36][6];
00067 };
00068 
00069 
00070 #endif