Fork of David Smart's RA8875 library for the purpose of adding touch screen support

Fork of RA8875 by David Smart

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Tue Jan 21 03:28:36 2014 +0000
Parent:
31:c72e12cd5c67
Child:
33:b6b710758ab3
Commit message:
Tuned up the Bitmap support - includes 24-bit color, and some hardware performance improvements.

Changed in this revision

Bitmap.h Show annotated file Show diff for this revision Revisions of this file
DisplayDefs.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
RA8875.cpp Show annotated file Show diff for this revision Revisions of this file
RA8875.h Show annotated file Show diff for this revision Revisions of this file
--- a/Bitmap.h	Mon Jan 20 19:19:48 2014 +0000
+++ b/Bitmap.h	Tue Jan 21 03:28:36 2014 +0000
@@ -18,6 +18,8 @@
 //
 // Bitmap file data structures
 //
+// must align to 2-byte boundaries so it doesn't alter the memory image when 
+// bytes are read from the file system into this footprint.
 #pragma push
 #pragma pack(2)
 
@@ -30,8 +32,6 @@
     uint32_t    bfOffBits;        /* Offset to bitmap data */
     } BITMAPFILEHEADER;
 
-#define BF_TYPE 0x4D42            /* "MB" */
-
 typedef struct                    /**** BMP file info structure ****/
     {
     uint32_t    biSize;           /* Size of info header */
@@ -48,6 +48,8 @@
     } BITMAPINFOHEADER;
 #pragma pop
 
+#define BF_TYPE 0x4D42            /* "MB" */
+
 /*
  * Constants for the biCompression field...
  */
@@ -65,19 +67,10 @@
     uint8_t  rgbReserved;      /* Reserved */
     } RGBQUAD;
 
-typedef struct                       /**** Bitmap information structure ****/
-    {
-    BITMAPINFOHEADER bmiHeader;      /* Image header */
-    RGBQUAD          bmiColors[256]; /* Image colormap */
-    } BITMAPINFO;
-
-
-/*
- * Prototypes...
- */
-
-//extern GLubyte *LoadDIBitmap(const char *filename, BITMAPINFO **info);
-//extern int32_t    SaveDIBitmap(const char *filename, BITMAPINFO *info,
-//                            GLubyte *bits);
+//typedef struct                       /**** Bitmap information structure ****/
+//    {
+//    BITMAPINFOHEADER bmiHeader;      /* Image header */
+//    RGBQUAD          bmiColors[256]; /* Image colormap */
+//    } BITMAPINFO;
 
 #endif // _BITMAP_H_
--- a/DisplayDefs.h	Mon Jan 20 19:19:48 2014 +0000
+++ b/DisplayDefs.h	Tue Jan 21 03:28:36 2014 +0000
@@ -1,6 +1,8 @@
 #ifndef DISPLAYDEFS_H
 #define DISPLAYDEFS_H
 
+#define RGB(r,g,b) ( ((r<<8)&0xF800) | ((g<<3)&0x07E0) | (b>>3) )
+
 typedef uint16_t color_t;
 
 /// return values from functions
@@ -15,4 +17,29 @@
     not_enough_ram,         ///< could not allocate ram for scanline
 } RetCode_t;
 
+/// type that manages x,y pairs
+typedef struct
+{
+    uint16_t x;             ///< x value in the point
+    uint16_t y;             ///< y value in the point
+} point_t;
+
+/// color type definition to let the compiler help keep us honest.
+/// 
+/// colors can be defined with the RGB(r,g,b) macro, and there
+/// are a number of predefined colors:
+/// - Black,    Blue,       Green,       Cyan,
+/// - Red,      Magenta,    Brown,       Gray,
+/// - Charcoal, BrightBlue, BrightGreen, BrightCyan,
+/// - Orange,   Pink,       Yellow,      White
+///
+typedef uint16_t color_t;   
+
+/// background fill info for drawing Text, Rectangles, RoundedRectanges, Circles, Ellipses and Triangles.
+typedef enum
+{
+    NOFILL,     ///< do not fill the object with the background color
+    FILL        ///< fill the object space with the background color
+} fill_t;
+
 #endif // DISPLAYDEFS_H
