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