Gregor Mraczny / TFTLCD_Landtiger
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lcd_base.h Source File

lcd_base.h

Go to the documentation of this file.
00001 /** \file lcd_base.h
00002  *  \brief Base class for all LCD controller implementations.
00003  *  \copyright GNU Public License, v2. or later
00004  *
00005  * Generic object painting and screen control.
00006  *
00007  * This library is based on the Arduino/chipKIT UTFT library by Henning
00008  * Karlsen, http://henningkarlsen.com/electronics/library.php?id=52
00009  *
00010  * Copyright (C)2010-2012 Henning Karlsen. All right reserved.
00011  *
00012  * Copyright (C)2012 Todor Todorov.
00013  *
00014  * This library is free software; you can redistribute it and/or
00015  * modify it under the terms of the GNU Lesser General Public
00016  * License as published by the Free Software Foundation; either
00017  * version 2.1 of the License, or (at your option) any later version.
00018  *
00019  * This library is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022  * Lesser General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public
00025  * License along with this library; if not, write to:
00026  *
00027  * Free Software Foundation, Inc.
00028  * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA
00029  *
00030  *********************************************************************/
00031 #ifndef TFTLCD_BASE_H
00032 #define TFTLCD_BASE_H
00033 
00034 #include "mbed.h"
00035 #include "terminus.h"
00036 
00037 
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 /** \def RGB(r,g,b)
00044  *  \brief Creates a RGB color from distinct bytes for the red, green and blue components.
00045  *
00046  * Displays which use 16 bits to assign colors to a specific pixel, use
00047  * 5 bits for the red component, 6 bits for the green component and 5
00048  * bits for the blue component.  Displays which have 18-bit color depth
00049  * use 6 bits for red, 6 bits for green and 6 bits for blue component.
00050  * This macro preserves the full 24-bit color depth, but it is the responsibility
00051  * of the respective driver to convert the color value to the correct format.
00052  */
00053 #define RGB( r, g, b )          ( ( r ) << 16 ) | ( ( g ) << 8 ) | ( b )
00054 /** \def COLOR_BLACK
00055  *  \brief Shorthand for RGB( 0, 0, 0 ).
00056  */
00057 #define COLOR_BLACK             RGB( 0x00, 0x00, 0x00 )
00058 /** \def COLOR_WHITE
00059  *  \brief Shorthand for RGB( 255, 255, 255 ).
00060  */
00061 #define COLOR_WHITE             RGB( 0xFF, 0xFF, 0xFF )
00062 /** \def COLOR_RED
00063  *  \brief Shorthand for RGB( 255, 0, 0 ).
00064  */
00065 #define COLOR_RED               RGB( 0xFF, 0x00, 0x00 )
00066 /** \def COLOR_GREEN
00067  *  \brief Shorthand for RGB( 0, 255, 0 ).
00068  */
00069 #define COLOR_GREEN             RGB( 0x00, 0xFF, 0x00 )
00070 /** \def COLOR_BLUE
00071  *  \brief Shorthand for RGB( 0, 0, 255 ).
00072  */
00073 #define COLOR_BLUE              RGB( 0x00, 0x00, 0xFF )
00074 /** \def COLOR_CYAN
00075  *  \brief Shorthand for RGB( 0, 255, 255 )
00076  */
00077 #define COLOR_CYAN              RGB( 0x00, 0xFF, 0xFF )
00078 /** \def COLOR_MAGENTA
00079  *  \brief Shorthand for RGB( 255, 0, 255 )
00080  */
00081 #define COLOR_MAGENTA           RGB( 0xFF, 0x00, 0xFF )
00082 /** \def COLOR_YELLOW
00083  *  \brief Shorthand for RGB( 255, 255, 0 )
00084  */
00085 #define COLOR_YELLOW            RGB( 0xFF, 0xFF, 0x00 )
00086 
00087 
00088 /** \enum Orientation_enum
00089  *  \brief Display orientation.
00090  */
00091 enum Orientation_enum
00092 {
00093     PORTRAIT = 0, /**< Top row of the screen is at 12 o'clock. */ 
00094     LANDSCAPE = 1, /**< Top row of the screen is at 9 o'clock. */
00095     PORTRAIT_REV = 2, /**< Top row of the screen is at 6 o'clock. */
00096     LANDSCAPE_REV = 3, /**< Top row of the screen is at 3 o'clock. */
00097 };
00098 /** \typedef orientation_t
00099  *  \brief Convenience shortcut for display orientation.
00100  */
00101 typedef enum Orientation_enum orientation_t;
00102 
00103 /** \enum ColorDepth_enum
00104  *  \brief Color depth
00105  */
00106 enum ColorDepth_enum
00107 {
00108     RGB16, /**< 16-bit colors, pixels can have 65K+ distinct color values */
00109     RGB18, /**< 18-bit colors, pixels can have 262K+ distinct color values */
00110     RGB24, /**< 24-bit colors, full 8 bits per component, 16M+ distinct color values */
00111 };
00112 /** \typedef colordepth_t
00113  *  \brief Convenience shortcut for display color depth.
00114  */
00115 typedef enum ColorDepth_enum colordepth_t;
00116 
00117 /** \enum Alignment_enum
00118  *  \brief Horizontal text alignment on the line.
00119  */
00120 enum Alignment_enum
00121 {
00122     LEFT = 0, /**< Left-oriented, naturally gravitate closer to the left edge of the screen. */
00123     CENTER = 9998, /**< Center-oriented, try to fit in the middle of the available space with equal free space to the left and right of the text. */
00124     RIGHT = 9999, /**< Right-oriented, naturally gravitate closer to the right edge of the screen, leaving any remaining free space to the left of the text. */
00125 };
00126 /** \typedef align_t
00127  *  \brief Convenience shortcut for text alignment.
00128  */
00129 typedef enum Alignment_enum align_t;
00130 
00131 ///** \struct Font_struct
00132 // *  \brief Describes fonts and their properties.
00133 // *  \sa Comments in fonts.h
00134 // */
00135 //struct Font_struct
00136 //{
00137 //    const    char* font; /**< A pointer to the first byte in the font. */
00138 //    unsigned char  width; /**< The width of each character, in pixels. */
00139 //    unsigned char  height; /**< Height of each character, in pixels. */
00140 //    unsigned char  offset; /**< Offset of the first character in the font. */
00141 //    unsigned char  numchars; /**< Count of the available characters in the font. */
00142 //};
00143 ///** \typedef font_metrics_t
00144 // *  \brief Convenience shortcut for fonts properties.
00145 // */
00146 //typedef struct Font_struct font_metrics_t;
00147 
00148 /** \struct Bitmap_struct
00149  *  \brief Describes an image.
00150  */
00151 struct Bitmap_struct
00152 {
00153     colordepth_t Format; /**< Color depth of the image. */
00154     unsigned short Width; /**< Width of the image in pixels. */
00155     unsigned short Height; /**< Height of the image in pixels. */
00156     const void* PixelData; /**< Image pixel data. */
00157 };
00158 /** \typedef bitmap_t
00159  *  \brief Convenience shortcut bitmap type.
00160  */
00161 typedef struct Bitmap_struct bitmap_t;
00162 
00163 /** \struct BacklightPwmCtrl_enum
00164  *  \brief Type of backlight control for the LCD.
00165  *
00166  * When the selected type is \c Constant, the pin is simply on or off - there is no gradation in the intensity of the display.
00167  * In this case any free pin can be used to control the backlight.  On the other hand, when PWM is used to control brightness,
00168  * take care to use only PWM-able mbed pins (p21, p22, p23, p24, p25, and p26), any other pins won't work.  It is assumed that
00169  * you know what you are doing, so no check is done to prevent using a non-PWM pin as assigned control pin, when either \c Direct
00170  * or \c Indirect option is used.
00171  *
00172  * \version 0.1
00173  * \remark When choosing PWM to control the backlight, you have the option to choose the pin to either source (\c Direct) or sink
00174  *         (\c Indirect) the current for LCD brightness control.  Be aware that the mbed pins can source (and probably sink when
00175  *         configured as inputs) only 4 mA @+3V3 VDD.  So if you are intending to use a bigger LCD, whith more LEDs in its backlight
00176  *         implementation, you probably want to interface it through a small signal transistor or a small MOSFET, in order to be able
00177  *         to handle a higher current without damaging your mbed.
00178  * \remark As of version 0.1 (2013-01-25) the Indirect method of PWM has not been implemented yet.
00179  */
00180 enum BacklightPwmCtrl_enum
00181 {
00182     Constant, /**< When the pin is a simple on/off switch. */
00183     Direct, /**< Control the brightness with PWM, as the control pin is sourcing the current to drive the backlight LEDs. */
00184     Indirect, /**< Control the brightness with PWM, as the control pin is sinking the current which drives the backlight LEDs. */
00185 };
00186 /** \typedef backlight_t
00187  *  \brief Convenience shortcut for the backlight control type.
00188  */
00189 typedef BacklightPwmCtrl_enum backlight_t;
00190 
00191 
00192 /** Base class for LCD implementations.
00193  *
00194  * All separate LCD controller implementations have to subclass this one.
00195  *
00196  * \version 0.1
00197  * \author Todor Todorov
00198  */
00199 class LCD
00200 {
00201 public:
00202 
00203     /** Initialize display.
00204      *
00205      * Wakes up the display from sleep, initializes power parameters.
00206      * This function must be called first, befor any painting on the
00207      * display is done, otherwise the positioning of graphical elements
00208      * will not work properly and any paynt operation will not be visible
00209      * or produce garbage.
00210      *
00211      * This function is controller-specific and needs to be implemented
00212      * separately for each available display.
00213      * \param oritentation The display orientation, landscape is default.
00214      * \param colors The correct color depth to use for the pixel data.
00215      */
00216     virtual void Initialize( orientation_t orientation, colordepth_t colors ) = 0;
00217     
00218     /** Puts the display to sleep.
00219      *
00220      * When the display is in sleep mode, its power consumption is
00221      * minimized.  Before new pixel data can be written to the display
00222      * memory, the controller needs to be brought out of sleep mode.
00223      * \sa #WakeUp( void );
00224      * \remarks The result of this operation might not be exactly as
00225      *          expected. Putting the display to sleep will cause the
00226      *          controller to switch to the standard color of the LCD,
00227      *          so depending on whether the display is normally white,
00228      *          or normally dark, the screen might or might not go
00229      *          dark.  Additional power saving can be achieved, if
00230      *          the backlight of the used display is not hardwired on
00231      *          the PCB and can be controlled via the BL pin.
00232      * \remarks This function is controller-specific and needs to be
00233      *          implemented separately for each available display.
00234      */
00235     virtual void Sleep( void );
00236     
00237     /** Wakes up the display from sleep mode.
00238      *
00239      * This function needs to be called before any other, when the
00240      * display has been put into sleep mode by a previois call to
00241      * #Sleep( void ).
00242      * \remarks This function is controller-specific and needs to be
00243      *          implemented separately for each available display.
00244      */
00245     virtual void WakeUp( void );
00246     
00247     /** Set the foreground color for painting.
00248      *
00249      * This is the default foreground color to be used in painting operations.
00250      * If a specific output function allows for a different color to be specified
00251      * in place, the new setting will be used for that single operation only and
00252      * will not change this value.
00253      *
00254      * \param color The color to be used (24-bit color depth).
00255      * \sa #RGB(r,g,b)
00256      */
00257     virtual void SetForeground( unsigned int color = COLOR_WHITE);
00258     
00259     /** Set the background color for painting.
00260      *
00261      * This is the default color to be used for "empty" pixels while painting.
00262      * If a particular function allows for a different value to be specified
00263      * when the function is called, the new value will be used only for this
00264      * single call and will not change this setting.
00265      *
00266      * \param color The background color (24-bit color depth).
00267      * \sa #RGB(r,g,b)
00268      */
00269     virtual void SetBackground( unsigned int color = COLOR_BLACK );
00270     
00271     /** Sets the font to be used for painting of text on the screen.
00272      * \param font A pointer to the font data.
00273      * \sa Comments in file fonts.h
00274      */
00275     virtual void SetFont( const font_t* font );
00276     
00277     /** Gets the display width.
00278      *  \return Display width in pixels.
00279      */
00280     unsigned short GetWidth( void );
00281     
00282     /** Gets the display height.
00283      *  \return Display height in pixels.
00284      */
00285     unsigned short GetHeight( void );
00286     
00287     /** Gets the font width.
00288      *  \return The current font width.
00289      */
00290     uint8_t GetFontWidth( void );
00291     
00292     /** Gets the font height.
00293      *  \return The current font height.
00294      */
00295     uint8_t GetFontHeight( void );
00296     
00297     /** Fills the whole screen with a single color.
00298      * \param color The color to be used. The value must be in RGB-565 format.
00299      * \remarks The special values -1 and -2 signify the preset background and foreground colors, respectively.
00300      *          The backround color is the default.
00301      */
00302     virtual void FillScreen( int color = -1 );
00303     
00304     /** Sets the backlight intensity in percent as a float value in the range [0.0,1.0].
00305      *  \param level The backligh intensity in percent, where 0.0 is off and 1.0 is full brightness.
00306      */
00307      
00308     virtual void SetBacklightLevel( float level );
00309     
00310     /** Clears the screen.
00311      *
00312      * This is the same as calling #FillScreen() or #FillScreen( -1 ) to use the background color.
00313      */
00314     virtual void ClearScreen( void );
00315     
00316     /** Draws a pixel at the specified location.
00317      *
00318      * By default the function will use the preset foreground color, but the background
00319      * or a custom color could be used as well.
00320      *
00321      * \param x The horizontal offset of the pixel from the upper left corner of the screen.
00322      * \param y The vertical offset of the pixel from the upper left corner of the screen.
00323      * \param color The color to be used. Use a custom color, or -1 for background and -2 for foreground color.
00324      */
00325     virtual void DrawPixel( unsigned short x, unsigned short y, int color = -2 );
00326     
00327     /** Draws a line.
00328      *
00329      * \param x1 Horizontal offset of the beginning point of the line.
00330      * \param y1 Vertical offset of the beginning point of the line.
00331      * \param x2 Horizontal offset of the end point of the line.
00332      * \param y2 Verical offset of the end point of the line.
00333      * \param color The color to use for painting, or -1 for background, or -2 for foreground.
00334      */
00335     virtual void DrawLine( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
00336     
00337     /** Paints a rectangle.
00338      *
00339      * \param x1 The horizontal offset of the beginning point of one of the rectangle's diagonals.
00340      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
00341      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
00342      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
00343      * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
00344      */
00345     virtual void DrawRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
00346     
00347     /** Paints a rectangle and fills it with the paint color.
00348      *
00349      * \param x1 The horizontal offset of the beginning point of one of the rectangle's diagonals.
00350      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
00351      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
00352      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
00353      * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
00354      */
00355     virtual void DrawRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
00356     
00357     /** Paints a rectangle with rounded corners.
00358      *
00359      * \param x1 The horizontal offset of the beginning point of one of the rectangle's diagonals.
00360      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
00361      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
00362      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
00363      * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
00364      */
00365     virtual void FillRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
00366     
00367     /** Paints a rectangle with rounded corners and fills it with the paint color.
00368      *
00369      * \param x1 The horizontal offset of the beginning point of one of the rectangle's diagonals.
00370      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
00371      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
00372      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
00373      * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
00374      */
00375     virtual void FillRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
00376     
00377     /** Paints a circle.
00378      *
00379      * \param x The offset of the circle's center from the left edge of the screen.
00380      * \param y The offset of the circle's center from the top edge of the screen.
00381      * \param radius The circle's radius.
00382      * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
00383      */
00384     virtual void DrawCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 );
00385     
00386     /** Paints a circle and fills it with the paint color.
00387      *
00388      * \param x The offset of the circle's center from the left edge of the screen.
00389      * \param y The offset of the circle's center from the top edge of the screen.
00390      * \param radius The circle's radius.
00391      * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color.
00392      */
00393     virtual void FillCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 );
00394     
00395     /** Print a text on the screen.
00396      *
00397      * \param str The text.
00398      * \param x The horizontal offset form the left edge of the screen. The special values LEFT, CENTER,
00399      *          or RIGHT can be used instead of pixel offset to indicate the text's horizontal alignment.
00400      * \param y The vertical offset of the text from the top of the screen.
00401      * \param fgColor The foreground to use for painting the text; -1 indicates background color, -2 the foreground setting, or custom color.
00402      * \param bgColor The color to use for painting the empty pixels; -1 indicates the background color, -2 the foreground setting, or custom color.
00403      * \param deg If different than 0, the text will be rotated at an angle this many degrees around its starting point. Default is not to ratate.
00404      */
00405     virtual void Print( const char *str, unsigned short x, unsigned short y, int fgColor = -2, int bgColor = -1, unsigned short deg = 0 );
00406     
00407     /** Draw an image on the screen.
00408      *
00409      * The pixels of the picture must be in the RGB-565 format.  The data can be provided
00410      * as an array in a source or a header file.  To convert an image file to the appropriate
00411      * format, a special utility must be utilized.  One such tool is provided by Henning Karlsen,
00412      * the author of the UTFT display liberary and can be downloaded for free from his web site:
00413      * http://henningkarlsen.com/electronics/library.php?id=52
00414      *
00415      * \param x Horizontal offset of the first pixel of the image.
00416      * \param y Vertical offset of the first pixel of the image.
00417      * \param img Image data pointer.
00418      * \param scale A value of 1 will produce an image with its original size, while a different value will scale the image.
00419      */
00420     virtual void DrawBitmap( unsigned short x, unsigned short y, const bitmap_t* img, unsigned char scale = 1 );
00421     
00422     /** Draw an image on the screen.
00423      *
00424      * The pixels of the picture must be in the RGB-565 format.  The data can be provided
00425      * as an array in a source or a header file.  To convert an image file to the appropriate
00426      * format, a special utility must be utilized.  One such tool is provided by Henning Karlsen,
00427      * the author of the UTFT display liberary and can be downloaded for free from his web site:
00428      * http://henningkarlsen.com/electronics/library.php?id=52
00429      *
00430      * \param x Horizontal offset of the first pixel of the image.
00431      * \param y Vertical offset of the first pixel of the image.
00432      * \param img Image data pointer.
00433      * \param deg Angle to rotate the image before painting on screen, in degrees.
00434      * \param rox
00435      * \param roy
00436      */
00437     virtual void DrawBitmap( unsigned short x, unsigned short y, const bitmap_t* img, unsigned short deg, unsigned short rox, unsigned short roy );
00438     
00439         /** Sends both command and data to the display controller.
00440      *
00441      * This is a helper utility function which combines the 2 functions above
00442      * into one single convenience step.
00443      *
00444      * \param cmd The display command.
00445      * \param data The display pixel data.
00446      */
00447     virtual void WriteCmdData( unsigned short cmd, unsigned short data );      
00448     
00449 protected:
00450     /** Creates an instance of the class.
00451      *
00452      * \param width Width of the display in pixels.
00453      * \param height Height of the display in pixels.
00454      * \param CS Pin connected to the CS input of the display.
00455      * \param RS Pin connected to the RS input of the display.
00456      * \param RESET Pin connected to the RESET input of the display.
00457      * \param BL Pin connected to the circuit controlling the LCD's backlight.
00458      * \param blType The type of backlight to be used.
00459      * \param defaultBacklight The standard backlight intensity (if using PWM control), expressed in percent as float value from 0.0 to 1.0
00460      */
00461     LCD( unsigned short width, unsigned short height, PinName CS, PinName RS,  PinName DIR, PinName EN, PinName LE, PinName BL, backlight_t blType, float defaultBacklight );
00462 
00463     /** Activates the display for command/data transfer.
00464      *
00465      * Usually achieved by pulling the CS pin of the display low.
00466      */
00467     virtual void Activate( void );
00468     
00469     /** Deactivates the display after data has been transmitted.
00470      *
00471      * Usually achieved by pulling the CS pin of the display high.
00472      */
00473     virtual void Deactivate( void );
00474     
00475     /** Sends a command to the display.
00476      *
00477      * \param cmd The display command.
00478      * \remarks Commands are controller-specific and this function needs to
00479      *          be implemented separately for each available controller.
00480      */
00481     virtual void WriteCmd( unsigned short cmd ) = 0;
00482     
00483     /** Sends pixel data to the display.
00484      *
00485      * \param data The display data.
00486      * \remarks Sendin data is controller-specific and this function needs to
00487      *          be implemented separately for each available controller.
00488      */
00489     virtual void WriteData( unsigned short data ) = 0;
00490     
00491 
00492     
00493     /** Assigns a chunk of the display memory to receive data.
00494      *
00495      * When data is sent to the display after this function completes, the opertion will
00496      * start from the begining of the assigned address (pixel position) and the pointer
00497      * will be automatically incremented so that the next data write operation will continue
00498      * with the next pixel from the memory block.  If more data is written than available
00499      * pixels, at the end of the block the pointer will jump back to its beginning and
00500      * commence again, until the next address change command is sent to the display.
00501      *
00502      * \param x1 The X coordinate of the pixel at the beginning of the block.
00503      * \param y1 The Y coordinate of the pixel at the beginning of the block.
00504      * \param x2 The X coordinate of the pixel at the end of the block.
00505      * \param y2 The Y coordinate of the pixel at the end of the block.
00506      * \remarks Addressing commands are controller-specific and this function needs to be
00507      *          implemented separately for each available controller.
00508      */
00509     virtual void SetXY( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2 ) = 0;
00510     
00511     /** Resets the memory address for the next display write operation to the screen origins (0,0).
00512      */
00513     virtual void ClearXY( void );
00514     
00515     /** Sets the color of the pixel at the address pointer of the controller.
00516      *
00517      * This function is to be provided by each implementation separately in
00518      * order to account for different color depths used by the controller.
00519      * \param color The color of the pixel.
00520      * \param mode The depth (palette) of the color.
00521      */
00522     virtual void SetPixelColor( unsigned int color, colordepth_t mode = RGB24 ) = 0;
00523     
00524     /** Draws a horizontal line.
00525      *
00526      * This is a utility function to draw horizontal-only lines
00527      * for reduced code complexity and faster execution.
00528      *
00529      * \param x X coordinate of the starting point of the line.
00530      * \param y Y coordinate of the starting point of the line.
00531      * \param len Length of the line.
00532      * \param color The color to use to draw the line. By default the global foreground color is used ( -2 ),
00533      *              -1 switches to the default background color, or any custom color can be used.
00534      */
00535     virtual void DrawHLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 );
00536     
00537     /** Draws a vertical line.
00538      *
00539      * This is a utility function to draw vertical-only lines
00540      * for reduced code complexity and faster execution.
00541      *
00542      * \param x X coordinate of the starting point of the line.
00543      * \param y Y coordinate of the starting point of the line.
00544      * \param len Height of the line.
00545      * \param color The color to use to draw the line. By default the global foreground color is used ( -2 ),
00546      *              -1 switches to the default background color, or any custom color can be used.
00547      */
00548     virtual void DrawVLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 );
00549     
00550     /** Prints a character at the given position and using the given color.
00551      *
00552      * \param c The character.
00553      * \param x X coordinate of the character position.
00554      * \param y Y coordinate of the character position.
00555      * \param fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ),
00556      *                -1 switches to the default background color, or any custom color can be used.
00557      * \param bgColor Background color for drawing. By default the global background color is used ( -1 ),
00558      *                -2 switches to the default foreground color, or any custom color can be used.
00559      */
00560     virtual void PrintChar( char c, unsigned short x, unsigned short y, int fgColor = -2, int bgColor = -1 );
00561     
00562     /** Prints a character at the given position and using the given color and with the given rotation.
00563      *
00564      * \param c The character.
00565      * \param x X coordinate of the character position.
00566      * \param y Y coordinate of the character position.
00567      * \param pos Position of the character in the string from which it originates (used to rotate a whole string).
00568      * \param fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ),
00569      *                -1 switches to the default background color, or any custom color can be used.
00570      * \param bgColor Background color for drawing. By default the global background color is used ( -1 ),
00571      *                -2 switches to the default foreground color, or any custom color can be used.
00572      * \param deg The angle at which to rotate. 
00573      */
00574     virtual void RotateChar( char c, unsigned short x, unsigned short y, int pos, int fgColor = -2, int bgColor = -1, unsigned short deg = 0 );
00575 
00576 protected:
00577     unsigned short  _disp_width, _disp_height;
00578     DigitalOut      _lcd_pin_cs, _lcd_pin_rs,  _lcd_pin_dir, _lcd_pin_en, _lcd_pin_le;
00579     orientation_t   _orientation;
00580     colordepth_t    _colorDepth;
00581     unsigned int    _foreground, _background;
00582     const font_t*   _font;
00583     DigitalOut*     _lcd_pin_bl;
00584     PwmOut*         _bl_pwm;
00585     backlight_t     _bl_type;
00586     float           _bl_pwm_default, _bl_pwm_current;
00587 };
00588 
00589 #ifdef __cplusplus
00590 }
00591 #endif
00592 
00593 #endif /* TFTLCD_BASE_H */