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.

Dependents:   DataBus2018

Revision:
1:2f436b8aebf4
Parent:
0:a3d518d2f36f
Child:
2:84b78506add6
--- a/SerialGraphicLCD.h	Wed Mar 28 16:04:25 2012 +0000
+++ b/SerialGraphicLCD.h	Wed Mar 28 16:33:27 2012 +0000
@@ -9,6 +9,7 @@
 
 #include "mbed.h"
 
+/** LCD Baud Rates */
 #define LCD_4800   1
 #define LCD_9600   2
 #define LCD_19200  3
@@ -16,6 +17,10 @@
 #define LCD_57600  5
 #define LCD_115200 6
 
+/** LCD Types */
+#define LCD_128x64  1
+#define LCD_160x128 2
+
 /** 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 printf(), putc(), etc to the display.
@@ -50,19 +55,28 @@
 class SerialGraphicLCD: public Serial {
 public:
     /** 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.
      */
     SerialGraphicLCD(PinName tx, PinName rx);
     
     /** clear the screen
      */
     void clear(void);
+
+    /** set text position in rows, columns
+     *
+     * @param row is the row coordinate
+     * @param col is the col coordinate
+     */
+    void pos(int row, int col);
     
-    /** set text position
+    /** set text position in x, y coordinates
      *
      * @param x is the x coordinate
      * @param y is the y coordinate
      */
-    void pos(int x, int y);
+    void posXY(int x, int y);
     
     /** set or erase a pixel
      *
@@ -125,6 +139,27 @@
      * @param b is the baud rate, LCD_4800, LCD_9600, LCD_19200, LCD_38400, LCD_57600 or LCD_115200
      */
     void lcdbaud(int b);
+    
+    
+    /** sets the resolution of the LCD so that the pos() call works properly
+     * defaults to LCD_128x64.
+     *
+     * @param type is the type of LCD, either LCD_128x64 or LCD_160x128
+     */
+    void resolution(int type);
+
+    /** sets the resolution of the LCD in x and y coordinates which determines
+     * how rows and columns are calculated in the pos() call.  Defaults to
+     * x=128, y=64
+     *
+     * @param x is the number of horizontal pixels
+     * @param y is the number of vertical pixels
+     */
+    void resolution(int x, int y);
+    
+    private:
+        int _xMax;
+        int _yMax;
 };