Library for interfacing to Nokia 5110 LCD display with Image Loader (as found on the SparkFun website).
Diff: N5110.h
- Revision:
- 6:adb79338d40f
- Parent:
- 5:6ea180eef702
- Child:
- 7:3010f24e0a81
diff -r 6ea180eef702 -r adb79338d40f N5110.h --- a/N5110.h Sun Jan 26 20:18:45 2014 +0000 +++ b/N5110.h Mon Jan 27 18:41:45 2014 +0000 @@ -49,7 +49,27 @@ * * Example: * @code - * + + #include "mbed.h" + #include "N5110.h" + + // VCC,SCE,RST,D/C,MOSI,SCLK,LED + N5110 lcd(p7,p8,p9,p10,p11,p13,p26); + + int main() { + + // initialise display + lcd.init(); + // print a string in top-left corner + lcd.printString("Hello, World!",0,0); + // move cursor to 4th row + lcd.setXYAddress(0,3); + // print character + lcd.printChar('X'); + + while(1); + } + * @endcode */ class N5110 @@ -125,18 +145,53 @@ /** Print Character * * Sends a character to the display. Will be printed at the current address. - * X address is autoincremented by 1 to leave a pixel between successive characters + * X address is autoincremented by 1 to leave a pixel between successive characters. * @param c - the character to print. Can print ASCII as so printChar('C'). */ void printChar(char c); + /** 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. + * @param x - the x co-ordinate of the pixel (0 to 83) + * @param y - the y co-ordinate of the pixel (0 to 47) + */ void setPixel(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. + * @param x - the x co-ordinate of the pixel (0 to 83) + * @param y - the y co-ordinate of the pixel (0 to 47) + */ void clearPixel(int x, int y); + + /** Get a Pixel + * + * This function gets the status of a pixel in the display. + * @param x - the x co-ordinate of the pixel (0 to 83) + * @param y - the y co-ordinate of the pixel (0 to 47) + * @returns + * 0 - pixel is clear + * non-zero - pixel is set + */ unsigned char getPixel(int x, int y); + /** Refresh display + * + * This functions refreshes the display to reflect the current data in the buffer. + */ + void refresh(); - void refreshDisplay(); - void clearBuffer(); + /** Randomise buffer + * + * This function fills the buffer with random data. Can be used to test the display. + * A call to refresh() must be made to update the display to reflect the change in pixels. + * The seed is not set and so the generated pattern will probably be the same each time. + * TODO: Randomise the seed - maybe using the noise on the AnalogIn pins. + */ void randomiseBuffer(); private: @@ -144,6 +199,7 @@ void turnOn(); void reset(); void clearRAM(); + void clearBuffer(); void sendCommand(unsigned char command); void sendData(unsigned char data);