This is a port of Henning Kralsen's UTFT library for Arduino/chipKIT to mbed, refactored to make full use of C inheritance and access control, in order to reduce work when implementing new drivers and at the same time make the code more readable and easier to maintain. As of now supported are SSD1289 (16-bit interface), HX8340-B (serial interface) and ST7735 (serial interface). Drivers for other controllers will be added as time and resources to acquire the displays to test the code permit.

Dependents:   UTFT_SSD1289

Fork of TFTLCD by Todor Todorov

Revision:
9:58b328831d0a
Parent:
8:7a4791dbb065
Child:
10:69571adcfad5
--- a/lcd_base.h	Thu Dec 06 02:18:22 2012 +0000
+++ b/lcd_base.h	Fri Dec 07 16:14:13 2012 +0000
@@ -161,11 +161,10 @@
      * in place, the new setting will be used for that single operation only and
      * will not change this value.
      *
-     * \param color The color to be used. Use the RGB macro to create the correct
-     *              color for the used LCD driver.
+     * \param color The color to be used. The value must be in RGB-565 format.
      * \sa #RGB(r,g,b)
      */
-    virtual void SetForeground( unsigned int color = COLOR_WHITE );
+    virtual void SetForeground( unsigned short color = COLOR_WHITE );
     
     /** Set the background color for painting.
      *
@@ -174,11 +173,10 @@
      * when the function is called, the new value will be used only for this
      * single call and will not change this setting.
      *
-     * \param color The background color. Use the RGB macro to create the correct
-     *              color for the used LCD driver.
+     * \param color The background color as RGB-565 value.
      * \sa #RGB(r,g,b)
      */
-    virtual void SetBackground( unsigned int color = COLOR_BLACK );
+    virtual void SetBackground( unsigned short color = COLOR_BLACK );
     
     /** Sets the font to be used for painting of text on the screen.
      * \param font A pointer to the font data.
@@ -197,10 +195,9 @@
     unsigned short GetHeight( void );
     
     /** Fills the whole screen with a single color.
-     * \param color The color to be used. Use the RGB macro to create the correct
-     *              color for the used LCD driver.
-     * \remarks The special values -1 and -2 signify the preset background and
-     *          foreground colors, respectively. The backround color is the default.
+     * \param color The color to be used. The value must be in RGB-565 format.
+     * \remarks The special values -1 and -2 signify the preset background and foreground colors, respectively.
+     *          The backround color is the default.
      */
     virtual void FillScreen( int color = -1 );
     
@@ -217,8 +214,7 @@
      *
      * \param x The horizontal offset of the pixel from the upper left corner of the screen.
      * \param y The vertical offset of the pixel from the upper left corner of the screen.
-     * \param color The color to be used. Use the RGB macro for custom color to produce the
-     *              correct format, or -1 for background and -2 for foreground color.
+     * \param color The color to be used. Must be in RGB-565 format, or -1 for background and -2 for foreground color.
      */
     virtual void DrawPixel( unsigned short x, unsigned short y, int color = -2 );
     
@@ -228,8 +224,7 @@
      * \param y1 Vertical offset of the beginning point of the line.
      * \param x2 Horizontal offset of the end point of the line.
      * \param y2 Verical offset of the end point of the line.
-     * \param color The color to use for painting; use -1 for background, or -2 for foreground,
-     *              or the RGB macro for custom colors.
+     * \param color The color to use for painting, in RGB-565 format, or -1 for background, or -2 for foreground.
      */
     virtual void DrawLine( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -239,7 +234,7 @@
      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void DrawRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -249,7 +244,7 @@
      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void DrawRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -259,7 +254,7 @@
      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void FillRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -269,7 +264,7 @@
      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void FillRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -278,7 +273,7 @@
      * \param x The offset of the circle's center from the left edge of the screen.
      * \param y The offset of the circle's center from the top edge of the screen.
      * \param radius The circle's radius.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void DrawCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 );
     
@@ -287,7 +282,7 @@
      * \param x The offset of the circle's center from the left edge of the screen.
      * \param y The offset of the circle's center from the top edge of the screen.
      * \param radius The circle's radius.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void FillCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 );
     
@@ -419,7 +414,7 @@
      * \param y Y coordinate of the starting point of the line.
      * \param len Length of the line.
      * \param color The color to use to draw the line. By default the global foreground color is used ( -2 ),
-     *              -1 switches to the default background color, or use the RGB macro for custom color.
+     *              -1 switches to the default background color, or any other RGB-565 color can be used.
      */
     virtual void DrawHLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 );
     
@@ -432,7 +427,7 @@
      * \param y Y coordinate of the starting point of the line.
      * \param len Height of the line.
      * \param color The color to use to draw the line. By default the global foreground color is used ( -2 ),
-     *              -1 switches to the default background color, or use the RGB macro for custom color.
+     *              -1 switches to the default background color, or any other RGB-565 color can be used.
      */
     virtual void DrawVLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 );
     
@@ -442,9 +437,9 @@
      * \param x X coordinate of the character position.
      * \param y Y coordinate of the character position.
      * \param fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ),
-     *                -1 switches to the default background color, or use the RGB macro for custom color.
+     *                -1 switches to the default background color, or any other RGB-565 color can be used.
      * \param bgColor Background color for drawing. By default the global background color is used ( -1 ),
-     *                -2 switches to the default foreground color, or use the RGB macro for custom color.
+     *                -2 switches to the default foreground color, or any other RGB-565 color can be used.
      */
     virtual void PrintChar( char c, unsigned short x, unsigned short y, int fgColor = -2, int bgColor = -1 );
     
@@ -455,9 +450,9 @@
      * \param y Y coordinate of the character position.
      * \param pos Position of the character in the string from which it originates (used to rotate a whole string).
      * \param fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ),
-     *                -1 switches to the default background color, or use the RGB macro for custom color.
+     *                -1 switches to the default background color, or any other RGB-565 color can be used.
      * \param bgColor Background color for drawing. By default the global background color is used ( -1 ),
-     *                -2 switches to the default foreground color, or use the RGB macro for custom color.
+     *                -2 switches to the default foreground color, or any other RGB-565 color can be used.
      * \param deg The angle at which to rotate. 
      */
     virtual void RotateChar( char c, unsigned short x, unsigned short y, int pos, int fgColor = -2, int bgColor = -1, unsigned short deg = 0 );
@@ -466,7 +461,7 @@
     unsigned short  _disp_width, _disp_height;
     DigitalOut      _lcd_pin_cs, _lcd_pin_rs, _lcd_pin_reset;
     orientation_t   _orientation;
-    unsigned int    _foreground, _background;
+    unsigned short  _foreground, _background;
     font_metrics_t  _font;
 };