EasyRad / TFTLCD

Fork of TFTLCD by Todor Todorov

Files at this revision

API Documentation at this revision

Comitter:
ttodorov
Date:
Thu Dec 06 02:18:22 2012 +0000
Parent:
7:5c418fc1879f
Child:
9:58b328831d0a
Commit message:
- preparation for drivers with 18 bit color mode

Changed in this revision

lcd_base.cpp Show annotated file Show diff for this revision Revisions of this file
lcd_base.h Show annotated file Show diff for this revision Revisions of this file
--- a/lcd_base.cpp	Tue Dec 04 02:26:44 2012 +0000
+++ b/lcd_base.cpp	Thu Dec 06 02:18:22 2012 +0000
@@ -31,13 +31,13 @@
 }
 
 inline
-void LCD::SetForeground( unsigned short color )
+void LCD::SetForeground( unsigned int color )
 {
     _foreground = color;
 }
 
 inline
-void LCD::SetBackground( unsigned short color )
+void LCD::SetBackground( unsigned int color )
 {
     _background = color;
 }
@@ -67,7 +67,7 @@
 
 void LCD::FillScreen( int color )
 {
-    unsigned short rgb = color == -1 ? _background : color == -2 ? _foreground : ( unsigned short ) color;
+    unsigned int rgb = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color;
     Activate();
     ClearXY();
     for ( int i = 0; i < ( ( _disp_width ) * ( _disp_height ) ); i++ )
@@ -120,7 +120,7 @@
     }
     else
     {
-        unsigned short usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned short ) color;
+        unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color;
         Activate();
         if ( abs( x2 - x1 ) > abs( y2 - y1 ) )
         {
@@ -261,7 +261,7 @@
     int ddF_y = -2 * radius;
     int x1 = 0;
     int y1 = radius;
-    unsigned short usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned short ) color;
+    unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color;
 
     Activate();
     SetXY( x, y + radius, x, y + radius );
@@ -306,7 +306,7 @@
 
 void LCD::FillCircle( unsigned short x, unsigned short y, unsigned short radius, int color )
 {
-    unsigned short usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned short ) color;
+    unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color;
     Activate();
     for ( int y1 = -radius; y1 <= radius; y1++ )
         for ( int x1 = -radius; x1 <= radius; x1++ )
@@ -491,7 +491,7 @@
 
 void LCD::DrawHLine( unsigned short x, unsigned short y, unsigned short len, int color )
 {
-    unsigned short usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned short ) color;
+    unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color;
     
     Activate();
     SetXY( x, y, x + len, y );
@@ -502,7 +502,7 @@
 
 void LCD::DrawVLine( unsigned short x, unsigned short y, unsigned short len, int color )
 {
-    unsigned short usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned short ) color;
+    unsigned int usedColor = color == -1 ? _background : color == -2 ? _foreground : ( unsigned int ) color;
     
     Activate();
     SetXY( x, y, x, y + len );
@@ -516,8 +516,8 @@
     uint8_t i, ch;
     uint16_t j;
     uint16_t temp;
-    unsigned short usedColorFG = fgColor == -1 ? _background : fgColor == -2 ? _foreground : ( unsigned short ) fgColor;
-    unsigned short usedColorBG = bgColor == -1 ? _background : bgColor == -2 ? _foreground : ( unsigned short ) bgColor;
+    unsigned int usedColorFG = fgColor == -1 ? _background : fgColor == -2 ? _foreground : ( unsigned int ) fgColor;
+    unsigned int usedColorBG = bgColor == -1 ? _background : bgColor == -2 ? _foreground : ( unsigned int ) bgColor;
 
     Activate();
 
@@ -571,8 +571,8 @@
     double radian;
     radian = deg * 0.0175;
     
-    unsigned short usedColorFG = fgColor == -1 ? _background : fgColor == -2 ? _foreground : ( unsigned short ) fgColor;
-    unsigned short usedColorBG = bgColor == -1 ? _background : bgColor == -2 ? _foreground : ( unsigned short ) bgColor;
+    unsigned int usedColorFG = fgColor == -1 ? _background : fgColor == -2 ? _foreground : ( unsigned int ) fgColor;
+    unsigned int usedColorBG = bgColor == -1 ? _background : bgColor == -2 ? _foreground : ( unsigned int ) bgColor;
 
     Activate();
 
