Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
simon
Date:
Tue Sep 15 10:02:04 2009 +0000
Commit message:

Changed in this revision

Displays.h Show annotated file Show diff for this revision Revisions of this file
EA_QVGALCD.cpp Show annotated file Show diff for this revision Revisions of this file
EA_QVGALCD.h Show annotated file Show diff for this revision Revisions of this file
GraphicsDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
GraphicsDisplay.h Show annotated file Show diff for this revision Revisions of this file
MobileLCD.cpp Show annotated file Show diff for this revision Revisions of this file
MobileLCD.h Show annotated file Show diff for this revision Revisions of this file
Terminal.cpp Show annotated file Show diff for this revision Revisions of this file
Terminal.h Show annotated file Show diff for this revision Revisions of this file
TextDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
TextDisplay.h Show annotated file Show diff for this revision Revisions of this file
TextLCD.cpp Show annotated file Show diff for this revision Revisions of this file
TextLCD.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r cc002f2fad97 Displays.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Displays.h	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,24 @@
+/* mbed Display Library
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * A library for providing a common base class for Text and Graphics
+ * displays, to provide commonality and simplify porting of new displays 
+ */
+
+#ifndef MBED_DISPLAYS_H
+#define MBED_DISPLAYS_H
+
+// Display Base Classes
+#include "TextDisplay.h"
+#include "GraphicsDisplay.h"
+
+// Text Displays
+#include "TextLCD.h"
+#include "Terminal.h"
+
+// Graphics Displays
+#include "MobileLCD.h"
+#include "EA_QVGALCD.h"
+
+#endif
diff -r 000000000000 -r cc002f2fad97 EA_QVGALCD.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EA_QVGALCD.cpp	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,184 @@
+/* mbed Embedded Artists QVGA LCD Display Library
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+  
+#include "EA_QVGALCD.h"
+
+EA_QVGALCD::EA_QVGALCD(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst) : _spi(mosi, miso, sclk), _cs(cs), _rst(rst) {
+
+	_spi.frequency(15000000);
+	_spi.format(9);
+	_cs = 1;
+	_rst = 0;
+	wait(0.001);
+	_rst = 1;
+	wait(0.001);
+
+// 3-wire SPI Format (see 7.1 c)
+// =================
+//
+// The 3-wire spi format uses 9-bit messages of the form:
+//
+// [Data/nControl D7 D6 D5 D4 D3 D2 D1 D0]
+//  (first)                         (last)
+// 
+// Most commands and data are 16-bit, so are achieved by sending two
+// command messages, [ CommandMSB | CommandLSB ], or two data messages
+// [ DataMSB | DataLSB ].
+//
+// Controlling the Display
+// =======================
+// 
+// The Index Register is used to setup which configuration register is
+// modified. This address is changed by sending a command message:
+//
+//     command [ 0 | index[7:0] ]
+//
+// The data that follows update the register.
+//
+//
+// 0x07 - Display Control
+// ======================
+//
+// [ 0 0 0 PT1 PT0 VLE2 VLE1 SPT | 0 0 GON DTE CM 0 D1 D0 ]
+// where:
+//   PT[1:0]  - ? (0)
+//   VLE[2:1] - ? (0)
+//   SPT      - ? (0)
+//   CM       - 8 colour mode enable
+//   GON      - 0 = Gate-off level VGH 
+//   DTE      - 0 = All gate outputs become VGL
+//              1 = Selected gate outputs become VGH
+//   D[1:0]   - D1 = Display enable
+//              D0 = Display operating
+
+// 15.5 On Sequence
+//
+// -> Set R07h: GON =1, DTE = 0, D[1:0] = 01
+    _cs = 0;
+	config(0x7
+	  			, 1 << 5 // GON
+				| 0 << 4 // DTE 
+				| 0 << 3 // CM
+				| 1 << 0 // D[1:0] = 01 - operate, but disp off
+				);
+// -> Set R00h to 0001h
+// R00h [ 00000000 | 0000000 OSCEN ]
+// OSCEN - 1 = oscillator enabled
+
+	config(0x0, 1);
+
+// -> Set R07h: GON = 1, DTE = 0, D[1:0] = 11	
+
+	config(0x7
+	  			, 1 << 5 // GON
+				| 1 << 4 // DTE 
+				| 0 << 3 // CM
+				| 3 << 0 // D[1:0] = 3 - operate, display on
+				);
+				
+// -> Set R10h at 0000h : Exit sleep mode				
+// R10h [ 00000000 | 0000000 SLP ]
+// SLP = enter sleep mode (retain but no function)
+
+	config(0x10, 0);
+
+// -> wait 30ms
+	wait(0.030);
+	
+// -> LCD driver AC setting (R02h)
+    config(0x02, 0x0600);
+    config(0x01, 0x2b3f);  // 1011
+    config(0x25, 0xa000);	// 70Hz freq
+
+// -> Entry Mode setting (R11h)
+// R11h [ VSMode DFM1 DFM0 TRANS OEDef WMode DMode1 DMode0 | TY1 TY0 ID1 ID0 AM LG2 LG1 LG0 ]
+//  VSMode = freq dependant on VSYNC
+//  DFM[1:0] colour display mode 11 - 65k, 10 - 262k
+//  TRANS - allow transparent display
+//  OEDef:
+//    When OEDef = 1, OE defines the display window.
+//    When OEDef = 0, the display window is defined by R4Eh and R4Fh.
+//  WMode: Select the source of data to write in the RAM.
+//     0 Normal data bus (POR)
+//     1 Generic interface
+//  Dmode - where to show from (0 = ram)
+// TY - 262k mode options
+// ID[1:0] [ VERTICAL HORIZONTAL ] increment = 1 decrement = 0
+// AM - 0 = horizontal display, 1 = vertical
+// LG - do maths n written data
+
+	config(0x11
+				, 0 << 15 // VSMode
+				| 3 << 13 // DFM[1:0]
+				| 0 << 12 // TRANS
+				| 1 << 11 // OEDef
+				| 0 << 10 // WMode
+				| 0 << 8  // DMode[1:0]
+				| 0 << 6  // TY[1:0]
+				| 3 << 4  // ID[1:0]
+				| 0 << 3  // AM 
+				| 0 << 0  // LG[2:0]
+				);
+    _cs = 1;
+    
+    cls();
+}
+
+void EA_QVGALCD::pixel(int x, int y, int colour) {
+    window(x, y, 1, 1);
+    putp(colour);
+}
+     
+int EA_QVGALCD::width() { return 240; }
+int EA_QVGALCD::height() { return 320; }
+     
+
+void EA_QVGALCD::command(int value) {
+	_spi.write(value & 0xFF);
+}
+
+void EA_QVGALCD::data(int value) {
+	_spi.write(value | 0x100);
+}
+
+void EA_QVGALCD::config(int index, int value) {
+	command(0);
+	command(index);
+	data(value >> 8);
+	data(value);
+}
+
+
+void EA_QVGALCD::window(int x, int y, int w, int h) {
+    _cs = 0;
+
+	int hstart = x;
+	int hend = x + w - 1;
+	int vstart = y;
+	int vend = y + h - 1;
+	config(0x44, (hend << 8) | hstart);
+	config(0x45, vstart);
+	config(0x46, vend);
+
+	config(0x4E, hstart & 0xFF);
+    config(0x4F, vstart & 0x1FF);
+	command(0);
+	command(0x22);
+
+    _cs = 1;
+}
+
+void EA_QVGALCD::putp(int colour) {
+    _cs = 0;
+	int top    = ((colour >> (8+8)) & 0xF8) // r7-3
+	           | ((colour >> (5+8)) & 0x07); // g7-5 
+	int bottom = ((colour >> 5) & 0xE0) // g4-2
+			   | ((colour >> 3) & 0x1F); // b7-3
+				   
+ 	data(top);
+	data(bottom);
+    _cs = 1; 
+}
+
diff -r 000000000000 -r cc002f2fad97 EA_QVGALCD.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EA_QVGALCD.h	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,37 @@
+/* mbed Embedded Artists QVGA LCD Display Library
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Implements a QVGA LCD display from Embedded Artisits
+ */
+
+#ifndef MBED_EA_QVGALCD_H
+#define MBED_EA_QVGALCD_H
+ 
+#include "GraphicsDisplay.h"
+
+class EA_QVGALCD : public GraphicsDisplay {
+
+public:
+
+    EA_QVGALCD(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst);
+
+    virtual void pixel(int x, int y, int colour);
+    virtual int width();
+    virtual int height();
+    virtual void window(int x, int y, int w, int h);
+    virtual void putp(int colour);
+    
+protected:
+
+     void command(int value);
+     void data(int value);
+    void config(int index, int value);
+           
+    SPI _spi;
+    DigitalOut _cs;    
+    DigitalOut _rst;
+    
+};
+
+#endif
diff -r 000000000000 -r cc002f2fad97 GraphicsDisplay.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GraphicsDisplay.cpp	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,175 @@
+/* mbed GraphicsDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+ 
+#include "GraphicsDisplay.h"
+
+const unsigned char FONT8x8[97][8] = {
+0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, // columns, rows, num_bytes_per_char
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space 0x20
+0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00, // !
+0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00, // "
+0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00, // #
+0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00, // $
+0x00,0x63,0x66,0x0C,0x18,0x33,0x63,0x00, // %
+0x1C,0x36,0x1C,0x3B,0x6E,0x66,0x3B,0x00, // &
+0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00, // '
+0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x00, // (
+0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x00, // )
+0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, // *
+0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00, // +
+0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30, // ,
+0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00, // -
+0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, // .
+0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, // / (forward slash)
+0x3E,0x63,0x63,0x6B,0x63,0x63,0x3E,0x00, // 0 0x30
+0x18,0x38,0x58,0x18,0x18,0x18,0x7E,0x00, // 1
+0x3C,0x66,0x06,0x1C,0x30,0x66,0x7E,0x00, // 2
+0x3C,0x66,0x06,0x1C,0x06,0x66,0x3C,0x00, // 3
+0x0E,0x1E,0x36,0x66,0x7F,0x06,0x0F,0x00, // 4
+0x7E,0x60,0x7C,0x06,0x06,0x66,0x3C,0x00, // 5
+0x1C,0x30,0x60,0x7C,0x66,0x66,0x3C,0x00, // 6
+0x7E,0x66,0x06,0x0C,0x18,0x18,0x18,0x00, // 7
+0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00, // 8
+0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00, // 9
+0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00, // :
+0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30, // ;
+0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x00, // <
+0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00, // =
+0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x00, // >
+0x3C,0x66,0x06,0x0C,0x18,0x00,0x18,0x00, // ?
+0x3E,0x63,0x6F,0x69,0x6F,0x60,0x3E,0x00, // @ 0x40
+0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x00, // A
+0x7E,0x33,0x33,0x3E,0x33,0x33,0x7E,0x00, // B
+0x1E,0x33,0x60,0x60,0x60,0x33,0x1E,0x00, // C
+0x7C,0x36,0x33,0x33,0x33,0x36,0x7C,0x00, // D
+0x7F,0x31,0x34,0x3C,0x34,0x31,0x7F,0x00, // E
+0x7F,0x31,0x34,0x3C,0x34,0x30,0x78,0x00, // F
+0x1E,0x33,0x60,0x60,0x67,0x33,0x1F,0x00, // G
+0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00, // H
+0x3C,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // I
+0x0F,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, // J
+0x73,0x33,0x36,0x3C,0x36,0x33,0x73,0x00, // K
+0x78,0x30,0x30,0x30,0x31,0x33,0x7F,0x00, // L
+0x63,0x77,0x7F,0x7F,0x6B,0x63,0x63,0x00, // M
+0x63,0x73,0x7B,0x6F,0x67,0x63,0x63,0x00, // N
+0x3E,0x63,0x63,0x63,0x63,0x63,0x3E,0x00, // O
+0x7E,0x33,0x33,0x3E,0x30,0x30,0x78,0x00, // P 0x50
+0x3C,0x66,0x66,0x66,0x6E,0x3C,0x0E,0x00, // Q
+0x7E,0x33,0x33,0x3E,0x36,0x33,0x73,0x00, // R
+0x3C,0x66,0x30,0x18,0x0C,0x66,0x3C,0x00, // S
+0x7E,0x5A,0x18,0x18,0x18,0x18,0x3C,0x00, // T
+0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x00, // U
+0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00, // V
+0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, // W
+0x63,0x63,0x36,0x1C,0x1C,0x36,0x63,0x00, // X
+0x66,0x66,0x66,0x3C,0x18,0x18,0x3C,0x00, // Y
+0x7F,0x63,0x46,0x0C,0x19,0x33,0x7F,0x00, // Z
+0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00, // [
+0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, // \ (back slash)
+0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00, // ]
+0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, // ^
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, // _
+0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00, // ` 0x60
+0x00,0x00,0x3C,0x06,0x3E,0x66,0x3B,0x00, // a
+0x70,0x30,0x3E,0x33,0x33,0x33,0x6E,0x00, // b
+0x00,0x00,0x3C,0x66,0x60,0x66,0x3C,0x00, // c
+0x0E,0x06,0x3E,0x66,0x66,0x66,0x3B,0x00, // d
+0x00,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00, // e
+0x1C,0x36,0x30,0x78,0x30,0x30,0x78,0x00, // f
+0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x7C, // g
+0x70,0x30,0x36,0x3B,0x33,0x33,0x73,0x00, // h
+0x18,0x00,0x38,0x18,0x18,0x18,0x3C,0x00, // i
+0x06,0x00,0x06,0x06,0x06,0x66,0x66,0x3C, // j
+0x70,0x30,0x33,0x36,0x3C,0x36,0x73,0x00, // k
+0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // l
+0x00,0x00,0x66,0x7F,0x7F,0x6B,0x63,0x00, // m
+0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x00, // n
+0x00,0x00,0x3C,0x66,0x66,0x66,0x3C,0x00, // o
+0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x78, // p
+0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x0F, // q
+0x00,0x00,0x6E,0x3B,0x33,0x30,0x78,0x00, // r
+0x00,0x00,0x3E,0x60,0x3C,0x06,0x7C,0x00, // s
+0x08,0x18,0x3E,0x18,0x18,0x1A,0x0C,0x00, // t
+0x00,0x00,0x66,0x66,0x66,0x66,0x3B,0x00, // u
+0x00,0x00,0x66,0x66,0x66,0x3C,0x18,0x00, // v
+0x00,0x00,0x63,0x6B,0x7F,0x7F,0x36,0x00, // w
+0x00,0x00,0x63,0x36,0x1C,0x36,0x63,0x00, // x
+0x00,0x00,0x66,0x66,0x66,0x3E,0x06,0x7C, // y
+0x00,0x00,0x7E,0x4C,0x18,0x32,0x7E,0x00, // z
+0x0E,0x18,0x18,0x70,0x18,0x18,0x0E,0x00, // {
+0x0C,0x0C,0x0C,0x00,0x0C,0x0C,0x0C,0x00, // |
+0x70,0x18,0x18,0x0E,0x18,0x18,0x70,0x00, // }
+0x3B,0x6E,0x00,0x00,0x00,0x00,0x00,0x00, // ~
+0x1C,0x36,0x36,0x1C,0x00,0x00,0x00,0x00}; // DEL
+	
+GraphicsDisplay::GraphicsDisplay() {
+	foreground(0x00FFFFFF);
+	background(0x00000000);
+}
+	
+void GraphicsDisplay::character(int column, int row, int value) { 
+	blitbit(column * 8, row * 8, 8, 8, (char*)&(FONT8x8[value - 0x1F][0]));
+}
+
+void GraphicsDisplay::window(int x, int y, int w, int h) {
+    // current pixel location
+    _x = x;
+    _y = y;
+    // window settings
+    _x1 = x;
+    _x2 = x + w - 1;
+    _y1 = y;
+    _y2 = y + h - 1;
+}
+    
+void GraphicsDisplay::putp(int colour) {
+    // put pixel at current pixel location
+    pixel(_x, _y, colour);
+    // update pixel location based on window settings
+    _x++;
+    if(_x > _x2) {
+        _x = _x1;
+        _y++;
+        if(_y > _y2) {
+            _y = _y1;
+        }
+    }
+}
+
+void GraphicsDisplay::fill(int x, int y, int w, int h, int colour) { 
+    window(x, y, w, h);
+    for(int i=0; i<w*h; i++) {
+        putp(colour);
+    }
+}
+    
+void GraphicsDisplay::cls() {
+    fill(0, 0, width(), height(), _background);
+}
+    
+void GraphicsDisplay::blit(int x, int y, int w, int h, const int *colour) { 
+    window(x, y, w, h);
+    for(int i=0; i<w*h; i++) {
+        putp(colour[i]);
+    }
+}
+    
+void GraphicsDisplay::blitbit(int x, int y, int w, int h, const char* colour) {
+    window(x, y, w, h);
+    for(int i = 0; i < w*h; i++) {
+        char byte = colour[i >> 3];
+        int offset = i & 0x7;
+        int c = ((byte << offset) & 0x80) ? _foreground : _background;
+        putp(c);
+    }
+}
+    
+int GraphicsDisplay::columns() { 
+    return width() / 8; 
+}
+
+int GraphicsDisplay::rows() { 
+	return height() / 8; 
+}
diff -r 000000000000 -r cc002f2fad97 GraphicsDisplay.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GraphicsDisplay.h	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,55 @@
+/* mbed GraphicsDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * A library for providing a common base class for Graphics displays
+ * To port a new display, derive from this class and implement
+ * the constructor (setup the display), pixel (put a pixel
+ * at a location), width and height functions. Everything else
+ * (locate, printf, putc, cls, window, putp, fill, blit, blitbit) 
+ * will come for free. You can also provide a specialised implementation
+ * of window and putp to speed up the results
+ */
+
+#ifndef MBED_GRAPHICSDISPLAY_H
+#define MBED_GRAPHICSDISPLAY_H
+
+#include "TextDisplay.h"
+
+class GraphicsDisplay : public TextDisplay {
+
+public: 		
+ 	 	
+ 	GraphicsDisplay();
+ 	
+    virtual void pixel(int x, int y, int colour) = 0;
+    virtual int width() = 0;
+    virtual int height() = 0;
+        
+    virtual void window(int x, int y, int w, int h);
+    virtual void putp(int colour);
+    
+    virtual void cls();
+    virtual void fill(int x, int y, int w, int h, int colour);
+    virtual void blit(int x, int y, int w, int h, const int *colour);    
+    virtual void blitbit(int x, int y, int w, int h, const char* colour);
+    
+    virtual void character(int column, int row, int value);
+    virtual int columns();
+    virtual int rows();
+    
+protected:
+
+    // pixel location
+    short _x;
+    short _y;
+    
+    // window location
+    short _x1;
+    short _x2;
+    short _y1;
+    short _y2;
+
+};
+
+#endif
diff -r 000000000000 -r cc002f2fad97 MobileLCD.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MobileLCD.cpp	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,102 @@
+/* mbed MobileLCD (Sparkfun Nokia) Display Library
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+  
+#include "MobileLCD.h"
+
+MobileLCD::MobileLCD(PinName mosi, PinName sclk, PinName cs, PinName rst) : _spi(mosi, NC, sclk), _cs(cs), _rst(rst) {
+    _cs = 1;
+    _rst = 0;
+    _spi.format(9);
+    _spi.frequency(5000000);
+    wait(0.001);
+    _rst = 1;
+    wait(0.001);
+    _cs = 0;
+
+    command(0xCA); // display control 
+    data(0);
+    data(32);
+    data(0);
+
+    command(0xBB); 
+    data(1);
+
+    command(0xD1); // oscillator on
+    command(0x94); // sleep out
+    command(0x20); // power control
+    data(0x0F);
+
+    command(0xA7); // invert display
+    command(0x81); // Voltage control
+    data(39);      // contrast setting: 0..63
+    data(3);       // resistance ratio
+    wait(0.001);
+
+	command(0xBC); // data control
+  	data(3); // scan dirs 
+  	data(1); // RGB
+  	data(4); // grayscale   	  	
+  	
+    command(0xAF);  // turn on the display   
+	_cs = 1;
+	
+	cls();
+}
+
+void MobileLCD::pixel(int x, int y, int colour) {
+    _cs = 0;
+    
+	command(0x15); // column
+	data(2 + x);       
+	data(2 + x); 
+	command(0x75); // page
+  	data(y);            
+  	data(y);
+   	command(0x5C); // start write to ram
+
+	int gr = ((colour >> 20) & 0x0F)
+	       | ((colour >> 8 ) & 0xF0);
+	int nb = ((colour >> 4 ) & 0x0F);
+	data(nb); 
+	data(gr);
+	
+	_cs = 1; 
+}
+ 	
+int MobileLCD::width() { return 130; }
+int MobileLCD::height() { return 130; }
+ 	
+void MobileLCD::command(int value) {
+	_spi.write(value & 0xFF);
+}
+
+void MobileLCD::data(int value) {
+	_spi.write(value | 0x100);
+}
+
+#ifdef MBED_MOBILELCD_FASTER
+void MobileLCD::window(int x, int y, int w, int h) {
+    _cs = 0;
+	command(0x15); // column
+	data(2 + x);       
+	data(2 + x + w - 1); 
+	command(0x75); // page
+  	data(y);            
+  	data(y + h - 1);
+   	command(0x5C); // start write to ram
+    _cs = 1;
+}
+
+void MobileLCD::putp(int colour) {
+    _cs = 0;
+   	int gr = ((colour >> 20) & 0x0F)
+	       | ((colour >> 8 ) & 0xF0);
+	int nb = ((colour >> 4 ) & 0x0F);
+	data(nb); 
+	data(gr);
+	_cs = 1; 
+}
+
+#endif
diff -r 000000000000 -r cc002f2fad97 MobileLCD.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MobileLCD.h	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,44 @@
+/* mbed MobileLCD (Sparkfun Nokia) Display Library
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Implements a Graphics display on the Nokia LCD from sparkfun
+ */
+
+#ifndef MBED_MOBILELCD_H
+#define MBED_MOBILELCD_H
+
+// example of simplest vs. more performant port
+//  if not defined, only pixel() is implemented (slower, but simpler implementation)
+//  if defined, window() and putp() are also specialised, as well as pixel()
+#define MBED_MOBILELCD_FASTER
+ 
+#include "GraphicsDisplay.h"
+
+class MobileLCD : public GraphicsDisplay {
+
+public:
+
+	MobileLCD(PinName mosi, PinName sclk, PinName cs, PinName rst);
+
+    virtual void pixel(int x, int y, int colour);
+    virtual int width();
+    virtual int height();
+
+#ifdef MBED_MOBILELCD_FASTER
+    virtual void window(int x, int y, int w, int h);
+    virtual void putp(int colour);
+#endif
+    
+protected:
+
+ 	void command(int value);
+ 	void data(int value);
+ 	  	
+	SPI _spi;
+	DigitalOut _cs;	
+	DigitalOut _rst;
+	
+};
+
+#endif
diff -r 000000000000 -r cc002f2fad97 Terminal.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Terminal.cpp	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,73 @@
+/* mbed Terminal TextDisplay Library
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+ 
+#include "Terminal.h"
+
+#include "mbed.h"
+
+Terminal::Terminal(PinName tx, PinName rx) : _serial(tx, rx) {
+    cls();
+}
+
+void Terminal::character(int column, int row, int c) {
+    // Cursor Home	<ESC>[{ROW};{COLUMN}H 
+	_serial.printf("\033[%d;%dH%c", row + 1, column + 1, c);
+}
+
+int Terminal::columns() {
+    return 80;
+}
+
+int Terminal::rows() { 
+    return 35; 
+}
+
+void Terminal::cls() {
+    _serial.printf("\033[2J");
+}
+
+void Terminal::foreground(int colour) {
+
+	/* Set Attribute Mode	<ESC>[{n}m
+	 * - Sets display attribute settings. The following lists standard attributes:
+	 * 
+   	 * Foreground Colours
+   	 * 30	Black
+   	 * 31	Red
+   	 * 32	Green
+   	 * 33	Yellow
+   	 * 34	Blue
+   	 * 35	Magenta
+   	 * 36	Cyan
+   	 * 37	White
+   	 */
+   	 int r = (colour >> 23) & 1;
+   	 int g = (colour >> 15) & 1;
+   	 int b = (colour >> 7) & 1;
+   	 int bgr = (b << 2) | (g << 1) | (r << 0);
+   	 int c = 30 + bgr;
+    _serial.printf("\033[%dm", c);
+}
+
+void Terminal::background(int colour) {
+	  
+   	 /* Background Colours
+   	 * 40	Black
+   	 * 41	Red
+   	 * 42	Green
+   	 * 43	Yellow
+   	 * 44	Blue
+   	 * 45	Magenta
+   	 * 46	Cyan
+   	 * 47	White
+	 */
+   	 int r = (colour >> 23) & 1;
+   	 int g = (colour >> 15) & 1;
+   	 int b = (colour >> 7) & 1;
+   	 int bgr = (b << 2) | (g << 1) | (r << 0);
+   	 int c = 40 + bgr;
+     _serial.printf("\033[%dm", c);
+}
+ 
\ No newline at end of file
diff -r 000000000000 -r cc002f2fad97 Terminal.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Terminal.h	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,33 @@
+/* mbed Terminal TextDisplay Library
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Implementation of a TextDisplay using a VT100 Terminal and 
+ * escape codes (e.g. Teraterm, Hyperterminal)
+ */
+
+#include "TextDisplay.h"
+
+#ifndef MBED_TERMINAL_H
+#define MBED_TERMINAL_H
+
+class Terminal : public TextDisplay {
+public:
+
+    Terminal(PinName tx, PinName rx);
+
+    virtual void character(int column, int row, int c);
+    virtual int rows(); 
+    virtual int columns();  
+
+	virtual void cls();
+    virtual void foreground(int colour);
+    virtual void background(int colour);
+
+protected:
+
+    Serial _serial;
+    
+};
+
+#endif
diff -r 000000000000 -r cc002f2fad97 TextDisplay.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextDisplay.cpp	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,56 @@
+/* mbed TextDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+ 
+#include "TextDisplay.h"
+
+TextDisplay::TextDisplay() {
+    _row = 0;
+    _column = 0;
+}
+	
+int TextDisplay::_putc(int value) {
+    if(value == '\n') {
+        _column = 0;
+        _row++;
+        if(_row >= rows()) {
+            _row = 0;
+        }
+    } else {
+        character(_column, _row, value);
+        _column++;
+        if(_column >= columns()) {
+            _column = 0;
+            _row++;
+            if(_row >= rows()) {
+                _row = 0;
+            }
+        }
+    }
+    return value;
+}
+
+void TextDisplay::cls() {
+    locate(0, 0);
+    for(int i=0; i<columns()*rows(); i++) {
+        putc(' ');
+    }
+}
+
+void TextDisplay::locate(int column, int row) {
+    _column = column;
+    _row = row;
+}
+
+int TextDisplay::_getc() {
+	return -1;
+}
+		
+void TextDisplay::foreground(int colour) {
+    _foreground = colour;
+}
+
+void TextDisplay::background(int colour) {
+    _background = colour;
+}
diff -r 000000000000 -r cc002f2fad97 TextDisplay.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextDisplay.h	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,46 @@
+/* mbed TextDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * A common base class for Text displays
+ * To port a new display, derive from this class and implement
+ * the constructor (setup the display), character (put a character
+ * at a location), rows and columns functions. Everything else
+ * (locate, printf, putc, cls) will come for free
+ */
+
+#ifndef MBED_TEXTDISPLAY_H
+#define MBED_TEXTDISPLAY_H
+
+#include "mbed.h"
+
+class TextDisplay : public Stream {
+public:
+
+    // functions to implement in derived class
+    TextDisplay();
+    virtual void character(int column, int row, int c) = 0;
+    virtual int rows() = 0;
+    virtual int columns() = 0;
+    
+    virtual void cls();
+    virtual void locate(int column, int row);
+    virtual void foreground(int colour);
+    virtual void background(int colour);
+    // putc, printf also available from Stream
+    
+protected:
+
+    virtual int _putc(int value);
+    virtual int _getc();
+
+    // character location
+    short _column;
+    short _row;
+
+    // colours
+    int _foreground;
+    int _background;
+};
+
+#endif
diff -r 000000000000 -r cc002f2fad97 TextLCD.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.cpp	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,99 @@
+/* mbed TextLCD Library
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+ 
+#include "TextLCD.h"
+
+#include "mbed.h"
+
+/*
+ * useful info found at http://www.a-netz.de/lcd.en.php
+ *
+ * Initialisation
+ * ==============
+ *
+ * After attaching the supply voltage/after a reset, the display needs to be brought in to a defined state
+ *
+ * - wait approximately 15 ms so the display is ready to execute commands
+ * - Execute the command 0x30 ("Display Settings") three times (wait 1,64ms after each command, the busy flag cannot be queried now). 
+ * - The display is in 8 bit mode, so if you have only connected 4 data pins you should only transmit the higher nibble of each command.
+ * - If you want to use the 4 bit mode, now you can execute the command to switch over to this mode now.
+ * - Execute the "clear display" command
+ *
+ * Timing
+ * ======
+ *
+ * Nearly all commands transmitted to the display need 40us for execution. 
+ * Exceptions are the commands "Clear Display and Reset" and "Set Cursor to Start Position" 
+ * These commands need 1.64ms for execution. These timings are valid for all displays working with an 
+ * internal clock of 250kHz. But I do not know any displays that use other frequencies. Any time you 
+ * can use the busy flag to test if the display is ready to accept the next command.
+ * 
+ * _e is kept high apart from calling clock
+ * _rw is kept 0 (write) apart from actions that uyse it differently
+ * _rs is set by the data/command writes
+ */
+
+TextLCD::TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, 
+    PinName d2, PinName d3) : _rw(rw), _rs(rs), 
+    _e(e), _d(d0, d1, d2, d3) {
+
+    _rw = 0;
+    _e  = 1;
+    _rs = 0; // command mode
+
+    // Should theoretically wait 15ms, but most things will be powered up pre-reset
+    // so i'll disable that for the minute. If implemented, could wait 15ms post reset
+    // instead
+    // wait(0.015); 
+        
+    // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
+    for(int i=0; i<3; i++) {
+        writeByte(0x3);
+        wait(0.00164);      // this command takes 1.64ms, so wait for it
+    }
+    writeByte(0x2); // 4-bit mode
+            
+    writeCommand(0x28);    // Function set 001 BW N F - -  
+    writeCommand(0x0C);
+    writeCommand(0x6);  //  Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes    
+    cls();
+}
+
+void TextLCD::character(int column, int row, int c) {
+      int address = 0x80 + (row * 40) + column; // memory starts at 0x80, and is 40 chars long per row
+      writeCommand(address);           
+      writeData(c); 
+}
+
+int TextLCD::columns() {
+    return 16;
+}
+
+int TextLCD::rows() { 
+    return 2; 
+}
+
+void TextLCD::writeByte(int value) {
+    _d = value >> 4;
+    wait(0.000040f); // most instructions take 40us
+    _e = 0;
+    wait(0.000040f);  
+    _e = 1;    
+    _d = value >> 0;
+    wait(0.000040f);
+    _e = 0;
+    wait(0.000040f);  // most instructions take 40us
+    _e = 1;    
+}
+
+void TextLCD::writeCommand(int command) {
+    _rs = 0;
+    writeByte(command);
+}
+
+void TextLCD::writeData(int data) {
+    _rs = 1;
+    writeByte(data);
+}
diff -r 000000000000 -r cc002f2fad97 TextLCD.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.h	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,29 @@
+/* mbed TextDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+
+#include "TextDisplay.h"
+
+#ifndef MBED_TEXTLCD_H
+#define MBED_TEXTLCD_H
+
+class TextLCD : public TextDisplay {
+public:
+
+    TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, PinName d2, PinName d3);
+    virtual void character(int column, int row, int c);
+    virtual int rows(); 
+    virtual int columns();  
+
+protected:
+
+    void writeByte(int value);
+    void writeCommand(int command);
+    void writeData(int data);
+
+    DigitalOut _rw, _rs, _e;
+    BusOut _d;
+};
+
+#endif
diff -r 000000000000 -r cc002f2fad97 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "Displays.h"
+DigitalOut myled(LED1);
+//TextLCD lcd(p10, p11, p12, p15, p16, p29, p30);
+//Terminal lcd(USBTX, USBRX);
+//MobileLCD lcd(p5, p7, p8, p9);
+EA_QVGALCD lcd(p5, p6, p7, p8, p9);
+ 
+int main() {
+    lcd.printf("helo world!\nhow are you");
+    lcd.locate(3,1);
+    lcd.foreground(0xFFFFFF);
+    lcd.background(0x00FF00);
+    lcd.printf("oyoy!");
+    wait(3);
+    lcd.cls();
+    for(int i=0; i<130; i++) {
+        lcd.pixel(0, i, 0xFF0000);
+    }
+    
+    for(int i=0; i<130; i++) {
+        lcd.pixel(129, i, 0xFF00FF);
+    }
+    for(int i=0; i<130; i++) {
+        lcd.pixel(i, 0, 0x0000FF);
+    }
+    for(int i=0; i<130; i++) {
+        lcd.pixel(i, 129, 0xFFFFFF);
+    }
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
diff -r 000000000000 -r cc002f2fad97 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 15 10:02:04 2009 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/f63353af7be8