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