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.cpp	Wed Mar 28 16:04:25 2012 +0000
+++ b/SerialGraphicLCD.cpp	Wed Mar 28 16:33:27 2012 +0000
@@ -1,9 +1,13 @@
 #include "SerialGraphicLCD.h"
 
+#define XSIZE 6
+#define YSIZE 9
+
 SerialGraphicLCD::SerialGraphicLCD(PinName tx, PinName rx): 
     Serial(tx, rx)
 {
-    baud(115200); // default baud rate
+    baud(115200);               // default baud rate
+    resolution(LCD_128x64);     // default resolution
 }
 
 void SerialGraphicLCD::clear() {
@@ -11,7 +15,11 @@
     putc(0x00);
 }
 
-void SerialGraphicLCD::pos(int x, int y) {
+void SerialGraphicLCD::pos(int row, int col) {
+    posXY(XSIZE*col, _yMax-(YSIZE*row));
+}
+
+void SerialGraphicLCD::posXY(int x, int y) {
     putc(0x7c);
     putc(0x18);
     putc(x);
@@ -80,6 +88,23 @@
     putc(0x12);
 }
 
+void SerialGraphicLCD::resolution(int type) {
+    switch (type) {
+    case LCD_128x64 :
+        resolution(128, 64);
+        break;
+    case LCD_160x128 :
+        resolution(160, 128);
+        break;
+    }
+}
+
+void SerialGraphicLCD::resolution(int x, int y) {
+    _xMax = x;
+    _yMax = y;
+}
+
+
 void SerialGraphicLCD::lcdbaud(int b) {
     if (b > 0 && b < 7) {
         putc(0x7c);