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.
Fork of TFTLCD by
Diff: lcd_base.h
- Revision:
- 8:7a4791dbb065
- Parent:
- 7:5c418fc1879f
- Child:
- 9:58b328831d0a
--- 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; };