Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
N_5110_Display.h@0:bb60966d6de1, 2011-10-11 (annotated)
- Committer:
- Fenwiz
- Date:
- Tue Oct 11 01:14:45 2011 +0000
- Revision:
- 0:bb60966d6de1
Revision 1.00. initial release. stable and fairly robust
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Fenwiz | 0:bb60966d6de1 | 1 | #ifndef N_5110_Display_H |
Fenwiz | 0:bb60966d6de1 | 2 | #define N_5110_Display_H |
Fenwiz | 0:bb60966d6de1 | 3 | |
Fenwiz | 0:bb60966d6de1 | 4 | #include "mbed.h" |
Fenwiz | 0:bb60966d6de1 | 5 | |
Fenwiz | 0:bb60966d6de1 | 6 | /* |
Fenwiz | 0:bb60966d6de1 | 7 | * This library is designed to make it easy for anyone to get the Nokia 5110 display 3.3V module up and running without delay |
Fenwiz | 0:bb60966d6de1 | 8 | * It provides a convenient interface for printing single characters or strings of characters and vertical bar graphs, all at various magnifications. |
Fenwiz | 0:bb60966d6de1 | 9 | * It is free to use and modify. I accept NO liability for malfunctions or damage caused by this software |
Fenwiz | 0:bb60966d6de1 | 10 | * I hope it is useful to the community and am open to suggestions for improvement. |
Fenwiz | 0:bb60966d6de1 | 11 | * |
Fenwiz | 0:bb60966d6de1 | 12 | * |
Fenwiz | 0:bb60966d6de1 | 13 | * ---Example code--- |
Fenwiz | 0:bb60966d6de1 | 14 | * |
Fenwiz | 0:bb60966d6de1 | 15 | * #include "mbed.h" |
Fenwiz | 0:bb60966d6de1 | 16 | * #include "N_5110_Display.h" |
Fenwiz | 0:bb60966d6de1 | 17 | * |
Fenwiz | 0:bb60966d6de1 | 18 | * N_5110_Display Display( p5, p6, p7, p8, p9, p10 ); |
Fenwiz | 0:bb60966d6de1 | 19 | * |
Fenwiz | 0:bb60966d6de1 | 20 | * int main() |
Fenwiz | 0:bb60966d6de1 | 21 | * { |
Fenwiz | 0:bb60966d6de1 | 22 | * Display.setCharPos( 0, 0 ); //x pos = 0, y pos = 0 |
Fenwiz | 0:bb60966d6de1 | 23 | * Display.printString( 'Bar', 2, 3 ); //output string with char width 2, char height 3 |
Fenwiz | 0:bb60966d6de1 | 24 | * |
Fenwiz | 0:bb60966d6de1 | 25 | * Display.setCharPos( 0, 3 ); //x pos = 0, y pos = 3 |
Fenwiz | 0:bb60966d6de1 | 26 | * Display.printString( 'Graph', 2, 3 ); //output string with char width 2, char height 3 |
Fenwiz | 0:bb60966d6de1 | 27 | * |
Fenwiz | 0:bb60966d6de1 | 28 | * Display.setCharPos( 11, 0 ); //x pos = 11, y pos = 0 .... X pos is 11 to allow for a bar graph with width 3 |
Fenwiz | 0:bb60966d6de1 | 29 | * Display.VertBarGraph( 40, 3, 6 ); //generate a vertical bar graph 40% full with width = 3 char, height = 6 char |
Fenwiz | 0:bb60966d6de1 | 30 | * |
Fenwiz | 0:bb60966d6de1 | 31 | * while (1) |
Fenwiz | 0:bb60966d6de1 | 32 | * { |
Fenwiz | 0:bb60966d6de1 | 33 | * |
Fenwiz | 0:bb60966d6de1 | 34 | * } |
Fenwiz | 0:bb60966d6de1 | 35 | * } |
Fenwiz | 0:bb60966d6de1 | 36 | * |
Fenwiz | 0:bb60966d6de1 | 37 | * |
Fenwiz | 0:bb60966d6de1 | 38 | * ---End of example code |
Fenwiz | 0:bb60966d6de1 | 39 | */ |
Fenwiz | 0:bb60966d6de1 | 40 | class N_5110_Display { |
Fenwiz | 0:bb60966d6de1 | 41 | |
Fenwiz | 0:bb60966d6de1 | 42 | public: |
Fenwiz | 0:bb60966d6de1 | 43 | |
Fenwiz | 0:bb60966d6de1 | 44 | //mosi, miso, sclk, Data/Command, Reset, ChipSelect |
Fenwiz | 0:bb60966d6de1 | 45 | N_5110_Display( PinName _mosi, PinName _miso, PinName _sclk, PinName _dc, PinName _reset, PinName _cs); |
Fenwiz | 0:bb60966d6de1 | 46 | int print1char( unsigned char c, unsigned char Xmag, unsigned char Ymag ); |
Fenwiz | 0:bb60966d6de1 | 47 | void printString( char * str2prt, unsigned char Xmag, unsigned char Ymag); |
Fenwiz | 0:bb60966d6de1 | 48 | void VertBarGraph( int Percentage, unsigned char Xmag, unsigned char Ymag ); |
Fenwiz | 0:bb60966d6de1 | 49 | void initDisplay( void ); |
Fenwiz | 0:bb60966d6de1 | 50 | void clrDisp( void ); |
Fenwiz | 0:bb60966d6de1 | 51 | int setCharPos( int x, int y ); //x axis position (0 to 13) y axis position (0 to 5) |
Fenwiz | 0:bb60966d6de1 | 52 | |
Fenwiz | 0:bb60966d6de1 | 53 | private: |
Fenwiz | 0:bb60966d6de1 | 54 | |
Fenwiz | 0:bb60966d6de1 | 55 | void clrMagArray( unsigned char Xmag, unsigned char Ymag, bool FullWidth ); |
Fenwiz | 0:bb60966d6de1 | 56 | void magChar( unsigned char c, unsigned char Xmag, unsigned char Ymag ); |
Fenwiz | 0:bb60966d6de1 | 57 | void smoothEdges( unsigned char Xmag, unsigned char Ymag ); |
Fenwiz | 0:bb60966d6de1 | 58 | void setDispPos( int DispX, int DispY ); //DispX axis (0 to 84) DispY axis (0 to 5) |
Fenwiz | 0:bb60966d6de1 | 59 | int outputMagData (unsigned char Xmag, unsigned char Ymag, bool FulWidth); |
Fenwiz | 0:bb60966d6de1 | 60 | |
Fenwiz | 0:bb60966d6de1 | 61 | DigitalOut dc; |
Fenwiz | 0:bb60966d6de1 | 62 | DigitalOut rst; |
Fenwiz | 0:bb60966d6de1 | 63 | DigitalOut cs; |
Fenwiz | 0:bb60966d6de1 | 64 | SPI spi; |
Fenwiz | 0:bb60966d6de1 | 65 | unsigned char PixX, CharX, CharY; |
Fenwiz | 0:bb60966d6de1 | 66 | unsigned char magData[36][6]; |
Fenwiz | 0:bb60966d6de1 | 67 | }; |
Fenwiz | 0:bb60966d6de1 | 68 | |
Fenwiz | 0:bb60966d6de1 | 69 | |
Fenwiz | 0:bb60966d6de1 | 70 | #endif |