Forked from TFTLCD_8bit by Thiha Electronics
Dependents: GR-PEACH_TFTLCD_8bit
Fork of TFTLCD_8bit by
lcd_base.h@32:155abe4126e3, 2014-12-03 (annotated)
- Committer:
- ThihaElectronics
- Date:
- Wed Dec 03 16:35:25 2014 +0000
- Revision:
- 32:155abe4126e3
- Parent:
- 30:5f23a4cbebd7
sorry if i broken any of your code by recent check in. please enlighten me how to unlink library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ttodorov | 0:881ff0b71102 | 1 | /** \file lcd_base.h |
ttodorov | 0:881ff0b71102 | 2 | * \brief Base class for all LCD controller implementations. |
ttodorov | 0:881ff0b71102 | 3 | * \copyright GNU Public License, v2. or later |
ttodorov | 0:881ff0b71102 | 4 | * |
ttodorov | 0:881ff0b71102 | 5 | * Generic object painting and screen control. |
ttodorov | 0:881ff0b71102 | 6 | * |
ttodorov | 0:881ff0b71102 | 7 | * This library is based on the Arduino/chipKIT UTFT library by Henning |
ttodorov | 0:881ff0b71102 | 8 | * Karlsen, http://henningkarlsen.com/electronics/library.php?id=52 |
ttodorov | 0:881ff0b71102 | 9 | * |
ttodorov | 0:881ff0b71102 | 10 | * Copyright (C)2010-2012 Henning Karlsen. All right reserved. |
ttodorov | 5:09b6d228ceea | 11 | * |
ttodorov | 0:881ff0b71102 | 12 | * Copyright (C)2012 Todor Todorov. |
ttodorov | 0:881ff0b71102 | 13 | * |
ttodorov | 0:881ff0b71102 | 14 | * This library is free software; you can redistribute it and/or |
ttodorov | 0:881ff0b71102 | 15 | * modify it under the terms of the GNU Lesser General Public |
ttodorov | 0:881ff0b71102 | 16 | * License as published by the Free Software Foundation; either |
ttodorov | 0:881ff0b71102 | 17 | * version 2.1 of the License, or (at your option) any later version. |
ttodorov | 0:881ff0b71102 | 18 | * |
ttodorov | 0:881ff0b71102 | 19 | * This library is distributed in the hope that it will be useful, |
ttodorov | 0:881ff0b71102 | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ttodorov | 0:881ff0b71102 | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ttodorov | 0:881ff0b71102 | 22 | * Lesser General Public License for more details. |
ttodorov | 0:881ff0b71102 | 23 | * |
ttodorov | 0:881ff0b71102 | 24 | * You should have received a copy of the GNU Lesser General Public |
ttodorov | 0:881ff0b71102 | 25 | * License along with this library; if not, write to: |
ttodorov | 0:881ff0b71102 | 26 | * |
ttodorov | 0:881ff0b71102 | 27 | * Free Software Foundation, Inc. |
ttodorov | 0:881ff0b71102 | 28 | * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA |
ttodorov | 0:881ff0b71102 | 29 | * |
ttodorov | 0:881ff0b71102 | 30 | *********************************************************************/ |
ttodorov | 3:64a5b67d5b51 | 31 | #ifndef TFTLCD_BASE_H |
ttodorov | 3:64a5b67d5b51 | 32 | #define TFTLCD_BASE_H |
ttodorov | 0:881ff0b71102 | 33 | |
ttodorov | 0:881ff0b71102 | 34 | #include "mbed.h" |
ttodorov | 21:e5c1e8ffada1 | 35 | #include "terminus.h" |
ttodorov | 0:881ff0b71102 | 36 | |
ttodorov | 6:059ca1648211 | 37 | #ifdef __cplusplus |
ttodorov | 6:059ca1648211 | 38 | extern "C" { |
ttodorov | 6:059ca1648211 | 39 | #endif |
ttodorov | 6:059ca1648211 | 40 | |
ttodorov | 0:881ff0b71102 | 41 | /** \def RGB(r,g,b) |
ttodorov | 12:d0978272a340 | 42 | * \brief Creates a RGB color from distinct bytes for the red, green and blue components. |
ttodorov | 0:881ff0b71102 | 43 | * |
ttodorov | 0:881ff0b71102 | 44 | * Displays which use 16 bits to assign colors to a specific pixel, use |
ttodorov | 0:881ff0b71102 | 45 | * 5 bits for the red component, 6 bits for the green component and 5 |
ttodorov | 12:d0978272a340 | 46 | * bits for the blue component. Displays which have 18-bit color depth |
ttodorov | 12:d0978272a340 | 47 | * use 6 bits for red, 6 bits for green and 6 bits for blue component. |
ttodorov | 12:d0978272a340 | 48 | * This macro preserves the full 24-bit color depth, but it is the responsibility |
ttodorov | 12:d0978272a340 | 49 | * of the respective driver to convert the color value to the correct format. |
ttodorov | 0:881ff0b71102 | 50 | */ |
ttodorov | 12:d0978272a340 | 51 | #define RGB( r, g, b ) ( ( r ) << 16 ) | ( ( g ) << 8 ) | ( b ) |
ttodorov | 0:881ff0b71102 | 52 | /** \def COLOR_BLACK |
ttodorov | 0:881ff0b71102 | 53 | * \brief Shorthand for RGB( 0, 0, 0 ). |
ttodorov | 0:881ff0b71102 | 54 | */ |
ttodorov | 0:881ff0b71102 | 55 | #define COLOR_BLACK RGB( 0x00, 0x00, 0x00 ) |
ttodorov | 0:881ff0b71102 | 56 | /** \def COLOR_WHITE |
ttodorov | 0:881ff0b71102 | 57 | * \brief Shorthand for RGB( 255, 255, 255 ). |
ttodorov | 0:881ff0b71102 | 58 | */ |
ttodorov | 0:881ff0b71102 | 59 | #define COLOR_WHITE RGB( 0xFF, 0xFF, 0xFF ) |
ttodorov | 0:881ff0b71102 | 60 | /** \def COLOR_RED |
ttodorov | 0:881ff0b71102 | 61 | * \brief Shorthand for RGB( 255, 0, 0 ). |
ttodorov | 0:881ff0b71102 | 62 | */ |
ttodorov | 0:881ff0b71102 | 63 | #define COLOR_RED RGB( 0xFF, 0x00, 0x00 ) |
ttodorov | 0:881ff0b71102 | 64 | /** \def COLOR_GREEN |
ttodorov | 0:881ff0b71102 | 65 | * \brief Shorthand for RGB( 0, 255, 0 ). |
ttodorov | 0:881ff0b71102 | 66 | */ |
ttodorov | 0:881ff0b71102 | 67 | #define COLOR_GREEN RGB( 0x00, 0xFF, 0x00 ) |
ttodorov | 0:881ff0b71102 | 68 | /** \def COLOR_BLUE |
ttodorov | 0:881ff0b71102 | 69 | * \brief Shorthand for RGB( 0, 0, 255 ). |
ttodorov | 0:881ff0b71102 | 70 | */ |
ttodorov | 0:881ff0b71102 | 71 | #define COLOR_BLUE RGB( 0x00, 0x00, 0xFF ) |
ttodorov | 19:eb27effb8c07 | 72 | /** \def COLOR_CYAN |
ttodorov | 19:eb27effb8c07 | 73 | * \brief Shorthand for RGB( 0, 255, 255 ) |
ttodorov | 19:eb27effb8c07 | 74 | */ |
ttodorov | 19:eb27effb8c07 | 75 | #define COLOR_CYAN RGB( 0x00, 0xFF, 0xFF ) |
ttodorov | 19:eb27effb8c07 | 76 | /** \def COLOR_MAGENTA |
ttodorov | 19:eb27effb8c07 | 77 | * \brief Shorthand for RGB( 255, 0, 255 ) |
ttodorov | 19:eb27effb8c07 | 78 | */ |
ttodorov | 19:eb27effb8c07 | 79 | #define COLOR_MAGENTA RGB( 0xFF, 0x00, 0xFF ) |
ttodorov | 19:eb27effb8c07 | 80 | /** \def COLOR_YELLOW |
ttodorov | 19:eb27effb8c07 | 81 | * \brief Shorthand for RGB( 255, 255, 0 ) |
ttodorov | 19:eb27effb8c07 | 82 | */ |
ttodorov | 19:eb27effb8c07 | 83 | #define COLOR_YELLOW RGB( 0xFF, 0xFF, 0x00 ) |
ttodorov | 19:eb27effb8c07 | 84 | |
ttodorov | 0:881ff0b71102 | 85 | |
ttodorov | 10:69571adcfad5 | 86 | /** \enum Orientation_enum |
ttodorov | 0:881ff0b71102 | 87 | * \brief Display orientation. |
ttodorov | 0:881ff0b71102 | 88 | */ |
ttodorov | 10:69571adcfad5 | 89 | enum Orientation_enum |
ttodorov | 0:881ff0b71102 | 90 | { |
ttodorov | 19:eb27effb8c07 | 91 | PORTRAIT = 0, /**< Top row of the screen is at 12 o'clock. */ |
ttodorov | 19:eb27effb8c07 | 92 | LANDSCAPE = 1, /**< Top row of the screen is at 9 o'clock. */ |
ttodorov | 19:eb27effb8c07 | 93 | PORTRAIT_REV = 2, /**< Top row of the screen is at 6 o'clock. */ |
ttodorov | 19:eb27effb8c07 | 94 | LANDSCAPE_REV = 3, /**< Top row of the screen is at 3 o'clock. */ |
ttodorov | 10:69571adcfad5 | 95 | }; |
ttodorov | 10:69571adcfad5 | 96 | /** \typedef orientation_t |
ttodorov | 10:69571adcfad5 | 97 | * \brief Convenience shortcut for display orientation. |
ttodorov | 10:69571adcfad5 | 98 | */ |
ttodorov | 10:69571adcfad5 | 99 | typedef enum Orientation_enum orientation_t; |
ttodorov | 0:881ff0b71102 | 100 | |
ttodorov | 10:69571adcfad5 | 101 | /** \enum ColorDepth_enum |
ttodorov | 10:69571adcfad5 | 102 | * \brief Color depth |
ttodorov | 10:69571adcfad5 | 103 | */ |
ttodorov | 10:69571adcfad5 | 104 | enum ColorDepth_enum |
ttodorov | 10:69571adcfad5 | 105 | { |
ttodorov | 20:4bdca8d8dadc | 106 | RGB16, /**< 16-bit colors, pixels can have 65K+ distinct color values */ |
ttodorov | 20:4bdca8d8dadc | 107 | RGB18, /**< 18-bit colors, pixels can have 262K+ distinct color values */ |
ttodorov | 20:4bdca8d8dadc | 108 | RGB24, /**< 24-bit colors, full 8 bits per component, 16M+ distinct color values */ |
ttodorov | 10:69571adcfad5 | 109 | }; |
ttodorov | 10:69571adcfad5 | 110 | /** \typedef colordepth_t |
ttodorov | 10:69571adcfad5 | 111 | * \brief Convenience shortcut for display color depth. |
ttodorov | 10:69571adcfad5 | 112 | */ |
ttodorov | 10:69571adcfad5 | 113 | typedef enum ColorDepth_enum colordepth_t; |
ttodorov | 10:69571adcfad5 | 114 | |
ttodorov | 10:69571adcfad5 | 115 | /** \enum Alignment_enum |
ttodorov | 0:881ff0b71102 | 116 | * \brief Horizontal text alignment on the line. |
ttodorov | 0:881ff0b71102 | 117 | */ |
ttodorov | 10:69571adcfad5 | 118 | enum Alignment_enum |
ttodorov | 0:881ff0b71102 | 119 | { |
ttodorov | 0:881ff0b71102 | 120 | LEFT = 0, /**< Left-oriented, naturally gravitate closer to the left edge of the screen. */ |
ttodorov | 0:881ff0b71102 | 121 | 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. */ |
ttodorov | 0:881ff0b71102 | 122 | 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. */ |
ttodorov | 10:69571adcfad5 | 123 | }; |
ttodorov | 10:69571adcfad5 | 124 | /** \typedef align_t |
ttodorov | 10:69571adcfad5 | 125 | * \brief Convenience shortcut for text alignment. |
ttodorov | 10:69571adcfad5 | 126 | */ |
ttodorov | 10:69571adcfad5 | 127 | typedef enum Alignment_enum align_t; |
ttodorov | 0:881ff0b71102 | 128 | |
ttodorov | 21:e5c1e8ffada1 | 129 | ///** \struct Font_struct |
ttodorov | 21:e5c1e8ffada1 | 130 | // * \brief Describes fonts and their properties. |
ttodorov | 21:e5c1e8ffada1 | 131 | // * \sa Comments in fonts.h |
ttodorov | 21:e5c1e8ffada1 | 132 | // */ |
ttodorov | 21:e5c1e8ffada1 | 133 | //struct Font_struct |
ttodorov | 21:e5c1e8ffada1 | 134 | //{ |
ttodorov | 21:e5c1e8ffada1 | 135 | // const char* font; /**< A pointer to the first byte in the font. */ |
ttodorov | 21:e5c1e8ffada1 | 136 | // unsigned char width; /**< The width of each character, in pixels. */ |
ttodorov | 21:e5c1e8ffada1 | 137 | // unsigned char height; /**< Height of each character, in pixels. */ |
ttodorov | 21:e5c1e8ffada1 | 138 | // unsigned char offset; /**< Offset of the first character in the font. */ |
ttodorov | 21:e5c1e8ffada1 | 139 | // unsigned char numchars; /**< Count of the available characters in the font. */ |
ttodorov | 21:e5c1e8ffada1 | 140 | //}; |
ttodorov | 21:e5c1e8ffada1 | 141 | ///** \typedef font_metrics_t |
ttodorov | 21:e5c1e8ffada1 | 142 | // * \brief Convenience shortcut for fonts properties. |
ttodorov | 21:e5c1e8ffada1 | 143 | // */ |
ttodorov | 21:e5c1e8ffada1 | 144 | //typedef struct Font_struct font_metrics_t; |
ttodorov | 0:881ff0b71102 | 145 | |
ttodorov | 12:d0978272a340 | 146 | /** \struct Bitmap_struct |
ttodorov | 12:d0978272a340 | 147 | * \brief Describes an image. |
ttodorov | 12:d0978272a340 | 148 | */ |
ttodorov | 12:d0978272a340 | 149 | struct Bitmap_struct |
ttodorov | 12:d0978272a340 | 150 | { |
ttodorov | 12:d0978272a340 | 151 | colordepth_t Format; /**< Color depth of the image. */ |
ttodorov | 12:d0978272a340 | 152 | unsigned short Width; /**< Width of the image in pixels. */ |
ttodorov | 12:d0978272a340 | 153 | unsigned short Height; /**< Height of the image in pixels. */ |
ttodorov | 12:d0978272a340 | 154 | const void* PixelData; /**< Image pixel data. */ |
ttodorov | 12:d0978272a340 | 155 | }; |
ttodorov | 12:d0978272a340 | 156 | /** \typedef bitmap_t |
ttodorov | 12:d0978272a340 | 157 | * \brief Convenience shortcut bitmap type. |
ttodorov | 12:d0978272a340 | 158 | */ |
ttodorov | 12:d0978272a340 | 159 | typedef struct Bitmap_struct bitmap_t; |
ttodorov | 12:d0978272a340 | 160 | |
ttodorov | 22:4c169297f374 | 161 | /** \struct BacklightPwmCtrl_enum |
ttodorov | 22:4c169297f374 | 162 | * \brief Type of backlight control for the LCD. |
ttodorov | 22:4c169297f374 | 163 | * |
ttodorov | 22:4c169297f374 | 164 | * When the selected type is \c Constant, the pin is simply on or off - there is no gradation in the intensity of the display. |
ttodorov | 22:4c169297f374 | 165 | * In this case any free pin can be used to control the backlight. On the other hand, when PWM is used to control brightness, |
ttodorov | 22:4c169297f374 | 166 | * 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 |
ttodorov | 22:4c169297f374 | 167 | * 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 |
ttodorov | 22:4c169297f374 | 168 | * or \c Indirect option is used. |
ttodorov | 22:4c169297f374 | 169 | * |
ttodorov | 22:4c169297f374 | 170 | * \version 0.1 |
ttodorov | 22:4c169297f374 | 171 | * \remark When choosing PWM to control the backlight, you have the option to choose the pin to either source (\c Direct) or sink |
ttodorov | 22:4c169297f374 | 172 | * (\c Indirect) the current for LCD brightness control. Be aware that the mbed pins can source (and probably sink when |
ttodorov | 22:4c169297f374 | 173 | * configured as inputs) only 4 mA @+3V3 VDD. So if you are intending to use a bigger LCD, whith more LEDs in its backlight |
ttodorov | 22:4c169297f374 | 174 | * implementation, you probably want to interface it through a small signal transistor or a small MOSFET, in order to be able |
ttodorov | 22:4c169297f374 | 175 | * to handle a higher current without damaging your mbed. |
ttodorov | 22:4c169297f374 | 176 | * \remark As of version 0.1 (2013-01-25) the Indirect method of PWM has not been implemented yet. |
ttodorov | 22:4c169297f374 | 177 | */ |
ttodorov | 22:4c169297f374 | 178 | enum BacklightPwmCtrl_enum |
ttodorov | 22:4c169297f374 | 179 | { |
ttodorov | 22:4c169297f374 | 180 | Constant, /**< When the pin is a simple on/off switch. */ |
ttodorov | 22:4c169297f374 | 181 | Direct, /**< Control the brightness with PWM, as the control pin is sourcing the current to drive the backlight LEDs. */ |
ttodorov | 22:4c169297f374 | 182 | Indirect, /**< Control the brightness with PWM, as the control pin is sinking the current which drives the backlight LEDs. */ |
ttodorov | 22:4c169297f374 | 183 | }; |
ttodorov | 22:4c169297f374 | 184 | /** \typedef backlight_t |
ttodorov | 22:4c169297f374 | 185 | * \brief Convenience shortcut for the backlight control type. |
ttodorov | 22:4c169297f374 | 186 | */ |
ttodorov | 22:4c169297f374 | 187 | typedef BacklightPwmCtrl_enum backlight_t; |
ttodorov | 22:4c169297f374 | 188 | |
ttodorov | 11:aeceefc5f9f2 | 189 | |
ttodorov | 0:881ff0b71102 | 190 | /** Base class for LCD implementations. |
ttodorov | 0:881ff0b71102 | 191 | * |
ttodorov | 0:881ff0b71102 | 192 | * All separate LCD controller implementations have to subclass this one. |
ttodorov | 0:881ff0b71102 | 193 | * |
ttodorov | 0:881ff0b71102 | 194 | * \version 0.1 |
ttodorov | 0:881ff0b71102 | 195 | * \author Todor Todorov |
ttodorov | 0:881ff0b71102 | 196 | */ |
ttodorov | 0:881ff0b71102 | 197 | class LCD |
ttodorov | 0:881ff0b71102 | 198 | { |
ttodorov | 0:881ff0b71102 | 199 | public: |
ttodorov | 0:881ff0b71102 | 200 | |
ttodorov | 0:881ff0b71102 | 201 | /** Initialize display. |
ttodorov | 0:881ff0b71102 | 202 | * |
ttodorov | 0:881ff0b71102 | 203 | * Wakes up the display from sleep, initializes power parameters. |
ttodorov | 0:881ff0b71102 | 204 | * This function must be called first, befor any painting on the |
ttodorov | 0:881ff0b71102 | 205 | * display is done, otherwise the positioning of graphical elements |
ttodorov | 0:881ff0b71102 | 206 | * will not work properly and any paynt operation will not be visible |
ttodorov | 0:881ff0b71102 | 207 | * or produce garbage. |
ttodorov | 0:881ff0b71102 | 208 | * |
ttodorov | 0:881ff0b71102 | 209 | * This function is controller-specific and needs to be implemented |
ttodorov | 4:3ac4239f6c9c | 210 | * separately for each available display. |
ttodorov | 0:881ff0b71102 | 211 | * \param oritentation The display orientation, landscape is default. |
ttodorov | 12:d0978272a340 | 212 | * \param colors The correct color depth to use for the pixel data. |
ttodorov | 0:881ff0b71102 | 213 | */ |
ttodorov | 12:d0978272a340 | 214 | virtual void Initialize( orientation_t orientation, colordepth_t colors ) = 0; |
ttodorov | 0:881ff0b71102 | 215 | |
ttodorov | 4:3ac4239f6c9c | 216 | /** Puts the display to sleep. |
ttodorov | 4:3ac4239f6c9c | 217 | * |
ttodorov | 4:3ac4239f6c9c | 218 | * When the display is in sleep mode, its power consumption is |
ttodorov | 4:3ac4239f6c9c | 219 | * minimized. Before new pixel data can be written to the display |
ttodorov | 4:3ac4239f6c9c | 220 | * memory, the controller needs to be brought out of sleep mode. |
ttodorov | 4:3ac4239f6c9c | 221 | * \sa #WakeUp( void ); |
ttodorov | 4:3ac4239f6c9c | 222 | * \remarks The result of this operation might not be exactly as |
ttodorov | 4:3ac4239f6c9c | 223 | * expected. Putting the display to sleep will cause the |
ttodorov | 4:3ac4239f6c9c | 224 | * controller to switch to the standard color of the LCD, |
ttodorov | 4:3ac4239f6c9c | 225 | * so depending on whether the display is normally white, |
ttodorov | 4:3ac4239f6c9c | 226 | * or normally dark, the screen might or might not go |
ttodorov | 4:3ac4239f6c9c | 227 | * dark. Additional power saving can be achieved, if |
ttodorov | 4:3ac4239f6c9c | 228 | * the backlight of the used display is not hardwired on |
ttodorov | 4:3ac4239f6c9c | 229 | * the PCB and can be controlled via the BL pin. |
ttodorov | 4:3ac4239f6c9c | 230 | * \remarks This function is controller-specific and needs to be |
ttodorov | 4:3ac4239f6c9c | 231 | * implemented separately for each available display. |
ttodorov | 4:3ac4239f6c9c | 232 | */ |
ttodorov | 22:4c169297f374 | 233 | virtual void Sleep( void ); |
ttodorov | 4:3ac4239f6c9c | 234 | |
ttodorov | 4:3ac4239f6c9c | 235 | /** Wakes up the display from sleep mode. |
ttodorov | 4:3ac4239f6c9c | 236 | * |
ttodorov | 4:3ac4239f6c9c | 237 | * This function needs to be called before any other, when the |
ttodorov | 4:3ac4239f6c9c | 238 | * display has been put into sleep mode by a previois call to |
ttodorov | 4:3ac4239f6c9c | 239 | * #Sleep( void ). |
ttodorov | 4:3ac4239f6c9c | 240 | * \remarks This function is controller-specific and needs to be |
ttodorov | 4:3ac4239f6c9c | 241 | * implemented separately for each available display. |
ttodorov | 4:3ac4239f6c9c | 242 | */ |
ttodorov | 22:4c169297f374 | 243 | virtual void WakeUp( void ); |
ttodorov | 4:3ac4239f6c9c | 244 | |
ttodorov | 0:881ff0b71102 | 245 | /** Set the foreground color for painting. |
ttodorov | 0:881ff0b71102 | 246 | * |
ttodorov | 0:881ff0b71102 | 247 | * This is the default foreground color to be used in painting operations. |
ttodorov | 0:881ff0b71102 | 248 | * If a specific output function allows for a different color to be specified |
ttodorov | 0:881ff0b71102 | 249 | * in place, the new setting will be used for that single operation only and |
ttodorov | 0:881ff0b71102 | 250 | * will not change this value. |
ttodorov | 0:881ff0b71102 | 251 | * |
ttodorov | 12:d0978272a340 | 252 | * \param color The color to be used (24-bit color depth). |
ttodorov | 0:881ff0b71102 | 253 | * \sa #RGB(r,g,b) |
ttodorov | 0:881ff0b71102 | 254 | */ |
ttodorov | 12:d0978272a340 | 255 | virtual void SetForeground( unsigned int color = COLOR_WHITE ); |
ttodorov | 0:881ff0b71102 | 256 | |
ttodorov | 0:881ff0b71102 | 257 | /** Set the background color for painting. |
ttodorov | 0:881ff0b71102 | 258 | * |
ttodorov | 0:881ff0b71102 | 259 | * This is the default color to be used for "empty" pixels while painting. |
ttodorov | 0:881ff0b71102 | 260 | * If a particular function allows for a different value to be specified |
ttodorov | 0:881ff0b71102 | 261 | * when the function is called, the new value will be used only for this |
ttodorov | 0:881ff0b71102 | 262 | * single call and will not change this setting. |
ttodorov | 0:881ff0b71102 | 263 | * |
ttodorov | 12:d0978272a340 | 264 | * \param color The background color (24-bit color depth). |
ttodorov | 0:881ff0b71102 | 265 | * \sa #RGB(r,g,b) |
ttodorov | 0:881ff0b71102 | 266 | */ |
ttodorov | 12:d0978272a340 | 267 | virtual void SetBackground( unsigned int color = COLOR_BLACK ); |
ttodorov | 0:881ff0b71102 | 268 | |
ttodorov | 0:881ff0b71102 | 269 | /** Sets the font to be used for painting of text on the screen. |
ttodorov | 0:881ff0b71102 | 270 | * \param font A pointer to the font data. |
ttodorov | 0:881ff0b71102 | 271 | * \sa Comments in file fonts.h |
ttodorov | 0:881ff0b71102 | 272 | */ |
ttodorov | 21:e5c1e8ffada1 | 273 | virtual void SetFont( const font_t* font ); |
ttodorov | 0:881ff0b71102 | 274 | |
ttodorov | 0:881ff0b71102 | 275 | /** Gets the display width. |
ttodorov | 0:881ff0b71102 | 276 | * \return Display width in pixels. |
ttodorov | 0:881ff0b71102 | 277 | */ |
ttodorov | 0:881ff0b71102 | 278 | unsigned short GetWidth( void ); |
ttodorov | 0:881ff0b71102 | 279 | |
ttodorov | 0:881ff0b71102 | 280 | /** Gets the display height. |
ttodorov | 0:881ff0b71102 | 281 | * \return Display height in pixels. |
ttodorov | 0:881ff0b71102 | 282 | */ |
ttodorov | 0:881ff0b71102 | 283 | unsigned short GetHeight( void ); |
ttodorov | 0:881ff0b71102 | 284 | |
ttodorov | 21:e5c1e8ffada1 | 285 | /** Gets the font width. |
ttodorov | 21:e5c1e8ffada1 | 286 | * \return The current font width. |
ttodorov | 21:e5c1e8ffada1 | 287 | */ |
ttodorov | 21:e5c1e8ffada1 | 288 | uint8_t GetFontWidth( void ); |
ttodorov | 21:e5c1e8ffada1 | 289 | |
ttodorov | 21:e5c1e8ffada1 | 290 | /** Gets the font height. |
ttodorov | 21:e5c1e8ffada1 | 291 | * \return The current font height. |
ttodorov | 21:e5c1e8ffada1 | 292 | */ |
ttodorov | 21:e5c1e8ffada1 | 293 | uint8_t GetFontHeight( void ); |
ttodorov | 21:e5c1e8ffada1 | 294 | |
ttodorov | 0:881ff0b71102 | 295 | /** Fills the whole screen with a single color. |
ttodorov | 9:58b328831d0a | 296 | * \param color The color to be used. The value must be in RGB-565 format. |
ttodorov | 9:58b328831d0a | 297 | * \remarks The special values -1 and -2 signify the preset background and foreground colors, respectively. |
ttodorov | 9:58b328831d0a | 298 | * The backround color is the default. |
ttodorov | 0:881ff0b71102 | 299 | */ |
ttodorov | 0:881ff0b71102 | 300 | virtual void FillScreen( int color = -1 ); |
ttodorov | 0:881ff0b71102 | 301 | |
ttodorov | 22:4c169297f374 | 302 | /** Sets the backlight intensity in percent as a float value in the range [0.0,1.0]. |
ttodorov | 22:4c169297f374 | 303 | * \param level The backligh intensity in percent, where 0.0 is off and 1.0 is full brightness. |
ttodorov | 22:4c169297f374 | 304 | */ |
ttodorov | 22:4c169297f374 | 305 | virtual void SetBacklightLevel( float level ); |
ttodorov | 22:4c169297f374 | 306 | |
ttodorov | 0:881ff0b71102 | 307 | /** Clears the screen. |
ttodorov | 0:881ff0b71102 | 308 | * |
ttodorov | 0:881ff0b71102 | 309 | * This is the same as calling #FillScreen() or #FillScreen( -1 ) to use the background color. |
ttodorov | 0:881ff0b71102 | 310 | */ |
ttodorov | 0:881ff0b71102 | 311 | virtual void ClearScreen( void ); |
ttodorov | 0:881ff0b71102 | 312 | |
ttodorov | 0:881ff0b71102 | 313 | /** Draws a pixel at the specified location. |
ttodorov | 0:881ff0b71102 | 314 | * |
ttodorov | 0:881ff0b71102 | 315 | * By default the function will use the preset foreground color, but the background |
ttodorov | 0:881ff0b71102 | 316 | * or a custom color could be used as well. |
ttodorov | 0:881ff0b71102 | 317 | * |
ttodorov | 0:881ff0b71102 | 318 | * \param x The horizontal offset of the pixel from the upper left corner of the screen. |
ttodorov | 0:881ff0b71102 | 319 | * \param y The vertical offset of the pixel from the upper left corner of the screen. |
ttodorov | 12:d0978272a340 | 320 | * \param color The color to be used. Use a custom color, or -1 for background and -2 for foreground color. |
ttodorov | 0:881ff0b71102 | 321 | */ |
ttodorov | 0:881ff0b71102 | 322 | virtual void DrawPixel( unsigned short x, unsigned short y, int color = -2 ); |
ttodorov | 0:881ff0b71102 | 323 | |
ttodorov | 0:881ff0b71102 | 324 | /** Draws a line. |
ttodorov | 0:881ff0b71102 | 325 | * |
ttodorov | 0:881ff0b71102 | 326 | * \param x1 Horizontal offset of the beginning point of the line. |
ttodorov | 0:881ff0b71102 | 327 | * \param y1 Vertical offset of the beginning point of the line. |
ttodorov | 0:881ff0b71102 | 328 | * \param x2 Horizontal offset of the end point of the line. |
ttodorov | 0:881ff0b71102 | 329 | * \param y2 Verical offset of the end point of the line. |
ttodorov | 12:d0978272a340 | 330 | * \param color The color to use for painting, or -1 for background, or -2 for foreground. |
ttodorov | 0:881ff0b71102 | 331 | */ |
ttodorov | 0:881ff0b71102 | 332 | virtual void DrawLine( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 ); |
ttodorov | 0:881ff0b71102 | 333 | |
ttodorov | 0:881ff0b71102 | 334 | /** Paints a rectangle. |
ttodorov | 0:881ff0b71102 | 335 | * |
ttodorov | 0:881ff0b71102 | 336 | * \param x1 The horizontal offset of the beginning point of one of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 337 | * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 338 | * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 339 | * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals. |
ttodorov | 12:d0978272a340 | 340 | * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. |
ttodorov | 0:881ff0b71102 | 341 | */ |
ttodorov | 0:881ff0b71102 | 342 | virtual void DrawRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 ); |
ThihaElectronics | 30:5f23a4cbebd7 | 343 | |
ThihaElectronics | 30:5f23a4cbebd7 | 344 | /** Paints a Triangle. |
ThihaElectronics | 30:5f23a4cbebd7 | 345 | * |
ThihaElectronics | 30:5f23a4cbebd7 | 346 | * \param x1 |
ThihaElectronics | 30:5f23a4cbebd7 | 347 | * \param y1 |
ThihaElectronics | 30:5f23a4cbebd7 | 348 | * \param x2 |
ThihaElectronics | 30:5f23a4cbebd7 | 349 | * \param y2 |
ThihaElectronics | 30:5f23a4cbebd7 | 350 | * \param x3 |
ThihaElectronics | 30:5f23a4cbebd7 | 351 | * \param y3 |
ThihaElectronics | 30:5f23a4cbebd7 | 352 | * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. |
ThihaElectronics | 30:5f23a4cbebd7 | 353 | */ |
ThihaElectronics | 30:5f23a4cbebd7 | 354 | virtual void DrawTriangle( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned short x3, unsigned short y3, int color = -2 ); |
ThihaElectronics | 30:5f23a4cbebd7 | 355 | |
ThihaElectronics | 30:5f23a4cbebd7 | 356 | /** Draw a Triangle and fill the color. |
ThihaElectronics | 30:5f23a4cbebd7 | 357 | * |
ThihaElectronics | 30:5f23a4cbebd7 | 358 | * \param x1 |
ThihaElectronics | 30:5f23a4cbebd7 | 359 | * \param y1 |
ThihaElectronics | 30:5f23a4cbebd7 | 360 | * \param x2 |
ThihaElectronics | 30:5f23a4cbebd7 | 361 | * \param y2 |
ThihaElectronics | 30:5f23a4cbebd7 | 362 | * \param x3 |
ThihaElectronics | 30:5f23a4cbebd7 | 363 | * \param y3 |
ThihaElectronics | 30:5f23a4cbebd7 | 364 | * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. |
ThihaElectronics | 30:5f23a4cbebd7 | 365 | */ |
ThihaElectronics | 30:5f23a4cbebd7 | 366 | |
ThihaElectronics | 30:5f23a4cbebd7 | 367 | |
ThihaElectronics | 30:5f23a4cbebd7 | 368 | virtual void FillTriangle( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned short x3, unsigned short y3, int color = -2 ); |
ThihaElectronics | 30:5f23a4cbebd7 | 369 | |
ttodorov | 0:881ff0b71102 | 370 | |
ttodorov | 0:881ff0b71102 | 371 | /** Paints a rectangle and fills it with the paint color. |
ttodorov | 0:881ff0b71102 | 372 | * |
ttodorov | 0:881ff0b71102 | 373 | * \param x1 The horizontal offset of the beginning point of one of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 374 | * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 375 | * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 376 | * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals. |
ttodorov | 12:d0978272a340 | 377 | * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. |
ttodorov | 0:881ff0b71102 | 378 | */ |
ttodorov | 0:881ff0b71102 | 379 | virtual void DrawRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 ); |
ttodorov | 0:881ff0b71102 | 380 | |
ttodorov | 0:881ff0b71102 | 381 | /** Paints a rectangle with rounded corners. |
ttodorov | 0:881ff0b71102 | 382 | * |
ttodorov | 0:881ff0b71102 | 383 | * \param x1 The horizontal offset of the beginning point of one of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 384 | * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 385 | * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 386 | * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals. |
ttodorov | 12:d0978272a340 | 387 | * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. |
ttodorov | 0:881ff0b71102 | 388 | */ |
ttodorov | 0:881ff0b71102 | 389 | virtual void FillRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 ); |
ttodorov | 0:881ff0b71102 | 390 | |
ttodorov | 0:881ff0b71102 | 391 | /** Paints a rectangle with rounded corners and fills it with the paint color. |
ttodorov | 0:881ff0b71102 | 392 | * |
ttodorov | 0:881ff0b71102 | 393 | * \param x1 The horizontal offset of the beginning point of one of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 394 | * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 395 | * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals. |
ttodorov | 0:881ff0b71102 | 396 | * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals. |
ttodorov | 12:d0978272a340 | 397 | * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. |
ttodorov | 0:881ff0b71102 | 398 | */ |
ttodorov | 0:881ff0b71102 | 399 | virtual void FillRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 ); |
ttodorov | 0:881ff0b71102 | 400 | |
ttodorov | 0:881ff0b71102 | 401 | /** Paints a circle. |
ttodorov | 0:881ff0b71102 | 402 | * |
ttodorov | 0:881ff0b71102 | 403 | * \param x The offset of the circle's center from the left edge of the screen. |
ttodorov | 0:881ff0b71102 | 404 | * \param y The offset of the circle's center from the top edge of the screen. |
ttodorov | 0:881ff0b71102 | 405 | * \param radius The circle's radius. |
ttodorov | 12:d0978272a340 | 406 | * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. |
ttodorov | 0:881ff0b71102 | 407 | */ |
ttodorov | 0:881ff0b71102 | 408 | virtual void DrawCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 ); |
ttodorov | 0:881ff0b71102 | 409 | |
ttodorov | 0:881ff0b71102 | 410 | /** Paints a circle and fills it with the paint color. |
ttodorov | 0:881ff0b71102 | 411 | * |
ttodorov | 0:881ff0b71102 | 412 | * \param x The offset of the circle's center from the left edge of the screen. |
ttodorov | 0:881ff0b71102 | 413 | * \param y The offset of the circle's center from the top edge of the screen. |
ttodorov | 0:881ff0b71102 | 414 | * \param radius The circle's radius. |
ttodorov | 12:d0978272a340 | 415 | * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. |
ttodorov | 0:881ff0b71102 | 416 | */ |
ttodorov | 0:881ff0b71102 | 417 | virtual void FillCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 ); |
ttodorov | 0:881ff0b71102 | 418 | |
ttodorov | 0:881ff0b71102 | 419 | /** Print a text on the screen. |
ttodorov | 0:881ff0b71102 | 420 | * |
ttodorov | 0:881ff0b71102 | 421 | * \param str The text. |
ttodorov | 0:881ff0b71102 | 422 | * \param x The horizontal offset form the left edge of the screen. The special values LEFT, CENTER, |
ttodorov | 0:881ff0b71102 | 423 | * or RIGHT can be used instead of pixel offset to indicate the text's horizontal alignment. |
ttodorov | 0:881ff0b71102 | 424 | * \param y The vertical offset of the text from the top of the screen. |
ttodorov | 0:881ff0b71102 | 425 | * \param fgColor The foreground to use for painting the text; -1 indicates background color, -2 the foreground setting, or custom color. |
ttodorov | 0:881ff0b71102 | 426 | * \param bgColor The color to use for painting the empty pixels; -1 indicates the background color, -2 the foreground setting, or custom color. |
ttodorov | 0:881ff0b71102 | 427 | * \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. |
ttodorov | 0:881ff0b71102 | 428 | */ |
ttodorov | 0:881ff0b71102 | 429 | virtual void Print( const char *str, unsigned short x, unsigned short y, int fgColor = -2, int bgColor = -1, unsigned short deg = 0 ); |
ttodorov | 0:881ff0b71102 | 430 | |
ttodorov | 0:881ff0b71102 | 431 | /** Draw an image on the screen. |
ttodorov | 0:881ff0b71102 | 432 | * |
ttodorov | 0:881ff0b71102 | 433 | * The pixels of the picture must be in the RGB-565 format. The data can be provided |
ttodorov | 0:881ff0b71102 | 434 | * as an array in a source or a header file. To convert an image file to the appropriate |
ttodorov | 0:881ff0b71102 | 435 | * format, a special utility must be utilized. One such tool is provided by Henning Karlsen, |
ttodorov | 0:881ff0b71102 | 436 | * the author of the UTFT display liberary and can be downloaded for free from his web site: |
ttodorov | 0:881ff0b71102 | 437 | * http://henningkarlsen.com/electronics/library.php?id=52 |
ttodorov | 0:881ff0b71102 | 438 | * |
ttodorov | 0:881ff0b71102 | 439 | * \param x Horizontal offset of the first pixel of the image. |
ttodorov | 12:d0978272a340 | 440 | * \param y Vertical offset of the first pixel of the image. |
ttodorov | 12:d0978272a340 | 441 | * \param img Image data pointer. |
ttodorov | 0:881ff0b71102 | 442 | * \param scale A value of 1 will produce an image with its original size, while a different value will scale the image. |
ttodorov | 0:881ff0b71102 | 443 | */ |
ttodorov | 12:d0978272a340 | 444 | virtual void DrawBitmap( unsigned short x, unsigned short y, const bitmap_t* img, unsigned char scale = 1 ); |
ttodorov | 0:881ff0b71102 | 445 | |
ttodorov | 0:881ff0b71102 | 446 | /** Draw an image on the screen. |
ttodorov | 0:881ff0b71102 | 447 | * |
ttodorov | 0:881ff0b71102 | 448 | * The pixels of the picture must be in the RGB-565 format. The data can be provided |
ttodorov | 0:881ff0b71102 | 449 | * as an array in a source or a header file. To convert an image file to the appropriate |
ttodorov | 0:881ff0b71102 | 450 | * format, a special utility must be utilized. One such tool is provided by Henning Karlsen, |
ttodorov | 0:881ff0b71102 | 451 | * the author of the UTFT display liberary and can be downloaded for free from his web site: |
ttodorov | 0:881ff0b71102 | 452 | * http://henningkarlsen.com/electronics/library.php?id=52 |
ttodorov | 0:881ff0b71102 | 453 | * |
ttodorov | 0:881ff0b71102 | 454 | * \param x Horizontal offset of the first pixel of the image. |
ttodorov | 12:d0978272a340 | 455 | * \param y Vertical offset of the first pixel of the image. |
ttodorov | 12:d0978272a340 | 456 | * \param img Image data pointer. |
ttodorov | 0:881ff0b71102 | 457 | * \param deg Angle to rotate the image before painting on screen, in degrees. |
ttodorov | 0:881ff0b71102 | 458 | * \param rox |
ttodorov | 0:881ff0b71102 | 459 | * \param roy |
ttodorov | 0:881ff0b71102 | 460 | */ |
ttodorov | 12:d0978272a340 | 461 | virtual void DrawBitmap( unsigned short x, unsigned short y, const bitmap_t* img, unsigned short deg, unsigned short rox, unsigned short roy ); |
ttodorov | 0:881ff0b71102 | 462 | |
ttodorov | 0:881ff0b71102 | 463 | protected: |
ttodorov | 0:881ff0b71102 | 464 | /** Creates an instance of the class. |
ttodorov | 0:881ff0b71102 | 465 | * |
ttodorov | 0:881ff0b71102 | 466 | * \param width Width of the display in pixels. |
ttodorov | 0:881ff0b71102 | 467 | * \param height Height of the display in pixels. |
ttodorov | 0:881ff0b71102 | 468 | * \param CS Pin connected to the CS input of the display. |
ttodorov | 0:881ff0b71102 | 469 | * \param RS Pin connected to the RS input of the display. |
ttodorov | 4:3ac4239f6c9c | 470 | * \param RESET Pin connected to the RESET input of the display. |
ttodorov | 22:4c169297f374 | 471 | * \param BL Pin connected to the circuit controlling the LCD's backlight. |
ttodorov | 22:4c169297f374 | 472 | * \param blType The type of backlight to be used. |
ttodorov | 22:4c169297f374 | 473 | * \param defaultBacklight The standard backlight intensity (if using PWM control), expressed in percent as float value from 0.0 to 1.0 |
ttodorov | 0:881ff0b71102 | 474 | */ |
ttodorov | 22:4c169297f374 | 475 | LCD( unsigned short width, unsigned short height ,PinName CS, PinName RS, PinName RESET, PinName BL, backlight_t blType, float defaultBacklight ); |
ttodorov | 4:3ac4239f6c9c | 476 | |
ttodorov | 4:3ac4239f6c9c | 477 | /** Activates the display for command/data transfer. |
ttodorov | 4:3ac4239f6c9c | 478 | * |
ttodorov | 4:3ac4239f6c9c | 479 | * Usually achieved by pulling the CS pin of the display low. |
ttodorov | 4:3ac4239f6c9c | 480 | */ |
ttodorov | 4:3ac4239f6c9c | 481 | virtual void Activate( void ); |
ttodorov | 4:3ac4239f6c9c | 482 | |
ttodorov | 4:3ac4239f6c9c | 483 | /** Deactivates the display after data has been transmitted. |
ttodorov | 4:3ac4239f6c9c | 484 | * |
ttodorov | 4:3ac4239f6c9c | 485 | * Usually achieved by pulling the CS pin of the display high. |
ttodorov | 4:3ac4239f6c9c | 486 | */ |
ttodorov | 4:3ac4239f6c9c | 487 | virtual void Deactivate( void ); |
ttodorov | 0:881ff0b71102 | 488 | |
ttodorov | 0:881ff0b71102 | 489 | /** Sends a command to the display. |
ttodorov | 0:881ff0b71102 | 490 | * |
ttodorov | 0:881ff0b71102 | 491 | * \param cmd The display command. |
ttodorov | 0:881ff0b71102 | 492 | * \remarks Commands are controller-specific and this function needs to |
ttodorov | 0:881ff0b71102 | 493 | * be implemented separately for each available controller. |
ttodorov | 0:881ff0b71102 | 494 | */ |
ttodorov | 2:81ed304b7e9b | 495 | virtual void WriteCmd( unsigned short cmd ) = 0; |
ttodorov | 0:881ff0b71102 | 496 | |
ttodorov | 0:881ff0b71102 | 497 | /** Sends pixel data to the display. |
ttodorov | 0:881ff0b71102 | 498 | * |
ttodorov | 0:881ff0b71102 | 499 | * \param data The display data. |
ttodorov | 0:881ff0b71102 | 500 | * \remarks Sendin data is controller-specific and this function needs to |
ttodorov | 0:881ff0b71102 | 501 | * be implemented separately for each available controller. |
ttodorov | 0:881ff0b71102 | 502 | */ |
ttodorov | 2:81ed304b7e9b | 503 | virtual void WriteData( unsigned short data ) = 0; |
ttodorov | 0:881ff0b71102 | 504 | |
ttodorov | 0:881ff0b71102 | 505 | /** Sends both command and data to the display controller. |
ttodorov | 0:881ff0b71102 | 506 | * |
ttodorov | 0:881ff0b71102 | 507 | * This is a helper utility function which combines the 2 functions above |
ttodorov | 0:881ff0b71102 | 508 | * into one single convenience step. |
ttodorov | 0:881ff0b71102 | 509 | * |
ttodorov | 0:881ff0b71102 | 510 | * \param cmd The display command. |
ttodorov | 0:881ff0b71102 | 511 | * \param data The display pixel data. |
ttodorov | 0:881ff0b71102 | 512 | */ |
ttodorov | 2:81ed304b7e9b | 513 | virtual void WriteCmdData( unsigned short cmd, unsigned short data ); |
ttodorov | 0:881ff0b71102 | 514 | |
ttodorov | 0:881ff0b71102 | 515 | /** Assigns a chunk of the display memory to receive data. |
ttodorov | 0:881ff0b71102 | 516 | * |
ttodorov | 0:881ff0b71102 | 517 | * When data is sent to the display after this function completes, the opertion will |
ttodorov | 0:881ff0b71102 | 518 | * start from the begining of the assigned address (pixel position) and the pointer |
ttodorov | 0:881ff0b71102 | 519 | * will be automatically incremented so that the next data write operation will continue |
ttodorov | 0:881ff0b71102 | 520 | * with the next pixel from the memory block. If more data is written than available |
ttodorov | 0:881ff0b71102 | 521 | * pixels, at the end of the block the pointer will jump back to its beginning and |
ttodorov | 0:881ff0b71102 | 522 | * commence again, until the next address change command is sent to the display. |
ttodorov | 0:881ff0b71102 | 523 | * |
ttodorov | 0:881ff0b71102 | 524 | * \param x1 The X coordinate of the pixel at the beginning of the block. |
ttodorov | 0:881ff0b71102 | 525 | * \param y1 The Y coordinate of the pixel at the beginning of the block. |
ttodorov | 0:881ff0b71102 | 526 | * \param x2 The X coordinate of the pixel at the end of the block. |
ttodorov | 0:881ff0b71102 | 527 | * \param y2 The Y coordinate of the pixel at the end of the block. |
ttodorov | 0:881ff0b71102 | 528 | * \remarks Addressing commands are controller-specific and this function needs to be |
ttodorov | 0:881ff0b71102 | 529 | * implemented separately for each available controller. |
ttodorov | 0:881ff0b71102 | 530 | */ |
ttodorov | 20:4bdca8d8dadc | 531 | virtual void SetXY( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2 ) = 0; |
ttodorov | 0:881ff0b71102 | 532 | |
ttodorov | 0:881ff0b71102 | 533 | /** Resets the memory address for the next display write operation to the screen origins (0,0). |
ttodorov | 0:881ff0b71102 | 534 | */ |
ttodorov | 2:81ed304b7e9b | 535 | virtual void ClearXY( void ); |
ttodorov | 2:81ed304b7e9b | 536 | |
ttodorov | 10:69571adcfad5 | 537 | /** Sets the color of the pixel at the address pointer of the controller. |
ttodorov | 10:69571adcfad5 | 538 | * |
ttodorov | 10:69571adcfad5 | 539 | * This function is to be provided by each implementation separately in |
ttodorov | 12:d0978272a340 | 540 | * order to account for different color depths used by the controller. |
ttodorov | 10:69571adcfad5 | 541 | * \param color The color of the pixel. |
ttodorov | 20:4bdca8d8dadc | 542 | * \param mode The depth (palette) of the color. |
ttodorov | 10:69571adcfad5 | 543 | */ |
ttodorov | 20:4bdca8d8dadc | 544 | virtual void SetPixelColor( unsigned int color, colordepth_t mode = RGB24 ) = 0; |
ttodorov | 10:69571adcfad5 | 545 | |
ttodorov | 2:81ed304b7e9b | 546 | /** Draws a horizontal line. |
ttodorov | 2:81ed304b7e9b | 547 | * |
ttodorov | 2:81ed304b7e9b | 548 | * This is a utility function to draw horizontal-only lines |
ttodorov | 2:81ed304b7e9b | 549 | * for reduced code complexity and faster execution. |
ttodorov | 2:81ed304b7e9b | 550 | * |
ttodorov | 2:81ed304b7e9b | 551 | * \param x X coordinate of the starting point of the line. |
ttodorov | 2:81ed304b7e9b | 552 | * \param y Y coordinate of the starting point of the line. |
ttodorov | 2:81ed304b7e9b | 553 | * \param len Length of the line. |
ttodorov | 2:81ed304b7e9b | 554 | * \param color The color to use to draw the line. By default the global foreground color is used ( -2 ), |
ttodorov | 12:d0978272a340 | 555 | * -1 switches to the default background color, or any custom color can be used. |
ttodorov | 2:81ed304b7e9b | 556 | */ |
ttodorov | 2:81ed304b7e9b | 557 | virtual void DrawHLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 ); |
ttodorov | 0:881ff0b71102 | 558 | |
ttodorov | 2:81ed304b7e9b | 559 | /** Draws a vertical line. |
ttodorov | 2:81ed304b7e9b | 560 | * |
ttodorov | 2:81ed304b7e9b | 561 | * This is a utility function to draw vertical-only lines |
ttodorov | 2:81ed304b7e9b | 562 | * for reduced code complexity and faster execution. |
ttodorov | 2:81ed304b7e9b | 563 | * |
ttodorov | 2:81ed304b7e9b | 564 | * \param x X coordinate of the starting point of the line. |
ttodorov | 2:81ed304b7e9b | 565 | * \param y Y coordinate of the starting point of the line. |
ttodorov | 2:81ed304b7e9b | 566 | * \param len Height of the line. |
ttodorov | 2:81ed304b7e9b | 567 | * \param color The color to use to draw the line. By default the global foreground color is used ( -2 ), |
ttodorov | 12:d0978272a340 | 568 | * -1 switches to the default background color, or any custom color can be used. |
ttodorov | 2:81ed304b7e9b | 569 | */ |
ttodorov | 2:81ed304b7e9b | 570 | virtual void DrawVLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 ); |
ttodorov | 2:81ed304b7e9b | 571 | |
ttodorov | 2:81ed304b7e9b | 572 | /** Prints a character at the given position and using the given color. |
ttodorov | 2:81ed304b7e9b | 573 | * |
ttodorov | 2:81ed304b7e9b | 574 | * \param c The character. |
ttodorov | 2:81ed304b7e9b | 575 | * \param x X coordinate of the character position. |
ttodorov | 2:81ed304b7e9b | 576 | * \param y Y coordinate of the character position. |
ttodorov | 2:81ed304b7e9b | 577 | * \param fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ), |
ttodorov | 12:d0978272a340 | 578 | * -1 switches to the default background color, or any custom color can be used. |
ttodorov | 2:81ed304b7e9b | 579 | * \param bgColor Background color for drawing. By default the global background color is used ( -1 ), |
ttodorov | 12:d0978272a340 | 580 | * -2 switches to the default foreground color, or any custom color can be used. |
ttodorov | 2:81ed304b7e9b | 581 | */ |
ttodorov | 2:81ed304b7e9b | 582 | virtual void PrintChar( char c, unsigned short x, unsigned short y, int fgColor = -2, int bgColor = -1 ); |
ttodorov | 2:81ed304b7e9b | 583 | |
ttodorov | 2:81ed304b7e9b | 584 | /** Prints a character at the given position and using the given color and with the given rotation. |
ttodorov | 2:81ed304b7e9b | 585 | * |
ttodorov | 2:81ed304b7e9b | 586 | * \param c The character. |
ttodorov | 2:81ed304b7e9b | 587 | * \param x X coordinate of the character position. |
ttodorov | 2:81ed304b7e9b | 588 | * \param y Y coordinate of the character position. |
ttodorov | 2:81ed304b7e9b | 589 | * \param pos Position of the character in the string from which it originates (used to rotate a whole string). |
ttodorov | 2:81ed304b7e9b | 590 | * \param fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ), |
ttodorov | 12:d0978272a340 | 591 | * -1 switches to the default background color, or any custom color can be used. |
ttodorov | 2:81ed304b7e9b | 592 | * \param bgColor Background color for drawing. By default the global background color is used ( -1 ), |
ttodorov | 12:d0978272a340 | 593 | * -2 switches to the default foreground color, or any custom color can be used. |
ttodorov | 2:81ed304b7e9b | 594 | * \param deg The angle at which to rotate. |
ttodorov | 2:81ed304b7e9b | 595 | */ |
ttodorov | 2:81ed304b7e9b | 596 | virtual void RotateChar( char c, unsigned short x, unsigned short y, int pos, int fgColor = -2, int bgColor = -1, unsigned short deg = 0 ); |
ttodorov | 0:881ff0b71102 | 597 | |
ttodorov | 0:881ff0b71102 | 598 | protected: |
ttodorov | 4:3ac4239f6c9c | 599 | unsigned short _disp_width, _disp_height; |
ttodorov | 4:3ac4239f6c9c | 600 | DigitalOut _lcd_pin_cs, _lcd_pin_rs, _lcd_pin_reset; |
ttodorov | 4:3ac4239f6c9c | 601 | orientation_t _orientation; |
ttodorov | 12:d0978272a340 | 602 | colordepth_t _colorDepth; |
ttodorov | 12:d0978272a340 | 603 | unsigned int _foreground, _background; |
ttodorov | 21:e5c1e8ffada1 | 604 | const font_t* _font; |
ttodorov | 22:4c169297f374 | 605 | DigitalOut* _lcd_pin_bl; |
ttodorov | 22:4c169297f374 | 606 | PwmOut* _bl_pwm; |
ttodorov | 22:4c169297f374 | 607 | backlight_t _bl_type; |
ttodorov | 22:4c169297f374 | 608 | float _bl_pwm_default, _bl_pwm_current; |
ttodorov | 0:881ff0b71102 | 609 | }; |
ttodorov | 0:881ff0b71102 | 610 | |
ttodorov | 6:059ca1648211 | 611 | #ifdef __cplusplus |
ttodorov | 6:059ca1648211 | 612 | } |
ttodorov | 6:059ca1648211 | 613 | #endif |
ttodorov | 6:059ca1648211 | 614 | |
ttodorov | 3:64a5b67d5b51 | 615 | #endif /* TFTLCD_BASE_H */ |