An interface to the Sparkfun Serial Graphic LCD, LCD-09351; and Graphic LCD Serial Backpack, LCD-09352. Derived class from Serial so that you can conveniently send text to the display with printf(), putc(), etc.
Revision 3:dff460658aed, committed 2012-04-11
- Comitter:
- shimniok
- Date:
- Wed Apr 11 07:13:52 2012 +0000
- Parent:
- 2:84b78506add6
- Commit message:
- Updated to support both stock SFE firmware and summoningdark firmware
Changed in this revision
SerialGraphicLCD.cpp | Show annotated file Show diff for this revision Revisions of this file |
SerialGraphicLCD.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 84b78506add6 -r dff460658aed SerialGraphicLCD.cpp --- a/SerialGraphicLCD.cpp Thu Mar 29 18:33:42 2012 +0000 +++ b/SerialGraphicLCD.cpp Wed Apr 11 07:13:52 2012 +0000 @@ -4,7 +4,14 @@ #define YSIZE 9 SerialGraphicLCD::SerialGraphicLCD(PinName tx, PinName rx): - Serial(tx, rx) + Serial(tx, rx), _firmware(SFE_FW) +{ + baud(115200); // default baud rate + resolution(LCD_128x64); // default resolution +} + +SerialGraphicLCD::SerialGraphicLCD(PinName tx, PinName rx, int firmware): + Serial(tx, rx), _firmware(firmware) { baud(115200); // default baud rate resolution(LCD_128x64); // default resolution @@ -16,7 +23,10 @@ } void SerialGraphicLCD::pos(int col, int row) { - posXY(XSIZE*col, _yMax-(YSIZE*row)-1); + if (_firmware == SD_FW) + posXY(XSIZE*col, (YSIZE*row)); + else if (_firmware == SFE_FW) + posXY(XSIZE*col, _yMax-(YSIZE*row)-1); } void SerialGraphicLCD::posXY(int x, int y) {
diff -r 84b78506add6 -r dff460658aed SerialGraphicLCD.h --- a/SerialGraphicLCD.h Thu Mar 29 18:33:42 2012 +0000 +++ b/SerialGraphicLCD.h Wed Apr 11 07:13:52 2012 +0000 @@ -9,6 +9,10 @@ #include "mbed.h" +/** Firmware modes */ +#define SFE_FW 0 // Stock SFE firmware +#define SD_FW 1 // summoningdark firmware http://sourceforge.net/projects/serialglcd/ + /** LCD Baud Rates */ #define LCD_4800 1 #define LCD_9600 2 @@ -57,9 +61,20 @@ /** Create a new interface to a Serial Graphic LCD * Note that the display lower left corner is coordinates 0, 0. * Rows start at the top at 0, columns start at the left at 0. + * @param tx -- mbed transmit pin + * @param rx -- mbed receive pin */ SerialGraphicLCD(PinName tx, PinName rx); + /** Create a new interface to a Serial Graphic LCD + * Note that the display lower left corner is coordinates 0, 0. + * Rows start at the top at 0, columns start at the left at 0. + * @param tx -- mbed transmit pin + * @param rx -- mbed receive pin + * @param firmware -- SFE_FW, stock firmware or SD_FW, summoningdark firmware + */ + SerialGraphicLCD(PinName tx, PinName rx, int firmware); + /** clear the screen */ void clear(void); @@ -160,6 +175,7 @@ private: int _xMax; int _yMax; + int _firmware; };