--- a/GraphicsDisplay.cpp	Mon Jan 20 19:19:48 2014 +0000
+++ b/GraphicsDisplay.cpp	Tue Jan 21 03:28:36 2014 +0000
@@ -1,12 +1,21 @@
 /* mbed GraphicsDisplay Display Library Base Class
  * Copyright (c) 2007-2009 sford
  * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Software Rendering of a Bitmap from the localfilesystem
+ *      34 sec: 352x272 pixels, 8-bit color, 94.5kbytes
+ * Hardware Rendering
+ *       9 sec: same file.
  */
 
 #include "GraphicsDisplay.h"
 #include "Bitmap.h"
 
-#define DEBUG "GD"
+// Defining USE_HW causes compilation of code that uses hardware drawing
+// provided by the super-class.
+#define USE_HW
+
+//#define DEBUG "GD"
 // ...
 // INFO("Stuff to show %d", var); // new-line is automatically appended
 //
@@ -38,7 +47,7 @@
 #define INFO(x, ...)
 #define WARN(x, ...)
 #define ERR(x, ...)
-#define HexDump(a, b)
+#define HexDump(a, b, c)
 #endif
 
 // #define LOCALFONT
@@ -184,7 +193,7 @@
 }
 #endif
 
-void GraphicsDisplay::window(unsigned int x, unsigned int y, unsigned int w, unsigned int h)
+RetCode_t GraphicsDisplay::window(unsigned int x, unsigned int y, unsigned int w, unsigned int h)
 {
     // current pixel location
     _x = x;
@@ -194,6 +203,7 @@
     _x2 = x + w - 1;
     _y1 = y;
     _y2 = y + h - 1;
+    return noerror;
 }
 
 void GraphicsDisplay::WindowMax(void)
@@ -201,7 +211,7 @@
     window(0,0, width(),height());
 }
 
-void GraphicsDisplay::putp(color_t colour)
+RetCode_t GraphicsDisplay::putp(color_t colour)
 {
     // put pixel at current pixel location
     pixel(_x, _y, colour);
@@ -214,14 +224,19 @@
             _y = _y1;
         }
     }
+    return noerror;
 }
 
 void GraphicsDisplay::fill(int x, int y, int w, int h, color_t colour)
 {
+    #ifdef USE_HW
+    fillrect(x,y, x+w, y+h, colour);
+    #else
     window(x, y, w, h);
     for(int i=0; i<w*h; i++) {
         putp(colour);
     }
+    #endif
 }
 
 RetCode_t GraphicsDisplay::cls()
@@ -288,7 +303,7 @@
 //      RRRR RGGG GGGB BBBB
 // swap to little endian
 //      GGGB BBBB RRRR RGGG
-color_t RGBQuadToRGB16(RGBQUAD * colorPalette, uint16_t i)
+color_t GraphicsDisplay::RGBQuadToRGB16(RGBQUAD * colorPalette, uint16_t i)
 {
     color_t c;
  
@@ -302,7 +317,7 @@
 }
 
 
