This is the David Smart RA8875 Library with mods for working with FRDM-K64F
GraphicsDisplay.h@114:dbfb996bfbf3, 2016-05-15 (annotated)
- Committer:
- WiredHome
- Date:
- Sun May 15 18:57:06 2016 +0000
- Revision:
- 114:dbfb996bfbf3
- Parent:
- 112:325ca91bc03d
- Child:
- 115:c9862fd0c689
Minor doc changes, and enable the GraphicsDisplay::window( ) to have no parameters to reset the screen size to full.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dreschpe | 0:de9d1462a835 | 1 | /* mbed GraphicsDisplay Display Library Base Class |
dreschpe | 0:de9d1462a835 | 2 | * Copyright (c) 2007-2009 sford |
dreschpe | 0:de9d1462a835 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
dreschpe | 0:de9d1462a835 | 4 | * |
dreschpe | 0:de9d1462a835 | 5 | * A library for providing a common base class for Graphics displays |
dreschpe | 0:de9d1462a835 | 6 | * To port a new display, derive from this class and implement |
dreschpe | 0:de9d1462a835 | 7 | * the constructor (setup the display), pixel (put a pixel |
dreschpe | 0:de9d1462a835 | 8 | * at a location), width and height functions. Everything else |
dreschpe | 0:de9d1462a835 | 9 | * (locate, printf, putc, cls, window, putp, fill, blit, blitbit) |
dreschpe | 0:de9d1462a835 | 10 | * will come for free. You can also provide a specialised implementation |
dreschpe | 0:de9d1462a835 | 11 | * of window and putp to speed up the results |
dreschpe | 0:de9d1462a835 | 12 | */ |
dreschpe | 0:de9d1462a835 | 13 | |
dreschpe | 0:de9d1462a835 | 14 | #ifndef MBED_GRAPHICSDISPLAY_H |
dreschpe | 0:de9d1462a835 | 15 | #define MBED_GRAPHICSDISPLAY_H |
WiredHome | 32:0e4f2ae512e2 | 16 | #include "Bitmap.h" |
dreschpe | 0:de9d1462a835 | 17 | #include "TextDisplay.h" |
dreschpe | 0:de9d1462a835 | 18 | |
WiredHome | 32:0e4f2ae512e2 | 19 | /// The GraphicsDisplay class |
WiredHome | 32:0e4f2ae512e2 | 20 | /// |
WiredHome | 32:0e4f2ae512e2 | 21 | /// This graphics display class supports both graphics and text operations. |
WiredHome | 32:0e4f2ae512e2 | 22 | /// Typically, a subclass is derived from this which has localizations to |
WiredHome | 32:0e4f2ae512e2 | 23 | /// adapt to a specific hardware platform (e.g. a display controller chip), |
WiredHome | 32:0e4f2ae512e2 | 24 | /// that overrides methods in here to either add more capability or perhaps |
WiredHome | 32:0e4f2ae512e2 | 25 | /// to improve performance, by leveraging specific hardware capabilities. |
WiredHome | 32:0e4f2ae512e2 | 26 | /// |
WiredHome | 32:0e4f2ae512e2 | 27 | class GraphicsDisplay : public TextDisplay |
WiredHome | 32:0e4f2ae512e2 | 28 | { |
WiredHome | 32:0e4f2ae512e2 | 29 | public: |
WiredHome | 32:0e4f2ae512e2 | 30 | /// The constructor |
dreschpe | 0:de9d1462a835 | 31 | GraphicsDisplay(const char* name); |
WiredHome | 32:0e4f2ae512e2 | 32 | |
WiredHome | 104:8d1d3832a215 | 33 | //~GraphicsDisplay(); |
WiredHome | 104:8d1d3832a215 | 34 | |
WiredHome | 32:0e4f2ae512e2 | 35 | /// Draw a pixel in the specified color. |
WiredHome | 32:0e4f2ae512e2 | 36 | /// |
WiredHome | 32:0e4f2ae512e2 | 37 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 38 | /// |
WiredHome | 76:c981284eb513 | 39 | /// @param[in] x is the horizontal offset to this pixel. |
WiredHome | 76:c981284eb513 | 40 | /// @param[in] y is the vertical offset to this pixel. |
WiredHome | 76:c981284eb513 | 41 | /// @param[in] color defines the color for the pixel. |
WiredHome | 32:0e4f2ae512e2 | 42 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 43 | /// |
WiredHome | 37:f19b7e7449dc | 44 | virtual RetCode_t pixel(loc_t x, loc_t y, color_t color) = 0; |
WiredHome | 32:0e4f2ae512e2 | 45 | |
WiredHome | 41:2956a0a221e5 | 46 | /// Write a stream of pixels to the display. |
WiredHome | 41:2956a0a221e5 | 47 | /// |
WiredHome | 41:2956a0a221e5 | 48 | /// @note this method must be supported in the derived class. |
WiredHome | 41:2956a0a221e5 | 49 | /// |
WiredHome | 76:c981284eb513 | 50 | /// @param[in] p is a pointer to a color_t array to write. |
WiredHome | 76:c981284eb513 | 51 | /// @param[in] count is the number of pixels to write. |
WiredHome | 76:c981284eb513 | 52 | /// @param[in] x is the horizontal position on the display. |
WiredHome | 76:c981284eb513 | 53 | /// @param[in] y is the vertical position on the display. |
WiredHome | 41:2956a0a221e5 | 54 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 41:2956a0a221e5 | 55 | /// |
WiredHome | 41:2956a0a221e5 | 56 | virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) = 0; |
WiredHome | 41:2956a0a221e5 | 57 | |
WiredHome | 41:2956a0a221e5 | 58 | /// Get a pixel from the display. |
WiredHome | 41:2956a0a221e5 | 59 | /// |
WiredHome | 41:2956a0a221e5 | 60 | /// @note this method must be supported in the derived class. |
WiredHome | 41:2956a0a221e5 | 61 | /// |
WiredHome | 76:c981284eb513 | 62 | /// @param[in] x is the horizontal offset to this pixel. |
WiredHome | 76:c981284eb513 | 63 | /// @param[in] y is the vertical offset to this pixel. |
WiredHome | 41:2956a0a221e5 | 64 | /// @returns the pixel. see @color_t |
WiredHome | 41:2956a0a221e5 | 65 | /// |
WiredHome | 41:2956a0a221e5 | 66 | virtual color_t getPixel(loc_t x, loc_t y) = 0; |
WiredHome | 41:2956a0a221e5 | 67 | |
WiredHome | 41:2956a0a221e5 | 68 | /// Get a stream of pixels from the display. |
WiredHome | 41:2956a0a221e5 | 69 | /// |
WiredHome | 41:2956a0a221e5 | 70 | /// @note this method must be supported in the derived class. |
WiredHome | 41:2956a0a221e5 | 71 | /// |
WiredHome | 76:c981284eb513 | 72 | /// @param[out] p is a pointer to a color_t array to accept the stream. |
WiredHome | 76:c981284eb513 | 73 | /// @param[in] count is the number of pixels to read. |
WiredHome | 76:c981284eb513 | 74 | /// @param[in] x is the horizontal offset to this pixel. |
WiredHome | 76:c981284eb513 | 75 | /// @param[in] y is the vertical offset to this pixel. |
WiredHome | 41:2956a0a221e5 | 76 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 41:2956a0a221e5 | 77 | /// |
WiredHome | 41:2956a0a221e5 | 78 | virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) = 0; |
WiredHome | 41:2956a0a221e5 | 79 | |
WiredHome | 32:0e4f2ae512e2 | 80 | /// get the screen width in pixels |
WiredHome | 32:0e4f2ae512e2 | 81 | /// |
WiredHome | 32:0e4f2ae512e2 | 82 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 83 | /// |
WiredHome | 32:0e4f2ae512e2 | 84 | /// @returns screen width in pixels. |
WiredHome | 32:0e4f2ae512e2 | 85 | /// |
WiredHome | 32:0e4f2ae512e2 | 86 | virtual uint16_t width() = 0; |
WiredHome | 32:0e4f2ae512e2 | 87 | |
WiredHome | 32:0e4f2ae512e2 | 88 | /// get the screen height in pixels |
WiredHome | 32:0e4f2ae512e2 | 89 | /// |
WiredHome | 32:0e4f2ae512e2 | 90 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 91 | /// |
WiredHome | 32:0e4f2ae512e2 | 92 | /// @returns screen height in pixels. |
WiredHome | 32:0e4f2ae512e2 | 93 | /// |
WiredHome | 32:0e4f2ae512e2 | 94 | virtual uint16_t height() = 0; |
WiredHome | 32:0e4f2ae512e2 | 95 | |
WiredHome | 32:0e4f2ae512e2 | 96 | /// Prepare the controller to write binary data to the screen by positioning |
WiredHome | 32:0e4f2ae512e2 | 97 | /// the memory cursor. |
WiredHome | 32:0e4f2ae512e2 | 98 | /// |
WiredHome | 32:0e4f2ae512e2 | 99 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 100 | /// |
WiredHome | 76:c981284eb513 | 101 | /// @param[in] x is the horizontal position in pixels (from the left edge) |
WiredHome | 76:c981284eb513 | 102 | /// @param[in] y is the vertical position in pixels (from the top edge) |
WiredHome | 32:0e4f2ae512e2 | 103 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 104 | /// |
WiredHome | 37:f19b7e7449dc | 105 | virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y) = 0; |
WiredHome | 32:0e4f2ae512e2 | 106 | |
WiredHome | 41:2956a0a221e5 | 107 | /// Prepare the controller to read binary data from the screen by positioning |
WiredHome | 41:2956a0a221e5 | 108 | /// the memory read cursor. |
WiredHome | 41:2956a0a221e5 | 109 | /// |
WiredHome | 76:c981284eb513 | 110 | /// @param[in] x is the horizontal position in pixels (from the left edge) |
WiredHome | 76:c981284eb513 | 111 | /// @param[in] y is the vertical position in pixels (from the top edge) |
WiredHome | 41:2956a0a221e5 | 112 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 41:2956a0a221e5 | 113 | /// |
WiredHome | 41:2956a0a221e5 | 114 | virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y) = 0; |
WiredHome | 41:2956a0a221e5 | 115 | |
WiredHome | 32:0e4f2ae512e2 | 116 | /// Draw a filled rectangle in the specified color |
WiredHome | 32:0e4f2ae512e2 | 117 | /// |
WiredHome | 32:0e4f2ae512e2 | 118 | /// @note As a side effect, this changes the current |
WiredHome | 32:0e4f2ae512e2 | 119 | /// foreground color for subsequent operations. |
WiredHome | 32:0e4f2ae512e2 | 120 | /// |
WiredHome | 32:0e4f2ae512e2 | 121 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 122 | /// |
WiredHome | 76:c981284eb513 | 123 | /// @param[in] x1 is the horizontal start of the line. |
WiredHome | 76:c981284eb513 | 124 | /// @param[in] y1 is the vertical start of the line. |
WiredHome | 76:c981284eb513 | 125 | /// @param[in] x2 is the horizontal end of the line. |
WiredHome | 76:c981284eb513 | 126 | /// @param[in] y2 is the vertical end of the line. |
WiredHome | 76:c981284eb513 | 127 | /// @param[in] color defines the foreground color. |
WiredHome | 76:c981284eb513 | 128 | /// @param[in] fillit is optional to NOFILL the rectangle. default is FILL. |
WiredHome | 32:0e4f2ae512e2 | 129 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 130 | /// |
WiredHome | 37:f19b7e7449dc | 131 | virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 32:0e4f2ae512e2 | 132 | color_t color, fill_t fillit = FILL) = 0; |
WiredHome | 32:0e4f2ae512e2 | 133 | |
WiredHome | 32:0e4f2ae512e2 | 134 | |
WiredHome | 32:0e4f2ae512e2 | 135 | virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF) = 0; |
WiredHome | 32:0e4f2ae512e2 | 136 | virtual RetCode_t WriteData(unsigned char data) = 0; |
WiredHome | 32:0e4f2ae512e2 | 137 | |
WiredHome | 32:0e4f2ae512e2 | 138 | /// Set the window, which controls where items are written to the screen. |
WiredHome | 32:0e4f2ae512e2 | 139 | /// |
WiredHome | 32:0e4f2ae512e2 | 140 | /// When something hits the window width, it wraps back to the left side |
WiredHome | 32:0e4f2ae512e2 | 141 | /// and down a row. If the initial write is outside the window, it will |
WiredHome | 32:0e4f2ae512e2 | 142 | /// be captured into the window when it crosses a boundary. |
WiredHome | 32:0e4f2ae512e2 | 143 | /// |
WiredHome | 111:efe436c43aba | 144 | /// @param[in] r is the rect_t rect to define the window. |
WiredHome | 111:efe436c43aba | 145 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 111:efe436c43aba | 146 | /// |
WiredHome | 111:efe436c43aba | 147 | virtual RetCode_t window(rect_t r); |
WiredHome | 111:efe436c43aba | 148 | |
WiredHome | 111:efe436c43aba | 149 | /// Set the window, which controls where items are written to the screen. |
WiredHome | 111:efe436c43aba | 150 | /// |
WiredHome | 111:efe436c43aba | 151 | /// When something hits the window width, it wraps back to the left side |
WiredHome | 111:efe436c43aba | 152 | /// and down a row. If the initial write is outside the window, it will |
WiredHome | 111:efe436c43aba | 153 | /// be captured into the window when it crosses a boundary. |
WiredHome | 111:efe436c43aba | 154 | /// |
WiredHome | 114:dbfb996bfbf3 | 155 | /// @note if no parameters are provided, it restores the window to full screen. |
WiredHome | 114:dbfb996bfbf3 | 156 | /// |
WiredHome | 76:c981284eb513 | 157 | /// @param[in] x is the left edge in pixels. |
WiredHome | 76:c981284eb513 | 158 | /// @param[in] y is the top edge in pixels. |
WiredHome | 76:c981284eb513 | 159 | /// @param[in] w is the window width in pixels. |
WiredHome | 76:c981284eb513 | 160 | /// @param[in] h is the window height in pixels. |
WiredHome | 32:0e4f2ae512e2 | 161 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 162 | /// |
WiredHome | 114:dbfb996bfbf3 | 163 | virtual RetCode_t window(loc_t x = 0, loc_t y = 0, dim_t w = (dim_t)-1, dim_t h = (dim_t)-1); |
WiredHome | 32:0e4f2ae512e2 | 164 | |
WiredHome | 111:efe436c43aba | 165 | /// method to set the window region to the full screen. |
WiredHome | 111:efe436c43aba | 166 | /// |
WiredHome | 111:efe436c43aba | 167 | /// This restores the 'window' to the full screen, so that |
WiredHome | 111:efe436c43aba | 168 | /// other operations (@see cls) would clear the whole screen. |
WiredHome | 111:efe436c43aba | 169 | /// |
WiredHome | 111:efe436c43aba | 170 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 111:efe436c43aba | 171 | /// |
WiredHome | 111:efe436c43aba | 172 | virtual RetCode_t WindowMax(void); |
WiredHome | 111:efe436c43aba | 173 | |
WiredHome | 32:0e4f2ae512e2 | 174 | /// Clear the screen. |
WiredHome | 32:0e4f2ae512e2 | 175 | /// |
WiredHome | 32:0e4f2ae512e2 | 176 | /// The behavior is to clear the whole screen. |
WiredHome | 32:0e4f2ae512e2 | 177 | /// |
WiredHome | 76:c981284eb513 | 178 | /// @param[in] layers is ignored, but supports maintaining the same |
WiredHome | 61:8f3153bf0baa | 179 | /// API for the graphics layer. |
WiredHome | 32:0e4f2ae512e2 | 180 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 181 | /// |
WiredHome | 61:8f3153bf0baa | 182 | virtual RetCode_t cls(uint16_t layers = 0); |
WiredHome | 32:0e4f2ae512e2 | 183 | |
WiredHome | 32:0e4f2ae512e2 | 184 | /// method to put a single color pixel to the screen. |
WiredHome | 32:0e4f2ae512e2 | 185 | /// |
WiredHome | 32:0e4f2ae512e2 | 186 | /// This method may be called as many times as necessary after |
WiredHome | 32:0e4f2ae512e2 | 187 | /// @see _StartGraphicsStream() is called, and it should be followed |
WiredHome | 32:0e4f2ae512e2 | 188 | /// by _EndGraphicsStream. |
WiredHome | 32:0e4f2ae512e2 | 189 | /// |
WiredHome | 76:c981284eb513 | 190 | /// @param[in] pixel is a color value to be put on the screen. |
WiredHome | 79:544eb4964795 | 191 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 192 | /// |
WiredHome | 55:dfbabef7003e | 193 | virtual RetCode_t _putp(color_t pixel); |
WiredHome | 32:0e4f2ae512e2 | 194 | |
WiredHome | 79:544eb4964795 | 195 | /// method to fill a region. |
WiredHome | 79:544eb4964795 | 196 | /// |
WiredHome | 79:544eb4964795 | 197 | /// This method fills a region with the specified color. |
WiredHome | 79:544eb4964795 | 198 | /// |
WiredHome | 79:544eb4964795 | 199 | /// @param[in] x is the left-edge of the region. |
WiredHome | 79:544eb4964795 | 200 | /// @param[in] y is the top-edge of the region. |
WiredHome | 79:544eb4964795 | 201 | /// @param[in] w specifies the width of the region. |
WiredHome | 79:544eb4964795 | 202 | /// @param[in] h specifies the height of the region. |
WiredHome | 79:544eb4964795 | 203 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 79:544eb4964795 | 204 | /// |
WiredHome | 109:7b94f06f085b | 205 | virtual RetCode_t fill(loc_t x, loc_t y, dim_t w, dim_t h, color_t color); |
WiredHome | 76:c981284eb513 | 206 | |
WiredHome | 79:544eb4964795 | 207 | |
WiredHome | 109:7b94f06f085b | 208 | virtual RetCode_t blit(loc_t x, loc_t y, dim_t w, dim_t h, const int * color); |
WiredHome | 29:422616aa04bd | 209 | |
WiredHome | 101:e0aad446094a | 210 | /// This method returns the width in pixels of the chosen character |
WiredHome | 101:e0aad446094a | 211 | /// from the previously selected external font. |
WiredHome | 101:e0aad446094a | 212 | /// |
WiredHome | 101:e0aad446094a | 213 | /// @param[in] c is the character of interest. |
WiredHome | 106:c80828f5dea4 | 214 | /// @param[in, out] width is a pointer to where the width will be stored. |
WiredHome | 101:e0aad446094a | 215 | /// This parameter is NULL tested and will only be written if not null |
WiredHome | 101:e0aad446094a | 216 | /// which is convenient if you only want the height. |
WiredHome | 106:c80828f5dea4 | 217 | /// @param[in, out] height is a pointer to where the height will be stored. |
WiredHome | 101:e0aad446094a | 218 | /// This parameter is NULL tested and will only be written if not null |
WiredHome | 101:e0aad446094a | 219 | /// which is convenient if you only want the width. |
WiredHome | 101:e0aad446094a | 220 | /// @returns a pointer to the raw character data or NULL if not found. |
WiredHome | 101:e0aad446094a | 221 | /// |
WiredHome | 109:7b94f06f085b | 222 | virtual const uint8_t * getCharMetrics(const unsigned char c, dim_t * width, dim_t * height); |
WiredHome | 101:e0aad446094a | 223 | |
WiredHome | 29:422616aa04bd | 224 | /// This method transfers one character from the external font data |
WiredHome | 29:422616aa04bd | 225 | /// to the screen. |
WiredHome | 29:422616aa04bd | 226 | /// |
WiredHome | 101:e0aad446094a | 227 | /// The font being used has already been set with the SelectUserFont |
WiredHome | 101:e0aad446094a | 228 | /// API. |
WiredHome | 101:e0aad446094a | 229 | /// |
WiredHome | 29:422616aa04bd | 230 | /// @note the font data is in a special format as generate by |
WiredHome | 95:ef538bd687c0 | 231 | /// the mikroe font creator. |
WiredHome | 29:422616aa04bd | 232 | /// See http://www.mikroe.com/glcd-font-creator/ |
WiredHome | 29:422616aa04bd | 233 | /// |
WiredHome | 76:c981284eb513 | 234 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 235 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 98:ecebed9b80b2 | 236 | /// @param[in] c is the character to render |
WiredHome | 98:ecebed9b80b2 | 237 | /// @returns how far the cursor should advance to the right in pixels. |
WiredHome | 98:ecebed9b80b2 | 238 | /// @returns zero if the character could not be rendered. |
WiredHome | 29:422616aa04bd | 239 | /// |
WiredHome | 109:7b94f06f085b | 240 | virtual int fontblit(loc_t x, loc_t y, const unsigned char c); |
WiredHome | 29:422616aa04bd | 241 | |
WiredHome | 32:0e4f2ae512e2 | 242 | /// This method returns the color value from a palette. |
WiredHome | 32:0e4f2ae512e2 | 243 | /// |
WiredHome | 32:0e4f2ae512e2 | 244 | /// This method accepts a pointer to a Bitmap color palette, which |
WiredHome | 32:0e4f2ae512e2 | 245 | /// is a table in memory composed of RGB Quad values (r, g, b, 0), |
WiredHome | 32:0e4f2ae512e2 | 246 | /// and an index into that table. It then extracts the color information |
WiredHome | 32:0e4f2ae512e2 | 247 | /// and downsamples it to a color_t value which it returns. |
WiredHome | 32:0e4f2ae512e2 | 248 | /// |
WiredHome | 32:0e4f2ae512e2 | 249 | /// @note This method probably has very little value outside of |
WiredHome | 32:0e4f2ae512e2 | 250 | /// the internal methods for reading BMP files. |
WiredHome | 32:0e4f2ae512e2 | 251 | /// |
WiredHome | 76:c981284eb513 | 252 | /// @param[in] colorPaletteArray is the handle to the color palette array to use. |
WiredHome | 76:c981284eb513 | 253 | /// @param[in] index is the index into the color palette. |
WiredHome | 32:0e4f2ae512e2 | 254 | /// @returns the color in color_t format. |
WiredHome | 32:0e4f2ae512e2 | 255 | /// |
WiredHome | 73:f22a18707b5e | 256 | color_t RGBQuadToRGB16(RGBQUAD * colorPaletteArray, uint16_t index); |
WiredHome | 32:0e4f2ae512e2 | 257 | |
WiredHome | 41:2956a0a221e5 | 258 | /// This method converts a 16-bit color value into a 24-bit RGB Quad. |
WiredHome | 41:2956a0a221e5 | 259 | /// |
WiredHome | 76:c981284eb513 | 260 | /// @param[in] c is the 16-bit color. @see color_t. |
WiredHome | 41:2956a0a221e5 | 261 | /// @returns an RGBQUAD value. @see RGBQUAD |
WiredHome | 41:2956a0a221e5 | 262 | /// |
WiredHome | 41:2956a0a221e5 | 263 | RGBQUAD RGB16ToRGBQuad(color_t c); |
WiredHome | 41:2956a0a221e5 | 264 | |
WiredHome | 42:7cbdfd2bbfc5 | 265 | /// This method attempts to render a specified graphics image file at |
WiredHome | 42:7cbdfd2bbfc5 | 266 | /// the specified screen location. |
WiredHome | 42:7cbdfd2bbfc5 | 267 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 268 | /// This supports several variants of the following file types: |
WiredHome | 42:7cbdfd2bbfc5 | 269 | /// \li Bitmap file format, |
WiredHome | 42:7cbdfd2bbfc5 | 270 | /// \li Icon file format. |
WiredHome | 42:7cbdfd2bbfc5 | 271 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 272 | /// @note The specified image width and height, when adjusted for the |
WiredHome | 42:7cbdfd2bbfc5 | 273 | /// x and y origin, must fit on the screen, or the image will not |
WiredHome | 42:7cbdfd2bbfc5 | 274 | /// be shown (it does not clip the image). |
WiredHome | 42:7cbdfd2bbfc5 | 275 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 276 | /// @note The file extension is tested, and if it ends in a supported |
WiredHome | 42:7cbdfd2bbfc5 | 277 | /// format, the appropriate handler is called to render that image. |
WiredHome | 42:7cbdfd2bbfc5 | 278 | /// |
WiredHome | 76:c981284eb513 | 279 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 280 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 76:c981284eb513 | 281 | /// @param[in] FileName refers to the fully qualified path and file on |
WiredHome | 42:7cbdfd2bbfc5 | 282 | /// a mounted file system. |
WiredHome | 42:7cbdfd2bbfc5 | 283 | /// @returns success or error code. |
WiredHome | 42:7cbdfd2bbfc5 | 284 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 285 | RetCode_t RenderImageFile(loc_t x, loc_t y, const char *FileName); |
WiredHome | 42:7cbdfd2bbfc5 | 286 | |
WiredHome | 31:c72e12cd5c67 | 287 | /// This method reads a disk file that is in bitmap format and |
WiredHome | 31:c72e12cd5c67 | 288 | /// puts it on the screen. |
WiredHome | 31:c72e12cd5c67 | 289 | /// |
WiredHome | 36:300f6ee0b2cf | 290 | /// Supported formats: |
WiredHome | 112:325ca91bc03d | 291 | /// \li 1-bit color format (2 colors) |
WiredHome | 112:325ca91bc03d | 292 | /// \li 4-bit color format (16 colors) |
WiredHome | 112:325ca91bc03d | 293 | /// \li 8-bit color format (256 colors) |
WiredHome | 36:300f6ee0b2cf | 294 | /// \li 16-bit color format (65k colors) |
WiredHome | 112:325ca91bc03d | 295 | /// \li 24-bit color format (16M colors) |
WiredHome | 36:300f6ee0b2cf | 296 | /// \li compression: no. |
WiredHome | 36:300f6ee0b2cf | 297 | /// |
WiredHome | 36:300f6ee0b2cf | 298 | /// @note This is a slow operation, typically due to the use of |
WiredHome | 36:300f6ee0b2cf | 299 | /// the file system, and partially because bmp files |
WiredHome | 31:c72e12cd5c67 | 300 | /// are stored from the bottom up, and the memory is written |
WiredHome | 32:0e4f2ae512e2 | 301 | /// from the top down; as a result, it constantly 'seeks' |
WiredHome | 32:0e4f2ae512e2 | 302 | /// on the file system for the next row of information. |
WiredHome | 31:c72e12cd5c67 | 303 | /// |
WiredHome | 34:c99ec28fac66 | 304 | /// As a performance test, a sample picture was timed. A family picture |
WiredHome | 34:c99ec28fac66 | 305 | /// was converted to Bitmap format; shrunk to 352 x 272 pixels and save |
WiredHome | 34:c99ec28fac66 | 306 | /// in 8-bit color format. The resulting file size was 94.5 KByte. |
WiredHome | 34:c99ec28fac66 | 307 | /// The SPI port interface was set to 20 MHz. |
WiredHome | 34:c99ec28fac66 | 308 | /// The original bitmap rendering software was purely in software, |
WiredHome | 34:c99ec28fac66 | 309 | /// pushing 1 pixel at a time to the write function, which did use SPI |
WiredHome | 34:c99ec28fac66 | 310 | /// hardware (not pin wiggling) to transfer commands and data to the |
WiredHome | 34:c99ec28fac66 | 311 | /// display. Then, the driver was improved to leverage the capability |
WiredHome | 34:c99ec28fac66 | 312 | /// of the derived display driver. As a final check, instead of the |
WiredHome | 34:c99ec28fac66 | 313 | /// [known slow] local file system, a randomly chosen USB stick was |
WiredHome | 34:c99ec28fac66 | 314 | /// used. The performance results are impressive (but depend on the |
WiredHome | 34:c99ec28fac66 | 315 | /// listed factors). |
WiredHome | 34:c99ec28fac66 | 316 | /// |
WiredHome | 35:7dcab9e3ab25 | 317 | /// \li 34 seconds, LocalFileSystem, Software Rendering |
WiredHome | 35:7dcab9e3ab25 | 318 | /// \li 9 seconds, LocalFileSystem, Hardware Rending for RA8875 |
WiredHome | 35:7dcab9e3ab25 | 319 | /// \li 3 seconds, MSCFileSystem, Hardware Rendering for RA8875 |
WiredHome | 34:c99ec28fac66 | 320 | /// |
WiredHome | 76:c981284eb513 | 321 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 322 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 76:c981284eb513 | 323 | /// @param[in] Name_BMP is the filename on the mounted file system. |
WiredHome | 31:c72e12cd5c67 | 324 | /// @returns success or error code. |
WiredHome | 31:c72e12cd5c67 | 325 | /// |
WiredHome | 37:f19b7e7449dc | 326 | RetCode_t RenderBitmapFile(loc_t x, loc_t y, const char *Name_BMP); |
WiredHome | 31:c72e12cd5c67 | 327 | |
WiredHome | 42:7cbdfd2bbfc5 | 328 | |
WiredHome | 42:7cbdfd2bbfc5 | 329 | /// This method reads a disk file that is in ico format and |
WiredHome | 42:7cbdfd2bbfc5 | 330 | /// puts it on the screen. |
WiredHome | 42:7cbdfd2bbfc5 | 331 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 332 | /// Reading the disk is slow, but a typical icon file is small |
WiredHome | 42:7cbdfd2bbfc5 | 333 | /// so it should be ok. |
WiredHome | 42:7cbdfd2bbfc5 | 334 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 335 | /// @note An Icon file can have more than one icon in it. This |
WiredHome | 42:7cbdfd2bbfc5 | 336 | /// implementation only processes the first image in the file. |
WiredHome | 42:7cbdfd2bbfc5 | 337 | /// |
WiredHome | 76:c981284eb513 | 338 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 339 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 76:c981284eb513 | 340 | /// @param[in] Name_ICO is the filename on the mounted file system. |
WiredHome | 42:7cbdfd2bbfc5 | 341 | /// @returns success or error code. |
WiredHome | 42:7cbdfd2bbfc5 | 342 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 343 | RetCode_t RenderIconFile(loc_t x, loc_t y, const char *Name_ICO); |
WiredHome | 42:7cbdfd2bbfc5 | 344 | |
WiredHome | 42:7cbdfd2bbfc5 | 345 | |
WiredHome | 29:422616aa04bd | 346 | /// prints one character at the specified coordinates. |
WiredHome | 29:422616aa04bd | 347 | /// |
WiredHome | 29:422616aa04bd | 348 | /// This will print the character at the specified pixel coordinates. |
WiredHome | 29:422616aa04bd | 349 | /// |
WiredHome | 76:c981284eb513 | 350 | /// @param[in] x is the horizontal offset in pixels. |
WiredHome | 76:c981284eb513 | 351 | /// @param[in] y is the vertical offset in pixels. |
WiredHome | 76:c981284eb513 | 352 | /// @param[in] value is the character to print. |
WiredHome | 29:422616aa04bd | 353 | /// @returns number of pixels to index to the right if a character was printed, 0 otherwise. |
WiredHome | 29:422616aa04bd | 354 | /// |
WiredHome | 29:422616aa04bd | 355 | virtual int character(int x, int y, int value); |
WiredHome | 29:422616aa04bd | 356 | |
WiredHome | 32:0e4f2ae512e2 | 357 | /// get the number of colums based on the currently active font |
WiredHome | 32:0e4f2ae512e2 | 358 | /// |
WiredHome | 32:0e4f2ae512e2 | 359 | /// @returns number of columns. |
WiredHome | 32:0e4f2ae512e2 | 360 | /// |
WiredHome | 32:0e4f2ae512e2 | 361 | virtual int columns(void); |
WiredHome | 32:0e4f2ae512e2 | 362 | |
WiredHome | 32:0e4f2ae512e2 | 363 | /// get the number of rows based on the currently active font |
WiredHome | 32:0e4f2ae512e2 | 364 | /// |
WiredHome | 32:0e4f2ae512e2 | 365 | /// @returns number of rows. |
WiredHome | 32:0e4f2ae512e2 | 366 | /// |
WiredHome | 32:0e4f2ae512e2 | 367 | virtual int rows(void); |
WiredHome | 32:0e4f2ae512e2 | 368 | |
WiredHome | 98:ecebed9b80b2 | 369 | /// Select a User Font for all subsequent text. |
WiredHome | 98:ecebed9b80b2 | 370 | /// |
WiredHome | 98:ecebed9b80b2 | 371 | /// @note Tool to create the fonts is accessible from its creator |
WiredHome | 98:ecebed9b80b2 | 372 | /// available at http://www.mikroe.com. |
WiredHome | 98:ecebed9b80b2 | 373 | /// For version 1.2.0.0, choose the "Export for TFT and new GLCD" |
WiredHome | 98:ecebed9b80b2 | 374 | /// format. |
WiredHome | 98:ecebed9b80b2 | 375 | /// |
WiredHome | 98:ecebed9b80b2 | 376 | /// @param[in] font is a pointer to a specially formed font resource. |
WiredHome | 98:ecebed9b80b2 | 377 | /// @returns error code. |
WiredHome | 98:ecebed9b80b2 | 378 | /// |
WiredHome | 98:ecebed9b80b2 | 379 | virtual RetCode_t SelectUserFont(const uint8_t * font = NULL); |
WiredHome | 98:ecebed9b80b2 | 380 | |
WiredHome | 32:0e4f2ae512e2 | 381 | |
WiredHome | 32:0e4f2ae512e2 | 382 | protected: |
WiredHome | 32:0e4f2ae512e2 | 383 | |
WiredHome | 32:0e4f2ae512e2 | 384 | /// Pure virtual method indicating the start of a graphics stream. |
WiredHome | 32:0e4f2ae512e2 | 385 | /// |
WiredHome | 32:0e4f2ae512e2 | 386 | /// This is called prior to a stream of pixel data being sent. |
WiredHome | 32:0e4f2ae512e2 | 387 | /// This may cause register configuration changes in the derived |
WiredHome | 32:0e4f2ae512e2 | 388 | /// class in order to prepare the hardware to accept the streaming |
WiredHome | 32:0e4f2ae512e2 | 389 | /// data. |
WiredHome | 32:0e4f2ae512e2 | 390 | /// |
WiredHome | 32:0e4f2ae512e2 | 391 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 392 | /// |
WiredHome | 32:0e4f2ae512e2 | 393 | /// @returns error code. |
WiredHome | 32:0e4f2ae512e2 | 394 | /// |
WiredHome | 32:0e4f2ae512e2 | 395 | virtual RetCode_t _StartGraphicsStream(void) = 0; |
dreschpe | 0:de9d1462a835 | 396 | |
WiredHome | 32:0e4f2ae512e2 | 397 | /// Pure virtual method indicating the end of a graphics stream. |
WiredHome | 32:0e4f2ae512e2 | 398 | /// |
WiredHome | 32:0e4f2ae512e2 | 399 | /// This is called to conclude a stream of pixel data that was sent. |
WiredHome | 32:0e4f2ae512e2 | 400 | /// This may cause register configuration changes in the derived |
WiredHome | 32:0e4f2ae512e2 | 401 | /// class in order to stop the hardware from accept the streaming |
WiredHome | 32:0e4f2ae512e2 | 402 | /// data. |
WiredHome | 32:0e4f2ae512e2 | 403 | /// |
WiredHome | 32:0e4f2ae512e2 | 404 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 405 | /// |
WiredHome | 32:0e4f2ae512e2 | 406 | /// @returns error code. |
WiredHome | 32:0e4f2ae512e2 | 407 | /// |
WiredHome | 32:0e4f2ae512e2 | 408 | virtual RetCode_t _EndGraphicsStream(void) = 0; |
WiredHome | 32:0e4f2ae512e2 | 409 | |
WiredHome | 42:7cbdfd2bbfc5 | 410 | /// Protected method to render an image given a file handle and |
WiredHome | 42:7cbdfd2bbfc5 | 411 | /// coordinates. |
WiredHome | 42:7cbdfd2bbfc5 | 412 | /// |
WiredHome | 76:c981284eb513 | 413 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 414 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 76:c981284eb513 | 415 | /// @param[in] w is the image width restriction, or zero to permit full image width. |
WiredHome | 76:c981284eb513 | 416 | /// @param[in] h is the image height restriction, or zero to permit full image height. |
WiredHome | 76:c981284eb513 | 417 | /// @param[in] fileOffset is the offset into the file where the image data starts |
WiredHome | 76:c981284eb513 | 418 | /// @param[in] Image is the filename stream already opened for the data. |
WiredHome | 42:7cbdfd2bbfc5 | 419 | /// @returns success or error code. |
WiredHome | 42:7cbdfd2bbfc5 | 420 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 421 | RetCode_t _RenderBitmap(loc_t x, loc_t y, uint32_t fileOffset, FILE * Image); |
WiredHome | 42:7cbdfd2bbfc5 | 422 | |
WiredHome | 109:7b94f06f085b | 423 | /// Pure virtual method to write a boolean stream to the display. |
WiredHome | 109:7b94f06f085b | 424 | /// |
WiredHome | 109:7b94f06f085b | 425 | /// This takes a bit stream in memory and using the current color settings |
WiredHome | 109:7b94f06f085b | 426 | /// it will stream it to the display. Along the way, each bit is translated |
WiredHome | 109:7b94f06f085b | 427 | /// to either the foreground or background color value and then that pixel |
WiredHome | 109:7b94f06f085b | 428 | /// is pushed onward. |
WiredHome | 109:7b94f06f085b | 429 | /// |
WiredHome | 109:7b94f06f085b | 430 | /// This is similar, but different, to the @ref pixelStream API, which is |
WiredHome | 109:7b94f06f085b | 431 | /// given a stream of color values. |
WiredHome | 109:7b94f06f085b | 432 | /// |
WiredHome | 109:7b94f06f085b | 433 | /// @param[in] x is the horizontal position on the display. |
WiredHome | 109:7b94f06f085b | 434 | /// @param[in] y is the vertical position on the display. |
WiredHome | 109:7b94f06f085b | 435 | /// @param[in] w is the width of the rectangular region to fill. |
WiredHome | 109:7b94f06f085b | 436 | /// @param[in] h is the height of the rectangular region to fill. |
WiredHome | 109:7b94f06f085b | 437 | /// @param[in] boolStream is the inline memory image from which to extract |
WiredHome | 109:7b94f06f085b | 438 | /// the bitstream. |
WiredHome | 109:7b94f06f085b | 439 | /// @returns success/failure code. See @ref RetCode_t. |
WiredHome | 109:7b94f06f085b | 440 | /// |
WiredHome | 109:7b94f06f085b | 441 | virtual RetCode_t booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) = 0; |
WiredHome | 109:7b94f06f085b | 442 | |
WiredHome | 109:7b94f06f085b | 443 | |
WiredHome | 29:422616aa04bd | 444 | const unsigned char * font; ///< reference to an external font somewhere in memory |
WiredHome | 29:422616aa04bd | 445 | |
dreschpe | 0:de9d1462a835 | 446 | // pixel location |
dreschpe | 0:de9d1462a835 | 447 | short _x; |
dreschpe | 0:de9d1462a835 | 448 | short _y; |
dreschpe | 0:de9d1462a835 | 449 | |
WiredHome | 111:efe436c43aba | 450 | rect_t windowrect; ///< window commands are held here for speed of access |
dreschpe | 0:de9d1462a835 | 451 | }; |
dreschpe | 0:de9d1462a835 | 452 | |
dreschpe | 0:de9d1462a835 | 453 | #endif |
WiredHome | 33:b6b710758ab3 | 454 |