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