-RetCode_t GraphicsDisplay::BMP_16(unsigned int x, unsigned int y, const char *Name_BMP)
+RetCode_t GraphicsDisplay::RenderBitmapFile(unsigned int x, unsigned int y, const char *Name_BMP)
 {
     #define OffsetPixelWidth    18
     #define OffsetPixelHeight   22
@@ -310,12 +325,11 @@
     #define OffsetPixData       10
     #define OffsetBPP           28
 
-    char filename[50];
     BITMAPFILEHEADER BMP_Header;
     BITMAPINFOHEADER BMP_Info;
     RGBQUAD * colorPalette = NULL;
     int colorCount;
-    char * lineBuffer = NULL;
+    uint8_t * lineBuffer = NULL;
     
     uint16_t BPP_t;
     uint32_t PixelWidth, PixelHeight;
@@ -323,11 +337,8 @@
     unsigned int    i, offset;
     int padd,j;
 
-    // get the filename
-    LocalFileSystem local("local");
-    sprintf(filename,"/local/%s", Name_BMP);
-    INFO("Opening {%s}", filename);
-    FILE *Image = fopen(filename, "rb");  // open the bmp file
+    INFO("Opening {%s}", Name_BMP);
+    FILE *Image = fopen(Name_BMP, "rb");
     if (!Image) {
         return(file_not_found);
     }
@@ -335,22 +346,20 @@
     fread(&BMP_Header, 1, sizeof(BMP_Header), Image);      // get the BMP Header
     INFO("bfType %04X", BMP_Header.bfType);
     //HexDump("BMP_Header", (uint8_t *)&BMP_Header, sizeof(BMP_Header));
-    if (BMP_Header.bfType != BF_TYPE) { // BMP_Header[0] != 0x42 || BMP_Header[1] != 0x4D) {  // check magic byte
+    if (BMP_Header.bfType != BF_TYPE) {
         fclose(Image);
-        return(not_bmp_format);     // error no BMP file
+        return(not_bmp_format);
     }
 
     fread(&BMP_Info, 1, sizeof(BMP_Info), Image);
     //HexDump("BMP_Info", (uint8_t *)&BMP_Info, sizeof(BMP_Info));
     BPP_t = BMP_Info.biBitCount;
     INFO("biBitCount %04X", BPP_t);
-    if (BPP_t != 4 && BPP_t != 8 && BPP_t != 16) {   // Support 4, 8, 16-bits per pixel
+    if (BPP_t != 4 && BPP_t != 8 && BPP_t != 16 && BPP_t != 24) { // Support 4, 8, 16, 24-bits per pixel
         fclose(Image);
         return(not_supported_format);
     }
 
-    //PixelHeight = BMP_Header[OffsetPixelHeight] + (BMP_Header[OffsetPixelHeight + 1] << 8) + (BMP_Header[OffsetPixelHeight + 2] << 16) + (BMP_Header[OffsetPixelHeight + 3] << 24);
-    //PixelWidth = BMP_Header[OffsetPixelWidth] + (BMP_Header[OffsetPixelWidth + 1] << 8) + (BMP_Header[OffsetPixelWidth + 2] << 16) + (BMP_Header[OffsetPixelWidth + 3] << 24);
     PixelHeight = BMP_Info.biHeight;
     PixelWidth = BMP_Info.biWidth;
     if (PixelHeight > height() + y || PixelWidth > width() + x) {
@@ -358,77 +367,90 @@
         return(image_too_big);
     }
     INFO("(%d,%d) (%d,%d)", x,y, PixelWidth,PixelHeight);
-
     if (BMP_Info.biBitCount <= 8) {
         int paletteSize;
         // Read the color palette
         colorCount = 1 << BMP_Info.biBitCount;
         paletteSize = sizeof(RGBQUAD) * colorCount;
-        //INFO("colors: %d, paletteSize: %d", colorCount, paletteSize);
         colorPalette = (RGBQUAD *)malloc(paletteSize);
         if (colorPalette == NULL) {
             fclose(Image);
             return(not_enough_ram);
         }
         fread(colorPalette, 1, paletteSize, Image);
-        HexDump("Color Palette", (uint8_t *)colorPalette, paletteSize);
-    } else {
-        ERR("Bits per pixel > 8 [%d]", BMP_Info.biBitCount);
+        //HexDump("Color Palette", (uint8_t *)colorPalette, paletteSize);
     }
 
-    //start_data = BMP_Header[OffsetPixData] + (BMP_Header[OffsetPixData + 1] << 8) + (BMP_Header[OffsetPixData + 2] << 16) + (BMP_Header[OffsetPixData + 3] << 24);
-    start_data = BMP_Header.bfOffBits;
-
-    //HexDump("Raw Data", (uint8_t *)&start_data, 32);
-    int lineBufSize = ((BPP_t * PixelWidth + 31)/32)*4;
-    //INFO("lineBufSize = %d", lineBufSize);
-    lineBuffer = (char *)malloc(lineBufSize);
+    int lineBufSize = ((BPP_t * PixelWidth + 7)/8);
+    //INFO("BPP_t %d, PixelWidth %d, lineBufSize %d", BPP_t, PixelWidth, lineBufSize);
+    lineBuffer = (uint8_t *)malloc(lineBufSize);
     if (lineBuffer == NULL) {
         free(colorPalette);
         fclose(Image);
         return(not_enough_ram);
     }
 
-    // the bmp lines are padded to multiple of 4 bytes
+    // the Raw Data records are padded to a multiple of 4 bytes
+    int recordSize = 2;
+    if (BPP_t == 4) {
+        recordSize = 1;
+    } else if (BPP_t == 8) {
+        recordSize = 1;
+    } else if (BPP_t == 16) {
+        recordSize = 2;
+    } else if (BPP_t == 24) {
+        recordSize = 3;
+    }
     padd = -1;
     do {
         padd++;
-    } while ((PixelWidth * sizeof(color_t) + padd) % 4 != 0);
+    } while ((PixelWidth * recordSize + padd) % 4 != 0);
 
-    // Define window for top to bottom and left to right
+    // Define window for top to bottom and left to right so writing auto-wraps
     window(x,y, PixelWidth,PixelHeight);
-    //INFO("(%d,%d) (%d,%d)", x,y, PixelWidth,PixelHeight);
-    for (j = PixelHeight - 1; j >= 0; j--) {               //Lines bottom up
-        //INFO("line %d", j);
-        offset = start_data + j * (lineBufSize + padd);   // start of line
+    SetGraphicsCursor(x, y);
+    _StartGraphicsStream();
+    
+    start_data = BMP_Header.bfOffBits;
+    HexDump("Raw Data", (uint8_t *)&start_data, 32);
+    //bool tag = true;
+    //INFO("(%d,%d) (%d,%d), [%d,%d]", x,y, PixelWidth,PixelHeight, lineBufSize, padd);
+    for (j = PixelHeight - 1; j >= 0; j--) {                //Lines bottom up
+        offset = start_data + j * (lineBufSize + padd);     // start of line
         fseek(Image, offset, SEEK_SET);
-        fread(lineBuffer, 1, lineBufSize, Image);       // read a line - slow !
-        //HexDump("Line", (uint8_t *)lineBuffer, lineBufSize);
-        for (i = 0; i < PixelWidth; i++) {        // copy pixel data to TFT
+        fread(lineBuffer, 1, lineBufSize, Image);           // read a line - slow !
+        //INFO("offset: %6X", offset);
+        //if (tag)
+        //    HexDump("Line", (uint8_t *)lineBuffer, lineBufSize);
+        for (i = 0; i < PixelWidth; i++) {                  // copy pixel data to TFT
             if (BPP_t == 4) {
                 uint8_t dPix = lineBuffer[i/2];
                 if ((i & 1) == 0)
                     dPix >>= 4;
                 dPix &= 0x0F;
-                color_t color;
-                color = RGBQuadToRGB16(colorPalette, dPix);
-                putp(color);
+                putp(RGBQuadToRGB16(colorPalette, dPix));
             } else if (BPP_t == 8) {
-                color_t color;
-                color = RGBQuadToRGB16(colorPalette, lineBuffer[i]);
+                putp(RGBQuadToRGB16(colorPalette, lineBuffer[i]));
+            } else if (BPP_t == 16) {
+                putp(lineBuffer[i]);
+            } else if (BPP_t == 24) {
+                color_t color;  // BGR
+                color = RGB(lineBuffer[i*3+2], lineBuffer[i*3+1], lineBuffer[i*3+0]);
+                //if (tag) 
+                //    INFO("color[%2d]: RGB(%02X,%02X,%02X) => %04X", 
+                //        i, lineBuffer[i*2], lineBuffer[i*3+1], lineBuffer[i*3+0], color);
+                color = (color >> 8) | (color << 8);
                 putp(color);
-            } else if (BPP_t == 16) {
-                putp(lineBuffer[i] & 0xFF);
-                putp(lineBuffer[i] >> 8);
             }
         }
+        //tag = false;
     }
     free(lineBuffer);
     free(colorPalette);
     fclose(Image);
-    //INFO("Freed and closed");
+    _EndGraphicsStream();
     WindowMax();
-    return(noerror);
+    return (noerror);
 }
 
 int GraphicsDisplay::columns()
@@ -441,3 +463,4 @@
     return height() / 8;
 }
 
+
--- a/GraphicsDisplay.h	Mon Jan 20 19:19:48 2014 +0000
+++ b/GraphicsDisplay.h	Tue Jan 21 03:28:36 2014 +0000
@@ -13,24 +13,120 @@
 
 #ifndef MBED_GRAPHICSDISPLAY_H
 #define MBED_GRAPHICSDISPLAY_H
-
+#include "Bitmap.h"
 #include "TextDisplay.h"
 
-class GraphicsDisplay : public TextDisplay {
-
-public:         
-          
+/// The GraphicsDisplay class 
+/// 
+/// This graphics display class supports both graphics and text operations.
+/// Typically, a subclass is derived from this which has localizations to
+/// adapt to a specific hardware platform (e.g. a display controller chip),
+/// that overrides methods in here to either add more capability or perhaps 
+/// to improve performance, by leveraging specific hardware capabilities.
+///
+class GraphicsDisplay : public TextDisplay 
+{
+public:
+    /// The constructor
     GraphicsDisplay(const char* name);
-     
+    
+    /// Draw a pixel in the specified color.
+    ///
+    /// @note this method must be supported in the derived class.
+    ///
+    /// @param x is the horizontal offset to this pixel.
+    /// @param y is the vertical offset to this pixel.
+    /// @param color defines the color for the pixel.
+    /// @returns success/failure code. @see RetCode_t.
+    ///
     virtual RetCode_t pixel(unsigned int x, unsigned int y, color_t colour) = 0;
-    virtual int width() = 0;
-    virtual int height() = 0;
-        
-    virtual void window(unsigned int x,unsigned int y,unsigned int w,unsigned int h);
+    
+    /// get the screen width in pixels
+    ///
+    /// @note this method must be supported in the derived class.
+    ///
+    /// @returns screen width in pixels.
+    ///
+    virtual uint16_t width() = 0;
+    
+    /// get the screen height in pixels
+    ///
+    /// @note this method must be supported in the derived class.
+    ///
+    /// @returns screen height in pixels.
+    ///
+    virtual uint16_t height() = 0;
+
+    /// Prepare the controller to write binary data to the screen by positioning
+    /// the memory cursor.
+    ///
+    /// @note this method must be supported in the derived class.
+    ///
+    /// @param x is the horizontal position in pixels (from the left edge)
+    /// @param y is the vertical position in pixels (from the top edge)
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    virtual RetCode_t SetGraphicsCursor(uint16_t x, uint16_t y) = 0;
+    
+    /// Draw a filled rectangle in the specified color
+    ///
+    /// @note As a side effect, this changes the current
+    ///     foreground color for subsequent operations.
+    ///
+    /// @note this method must be supported in the derived class.
+    ///
+    /// @param x1 is the horizontal start of the line.
+    /// @param y1 is the vertical start of the line.
+    /// @param x2 is the horizontal end of the line.
+    /// @param y2 is the vertical end of the line.
+    /// @param color defines the foreground color.
+    /// @param fillit is optional to NOFILL the rectangle. default is FILL.
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    virtual RetCode_t fillrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, 
+        color_t color, fill_t fillit = FILL) = 0;
+
+
+    virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF) = 0;
+    virtual RetCode_t WriteData(unsigned char data) = 0;
+
+    /// Set the window, which controls where items are written to the screen.
+    ///
+    /// When something hits the window width, it wraps back to the left side
+    /// and down a row. If the initial write is outside the window, it will
+    /// be captured into the window when it crosses a boundary.
+    ///
+    /// @param x is the left edge in pixels.
+    /// @param y is the top edge in pixels.
+    /// @param width is the window width in pixels.
+    /// @param height is the window height in pixels.
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    virtual RetCode_t window(unsigned int x,unsigned int y,unsigned int w,unsigned int h);
+    
+    /// Clear the screen.
+    ///
+    /// The behavior is to clear the whole screen.
+    ///
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    virtual RetCode_t cls();
+    
+
     virtual void WindowMax(void);
-    virtual void putp(color_t colour);
     
-    virtual RetCode_t cls();
+    /// method to put a single color pixel to the screen.
+    ///
+    /// This method may be called as many times as necessary after 
+    /// @see _StartGraphicsStream() is called, and it should be followed 
+    /// by _EndGraphicsStream.
+    ///
+    /// @param pixel is a color value to be put on the screen.
+    /// @returns error code.
+    ///
+    virtual RetCode_t putp(color_t pixel);
+
+            
     virtual void fill(int x, int y, int w, int h, color_t colour);
     virtual void blit(int x, int y, int w, int h, const int * colour);    
     
@@ -51,6 +147,22 @@
     ///
     virtual int fontblit(int x, int y, const unsigned char * fontTable, const unsigned char * fontChar);
     
+    /// This method returns the color value from a palette.
+    ///
+    /// This method accepts a pointer to a Bitmap color palette, which
+    /// is a table in memory composed of RGB Quad values (r, g, b, 0),
+    /// and an index into that table. It then extracts the color information
+    /// and downsamples it to a color_t value which it returns.
+    ///
+    /// @note This method probably has very little value outside of
+    ///         the internal methods for reading BMP files.
+    ///
+    /// @param colorPalette is the handle to the color palette to use.
+    /// @param i is the index into the color palette.
+    /// @returns the color in color_t format.
+    ///
+    color_t RGBQuadToRGB16(RGBQUAD * colorPalette, uint16_t i);
+    
     /// This method reads a disk file that is in bitmap format and 
     /// puts it on the screen.
     ///
@@ -58,14 +170,15 @@
     /// @note This is a slow operation, partially due to the use of
     ///         the local file system, and partially because bmp files
     ///         are stored from the bottom up, and the memory is written
-    ///         from the top down.
+    ///         from the top down; as a result, it constantly 'seeks'
+    ///         on the file system for the next row of information.
     ///
     /// @param x is the horizontal pixel coordinate
     /// @param y is the vertical pixel coordinate
     /// @param Name_BMP is the filename on the local file system.
     /// @returns success or error code.
     ///
-    RetCode_t BMP_16(unsigned int x, unsigned int y, const char *Name_BMP);
+    RetCode_t RenderBitmapFile(unsigned int x, unsigned int y, const char *Name_BMP);
     
     /// prints one character at the specified coordinates.
     ///
@@ -78,11 +191,63 @@
     ///
     virtual int character(int x, int y, int value);
     
-    virtual int columns();
-    virtual int rows();
+    /// get the number of colums based on the currently active font
+    ///
+    /// @returns number of columns.
+    ///    
+    virtual int columns(void);
+
+    /// get the number of rows based on the currently active font
+    ///
+    /// @returns number of rows.
+    ///    
+    virtual int rows(void);
+    
+    /// Select a bitmap font (provided by the user) for all subsequent text.
+    ///
+    /// @note Tool to create the fonts is accessible from its creator
+    ///     available at http://www.mikroe.com. 
+    ///     Change the data to an array of type char[].
+    ///
+    /// @param font is a pointer to a specially formed font array.
+    ///     This special font array has a 4-byte header, followed by 
+    ///     the data:
+    ///   - the number of bytes per char
+    ///   - the vertical size in pixels for each character
+    ///   - the horizontal size in pixels for each character
+    ///   - the number of bytes per vertical line (width of the array)
+    /// @returns error code.
+    ///
     virtual RetCode_t set_font(const unsigned char * font = NULL);
+
+protected:
+
+    /// Pure virtual method indicating the start of a graphics stream.
+    ///
+    /// This is called prior to a stream of pixel data being sent.
+    /// This may cause register configuration changes in the derived
+    /// class in order to prepare the hardware to accept the streaming
+    /// data.
+    ///
+    /// @note this method must be supported in the derived class.
+    ///
+    /// @returns error code.
+    ///
+    virtual RetCode_t _StartGraphicsStream(void) = 0;
     
-protected:
+    /// Pure virtual method indicating the end of a graphics stream.
+    ///
+    /// This is called to conclude a stream of pixel data that was sent.
+    /// This may cause register configuration changes in the derived
+    /// class in order to stop the hardware from accept the streaming
+    /// data.
+    ///
+    /// @note this method must be supported in the derived class.
+    ///
+    /// @returns error code.
+    ///
+    virtual RetCode_t _EndGraphicsStream(void) = 0;
+
     const unsigned char * font;     ///< reference to an external font somewhere in memory
     
     // pixel location
--- a/RA8875.cpp	Mon Jan 20 19:19:48 2014 +0000
+++ b/RA8875.cpp	Tue Jan 21 03:28:36 2014 +0000
@@ -159,9 +159,9 @@
         return font[2];
 }
 
-RetCode_t RA8875::locate(unsigned int x, unsigned int y)
+RetCode_t RA8875::locate(unsigned int column, unsigned int row)
 {
-    return SetTextCursor(x * fontwidth(), y * fontheight());
+    return SetTextCursor(column * fontwidth(), row * fontheight());
 }
 
 int RA8875::columns(void)
@@ -174,15 +174,13 @@
     return height() / fontheight();
 }
 