--- a/lcd_base.h	Tue Dec 04 02:26:44 2012 +0000
+++ b/lcd_base.h	Thu Dec 06 02:18:22 2012 +0000
@@ -161,10 +161,11 @@
      * 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. The value must be in RGB-565 format.
+     * \param color The color to be used. Use the RGB macro to create the correct
+     *              color for the used LCD driver.
      * \sa #RGB(r,g,b)
      */
-    virtual void SetForeground( unsigned short color = COLOR_WHITE );
+    virtual void SetForeground( unsigned int color = COLOR_WHITE );
     
     /** Set the background color for painting.
      *
@@ -173,10 +174,11 @@
      * 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 as RGB-565 value.
+     * \param color The background color. Use the RGB macro to create the correct
+     *              color for the used LCD driver.
      * \sa #RGB(r,g,b)
      */
-    virtual void SetBackground( unsigned short color = COLOR_BLACK );
+    virtual void SetBackground( unsigned int color = COLOR_BLACK );
     
     /** Sets the font to be used for painting of text on the screen.
      * \param font A pointer to the font data.
@@ -195,9 +197,10 @@
     unsigned short GetHeight( void );
     
     /** Fills the whole screen with a single color.
-     * \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.
+     * \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.
      */
     virtual void FillScreen( int color = -1 );
     
@@ -214,7 +217,8 @@
      *
      * \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. Must be in RGB-565 format, or -1 for background and -2 for foreground color.
+     * \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.
      */
     virtual void DrawPixel( unsigned short x, unsigned short y, int color = -2 );
     
@@ -224,7 +228,8 @@
      * \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, in RGB-565 format, or -1 for background, or -2 for foreground.
+     * \param color The color to use for painting; use -1 for background, or -2 for foreground,
+     *              or the RGB macro for custom colors.
      */
     virtual void DrawLine( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -234,7 +239,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 custom color in RGB-565 format.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
      */
     virtual void DrawRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -244,7 +249,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 custom color in RGB-565 format.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
      */
     virtual void DrawRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -254,7 +259,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 custom color in RGB-565 format.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
      */
     virtual void FillRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -264,7 +269,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 custom color in RGB-565 format.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
      */
     virtual void FillRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -273,7 +278,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 custom color in RGB-565 format.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
      */
     virtual void DrawCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 );
     
@@ -282,7 +287,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 custom color in RGB-565 format.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
      */
     virtual void FillCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 );
     
@@ -414,7 +419,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 any other RGB-565 color can be used.
+     *              -1 switches to the default background color, or use the RGB macro for custom color.
      */
     virtual void DrawHLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 );
     
@@ -427,7 +432,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 any other RGB-565 color can be used.
+     *              -1 switches to the default background color, or use the RGB macro for custom color.
      */
     virtual void DrawVLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 );
     
@@ -437,9 +442,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 any other RGB-565 color can be used.
+     *                -1 switches to the default background color, or use the RGB macro for custom color.
      * \param bgColor Background color for drawing. By default the global background color is used ( -1 ),
-     *                -2 switches to the default foreground color, or any other RGB-565 color can be used.
+     *                -2 switches to the default foreground color, or use the RGB macro for custom color.
      */
     virtual void PrintChar( char c, unsigned short x, unsigned short y, int fgColor = -2, int bgColor = -1 );
     
@@ -450,9 +455,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 any other RGB-565 color can be used.
+     *                -1 switches to the default background color, or use the RGB macro for custom color.
      * \param bgColor Background color for drawing. By default the global background color is used ( -1 ),
-     *                -2 switches to the default foreground color, or any other RGB-565 color can be used.
+     *                -2 switches to the default foreground color, or use the RGB macro for custom color.
      * \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 );
@@ -461,7 +466,7 @@
     unsigned short  _disp_width, _disp_height;
     DigitalOut      _lcd_pin_cs, _lcd_pin_rs, _lcd_pin_reset;
     orientation_t   _orientation;
-    unsigned short  _foreground, _background;
+    unsigned int    _foreground, _background;
     font_metrics_t  _font;
 };