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