-int RA8875::width(void)
+uint16_t RA8875::width(void)
 {
-    //return RA8875_DISPLAY_WIDTH;
     return (ReadCommand(0x14) + 1) * 8;
 }
 
-int RA8875::height(void)
+uint16_t RA8875::height(void)
 {
-    //return RA8875_DISPLAY_HEIGHT;
     return (ReadCommand(0x19) | (ReadCommand(0x1A) << 8)) + 1;
 }
 
@@ -365,6 +363,24 @@
     return c;
 }
 
+RetCode_t RA8875::_StartGraphicsStream(void)
+{
+    WriteCommand(0x40,0x00);    // Graphics write mode
+    WriteCommand(0x02);         // Prepare for streaming data
+    return noerror;
+}
+
+RetCode_t RA8875::_EndGraphicsStream(void)
+{
+    return noerror;
+}
+
+RetCode_t RA8875::putp(color_t pixel)
+{
+    WriteData(pixel & 0xFF);
+    WriteData(pixel >> 8);
+    return noerror;   
+}
 
 void RA8875::puts(unsigned int x, unsigned int y, const char * string)
 {
@@ -378,7 +394,6 @@
                 
     if ((mwcr0 & 0x80) == 0x00)
         WriteCommand(0x40,0x80);    // Put in Text mode if not already
-
     if (*string != '\0') {
         #if 1
         while (*string) {           // @TODO calling individual _putc is slower... optimizations?
@@ -398,7 +413,7 @@
     }
 }
 
-RetCode_t RA8875::SetMemoryCursor(unsigned int x, unsigned int y)
+RetCode_t RA8875::SetGraphicsCursor(uint16_t x, uint16_t y)
 {
     WriteCommand(0x46, x & 0xFF);
     WriteCommand(0x47, x >> 8);
@@ -407,7 +422,7 @@
     return noerror;
 }
 
-RetCode_t RA8875::SetWindow(unsigned int x, unsigned int y, unsigned int width, unsigned int height)
+RetCode_t RA8875::window(unsigned int x, unsigned int y, unsigned int width, unsigned int height)
 {
     WriteCommand(0x30, x & 0xFF);   // HSAW0
     WriteCommand(0x31, x >> 8);     // HSAW1
@@ -452,7 +467,7 @@
     PERFORMANCE_RESET;
     color_t color = GetForeColor();
     WriteCommand(0x40,0x00);    // Graphics write mode
-    SetMemoryCursor(x, y);
+    SetGraphicsCursor(x, y);
     WriteCommand(0x02);         //start data write
     WriteData(color & 0xFF);
     WriteData(color >> 8);
@@ -934,7 +949,7 @@
     WriteCommand(0x1f, 0x01);                     //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0]
 
     // Clear ram image
-    SetWindow(0,0, width(), height());          // Initialize to full screen
+    window(0,0, width(), height());          // Initialize to full screen
     SetTextCursorControl();
     foreground(Blue);
     background(Black);
@@ -1075,7 +1090,7 @@
     pc.printf("Web Color Test\r\n");
     display.background(Black);
     display.foreground(Blue);
-    display.SetWindow(0,0, display.width(), display.height());
+    display.window(0,0, display.width(), display.height());
     display.cls();
     display.puts(0,0, "Web Color Test\r\n");
     display.SetTextFontSize(1,2);
--- a/RA8875.h	Mon Jan 20 19:19:48 2014 +0000
+++ b/RA8875.h	Tue Jan 21 03:28:36 2014 +0000
@@ -14,8 +14,6 @@
 // .cpp file. See also the bottom of this file.
 #define TESTENABLE
 
-#define RGB(r,g,b) ( ((r<<8)&0xF800) | ((g<<3)&0x07E0) | (b>>3) )
-
 /// DOS colors - slightly color enhanced
 #define Black       (color_t)(RGB(0,0,0))
 #define Blue        (color_t)(RGB(0,0,187))
@@ -39,24 +37,6 @@
 //namespace SW_graphics
 //{
 
-/// color type definition to let the compiler help keep us honest.
-/// 
-/// colors can be defined with the RGB(r,g,b) macro, and there
-/// are a number of predefined colors:
-/// - Black,    Blue,       Green,       Cyan,
-/// - Red,      Magenta,    Brown,       Gray,
-/// - Charcoal, BrightBlue, BrightGreen, BrightCyan,
-/// - Orange,   Pink,       Yellow,      White
-///
-typedef uint16_t color_t;   
-
-/// background fill info for drawing Text, Rectangles, RoundedRectanges, Circles, Ellipses and Triangles.
-typedef enum
-{
-    NOFILL,     ///< do not fill the object with the background color
-    FILL        ///< fill the object space with the background color
-} fill_t;
-
 /// cursor type to be shown as the text cursor.
 typedef enum
 {
@@ -87,9 +67,6 @@
 /// of column and row, which is measured in character positions (and dependent
 /// on the font size), and other text APIs permit pixel level positioning.
 ///
-/// @todo Bitmap support.
-/// @todo Bitmap support could be sped up significantly using more hw features 
-///         (e.g. graphics cursor to avoid setting x,y coords for every pixel)
 /// @todo Add Scroll support for text.
 /// @todo Add 2-Layer support.
 /// @todo Improve sync between internal and externa font support - cursor, window, scroll.
@@ -167,7 +144,7 @@
     ///     and only occurs if the data is in the range [0 - 0xFF].
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
+    virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
     
     /// Write a data byte to the display
     ///
@@ -176,7 +153,7 @@
     /// @param data is the data to write.
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t WriteData(unsigned char data);
+    virtual RetCode_t WriteData(unsigned char data);
     
     /// Read a command register
     ///
@@ -229,21 +206,21 @@
     ///
     /// @returns screen width in pixels.
     ///
-    virtual int width(void);
+    virtual uint16_t width(void);
 
     /// get the screen height in pixels
     ///
     /// @returns screen height in pixels.
     ///
-    virtual int height(void);
+    virtual uint16_t height(void);
 
     /// Set cursor position based on the current font size.
     /// 
-    /// @param x is the horizontal position in character positions
-    /// @param y is the vertical position in character positions
+    /// @param column is the horizontal position in character positions
+    /// @param row is the vertical position in character positions
     /// @returns success/failure code. @see RetCode_t.
     ///
-    virtual RetCode_t locate(unsigned int x, unsigned int y);
+    virtual RetCode_t locate(unsigned int column, unsigned int row);
 
     /// Prepare the controller to write text to the screen by positioning
     /// the cursor.
@@ -369,7 +346,7 @@
     /// @param y is the vertical position in pixels (from the top edge)
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t SetMemoryCursor(unsigned int x, unsigned int y);
+    virtual RetCode_t SetGraphicsCursor(uint16_t x, uint16_t y);
     
     /// Set the window, which controls where items are written to the screen.
     ///
@@ -383,7 +360,7 @@
     /// @param height is the window height in pixels.
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t SetWindow(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
+    virtual RetCode_t window(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
     
     /// Clear the screen.
     ///
@@ -397,7 +374,7 @@
     ///
     /// The default behavior is to clear the whole screen. With the optional 
     /// parameter, the action can be restricted to the active window, which
-    /// can be set with the @see SetWindow method.
+    /// can be set with the @see window method.
     ///
     /// @param region is an optional parameter that defaults to FULLWINDOW
     ///         or may be set to ACTIVEWINDOW.
@@ -445,8 +422,8 @@
         
     /// Draw a pixel in the specified color.
     ///
-    /// @note As a side effect, this also sets the foreground color 
-    ///     affecting all subsequent operations.
+    /// @note As a side effect, this also sets the foreground  
+    ///     color affecting all subsequent operations.
     ///
     /// @param x is the horizontal offset to this pixel.
     /// @param y is the vertical offset to this pixel.
@@ -519,7 +496,7 @@
     /// @param fillit is optional to NOFILL the rectangle. default is FILL.
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t fillrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, 
+    virtual RetCode_t fillrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, 
         color_t color, fill_t fillit = FILL);
 
     /// Draw a rectangle
@@ -780,7 +757,7 @@
     ///
     RetCode_t Backlight(float brightness);
 
-    /// Set a reference to a bitmap font, provided by the user.
+    /// Select a bitmap font (provided by the user) for all subsequent text.
     ///
     /// @note Tool to create the fonts is accessible from its creator
     ///     available at http://www.mikroe.com. 
@@ -849,6 +826,45 @@
     ///
     RetCode_t init(void);
     
+    /// method indicating the start of a graphics stream.
+    ///
+    /// This is called prior to a stream of pixel data being sent.
+    /// This may cause register configuration changes in the derived
+    /// class in order to prepare the hardware to accept the streaming
+    /// data.
+    ///
+    /// Following this command, a series of @see putp() commands can
+    /// be used to send individual pixels to the screen.
+    ///
+    /// To conclude the graphics stream, @see _EndGraphicsStream should
+    /// be callled.
+    ///
+    /// @returns error code.
+    ///
+    virtual RetCode_t _StartGraphicsStream(void);
+    
+    /// method to put a single color pixel to the screen.
+    ///
+    /// This method may be called as many times as necessary after 
+    /// @see _StartGraphicsStream() is called, and it should be followed 
+    /// by _EndGraphicsStream.
+    ///
+    /// @param pixel is a color value to be put on the screen.
+    /// @returns error code.
+    ///
+    virtual RetCode_t putp(color_t pixel);
+    
+    /// method indicating the end of a graphics stream.
+    ///
+    /// This is called to conclude a stream of pixel data that was sent.
+    /// This may cause register configuration changes in the derived
+    /// class in order to stop the hardware from accept the streaming
+    /// data.
+    ///
+    /// @returns error code.
+    ///
+    virtual RetCode_t _EndGraphicsStream(void);
+
     /// Internal function to put a character using the built-in (internal) font engine
     ///
     /// @param is the character to put to the screen.