This is the David Smart RA8875 Library with mods for working with FRDM-K64F
GraphicsDisplay.h@190:3132b7dfad82, 2019-09-21 (annotated)
- Committer:
- WiredHome
- Date:
- Sat Sep 21 17:30:00 2019 +0000
- Revision:
- 190:3132b7dfad82
- Parent:
- 167:8aa3fb2a5a31
- Child:
- 196:56820026701b
Fonts Add & mods; Add methods; - get dimensions of image file; - round or square cap for thicklines; - word-wrap for puts; - align one rect to another; - independently set the text font fill; - get the width of a character, or a string
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
WiredHome | 167:8aa3fb2a5a31 | 1 | /// @page GraphicDisplay_Copyright GraphicDisplay Library Base Class |
WiredHome | 167:8aa3fb2a5a31 | 2 | /// |
WiredHome | 167:8aa3fb2a5a31 | 3 | /// mbed GraphicsDisplay Display Library Base Class |
WiredHome | 167:8aa3fb2a5a31 | 4 | /// @copyright © 2007-2009 sford |
WiredHome | 167:8aa3fb2a5a31 | 5 | /// Released under the MIT License: http://mbed.org/license/mit |
WiredHome | 167:8aa3fb2a5a31 | 6 | /// |
WiredHome | 190:3132b7dfad82 | 7 | /// extensive changes in the support of the RA8875 display by |
WiredHome | 190:3132b7dfad82 | 8 | /// Smartware Computing. |
WiredHome | 190:3132b7dfad82 | 9 | /// @copyright © 2019 Smartware Computing. |
WiredHome | 190:3132b7dfad82 | 10 | /// |
WiredHome | 190:3132b7dfad82 | 11 | /// |
WiredHome | 167:8aa3fb2a5a31 | 12 | /// A library for providing a common base class for Graphics displays |
WiredHome | 167:8aa3fb2a5a31 | 13 | /// To port a new display, derive from this class and implement |
WiredHome | 167:8aa3fb2a5a31 | 14 | /// the constructor (setup the display), pixel (put a pixel |
WiredHome | 167:8aa3fb2a5a31 | 15 | /// at a location), width and height functions. Everything else |
WiredHome | 190:3132b7dfad82 | 16 | /// (locate, printf, putc, cls, window, putp, fill, blit, blitbit) |
WiredHome | 190:3132b7dfad82 | 17 | /// will come for free. You can also provide a specialized implementation |
WiredHome | 167:8aa3fb2a5a31 | 18 | /// of window and putp to speed up the results |
WiredHome | 167:8aa3fb2a5a31 | 19 | /// |
dreschpe | 0:de9d1462a835 | 20 | #ifndef MBED_GRAPHICSDISPLAY_H |
dreschpe | 0:de9d1462a835 | 21 | #define MBED_GRAPHICSDISPLAY_H |
WiredHome | 32:0e4f2ae512e2 | 22 | #include "Bitmap.h" |
dreschpe | 0:de9d1462a835 | 23 | #include "TextDisplay.h" |
WiredHome | 115:c9862fd0c689 | 24 | #include "GraphicsDisplayJPEG.h" |
WiredHome | 152:a013ac0133e4 | 25 | #include "GraphicsDisplayGIF.h" |
dreschpe | 0:de9d1462a835 | 26 | |
WiredHome | 190:3132b7dfad82 | 27 | /// The GraphicsDisplay class |
WiredHome | 190:3132b7dfad82 | 28 | /// |
WiredHome | 32:0e4f2ae512e2 | 29 | /// This graphics display class supports both graphics and text operations. |
WiredHome | 32:0e4f2ae512e2 | 30 | /// Typically, a subclass is derived from this which has localizations to |
WiredHome | 32:0e4f2ae512e2 | 31 | /// adapt to a specific hardware platform (e.g. a display controller chip), |
WiredHome | 190:3132b7dfad82 | 32 | /// that overrides methods in here to either add more capability or perhaps |
WiredHome | 32:0e4f2ae512e2 | 33 | /// to improve performance, by leveraging specific hardware capabilities. |
WiredHome | 32:0e4f2ae512e2 | 34 | /// |
WiredHome | 190:3132b7dfad82 | 35 | class GraphicsDisplay : public TextDisplay |
WiredHome | 32:0e4f2ae512e2 | 36 | { |
WiredHome | 32:0e4f2ae512e2 | 37 | public: |
WiredHome | 32:0e4f2ae512e2 | 38 | /// The constructor |
dreschpe | 0:de9d1462a835 | 39 | GraphicsDisplay(const char* name); |
WiredHome | 190:3132b7dfad82 | 40 | |
WiredHome | 104:8d1d3832a215 | 41 | //~GraphicsDisplay(); |
WiredHome | 190:3132b7dfad82 | 42 | |
WiredHome | 32:0e4f2ae512e2 | 43 | /// Draw a pixel in the specified color. |
WiredHome | 32:0e4f2ae512e2 | 44 | /// |
WiredHome | 32:0e4f2ae512e2 | 45 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 46 | /// |
WiredHome | 76:c981284eb513 | 47 | /// @param[in] x is the horizontal offset to this pixel. |
WiredHome | 76:c981284eb513 | 48 | /// @param[in] y is the vertical offset to this pixel. |
WiredHome | 76:c981284eb513 | 49 | /// @param[in] color defines the color for the pixel. |
WiredHome | 32:0e4f2ae512e2 | 50 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 51 | /// |
WiredHome | 37:f19b7e7449dc | 52 | virtual RetCode_t pixel(loc_t x, loc_t y, color_t color) = 0; |
WiredHome | 190:3132b7dfad82 | 53 | |
WiredHome | 41:2956a0a221e5 | 54 | /// Write a stream of pixels to the display. |
WiredHome | 41:2956a0a221e5 | 55 | /// |
WiredHome | 41:2956a0a221e5 | 56 | /// @note this method must be supported in the derived class. |
WiredHome | 41:2956a0a221e5 | 57 | /// |
WiredHome | 76:c981284eb513 | 58 | /// @param[in] p is a pointer to a color_t array to write. |
WiredHome | 76:c981284eb513 | 59 | /// @param[in] count is the number of pixels to write. |
WiredHome | 76:c981284eb513 | 60 | /// @param[in] x is the horizontal position on the display. |
WiredHome | 76:c981284eb513 | 61 | /// @param[in] y is the vertical position on the display. |
WiredHome | 41:2956a0a221e5 | 62 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 41:2956a0a221e5 | 63 | /// |
WiredHome | 41:2956a0a221e5 | 64 | virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) = 0; |
WiredHome | 41:2956a0a221e5 | 65 | |
WiredHome | 41:2956a0a221e5 | 66 | /// Get a pixel 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[in] x is the horizontal offset to this pixel. |
WiredHome | 76:c981284eb513 | 71 | /// @param[in] y is the vertical offset to this pixel. |
WiredHome | 125:7a0b70f56550 | 72 | /// @returns the pixel. @see color_t |
WiredHome | 41:2956a0a221e5 | 73 | /// |
WiredHome | 41:2956a0a221e5 | 74 | virtual color_t getPixel(loc_t x, loc_t y) = 0; |
WiredHome | 41:2956a0a221e5 | 75 | |
WiredHome | 41:2956a0a221e5 | 76 | /// Get a stream of pixels from the display. |
WiredHome | 41:2956a0a221e5 | 77 | /// |
WiredHome | 41:2956a0a221e5 | 78 | /// @note this method must be supported in the derived class. |
WiredHome | 41:2956a0a221e5 | 79 | /// |
WiredHome | 76:c981284eb513 | 80 | /// @param[out] p is a pointer to a color_t array to accept the stream. |
WiredHome | 76:c981284eb513 | 81 | /// @param[in] count is the number of pixels to read. |
WiredHome | 76:c981284eb513 | 82 | /// @param[in] x is the horizontal offset to this pixel. |
WiredHome | 76:c981284eb513 | 83 | /// @param[in] y is the vertical offset to this pixel. |
WiredHome | 41:2956a0a221e5 | 84 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 41:2956a0a221e5 | 85 | /// |
WiredHome | 41:2956a0a221e5 | 86 | virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) = 0; |
WiredHome | 190:3132b7dfad82 | 87 | |
WiredHome | 32:0e4f2ae512e2 | 88 | /// get the screen width 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 width in pixels. |
WiredHome | 32:0e4f2ae512e2 | 93 | /// |
WiredHome | 32:0e4f2ae512e2 | 94 | virtual uint16_t width() = 0; |
WiredHome | 190:3132b7dfad82 | 95 | |
WiredHome | 32:0e4f2ae512e2 | 96 | /// get the screen height in pixels |
WiredHome | 32:0e4f2ae512e2 | 97 | /// |
WiredHome | 32:0e4f2ae512e2 | 98 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 99 | /// |
WiredHome | 32:0e4f2ae512e2 | 100 | /// @returns screen height in pixels. |
WiredHome | 32:0e4f2ae512e2 | 101 | /// |
WiredHome | 32:0e4f2ae512e2 | 102 | virtual uint16_t height() = 0; |
WiredHome | 32:0e4f2ae512e2 | 103 | |
WiredHome | 32:0e4f2ae512e2 | 104 | /// Prepare the controller to write binary data to the screen by positioning |
WiredHome | 32:0e4f2ae512e2 | 105 | /// the memory cursor. |
WiredHome | 32:0e4f2ae512e2 | 106 | /// |
WiredHome | 32:0e4f2ae512e2 | 107 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 108 | /// |
WiredHome | 76:c981284eb513 | 109 | /// @param[in] x is the horizontal position in pixels (from the left edge) |
WiredHome | 76:c981284eb513 | 110 | /// @param[in] y is the vertical position in pixels (from the top edge) |
WiredHome | 32:0e4f2ae512e2 | 111 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 112 | /// |
WiredHome | 37:f19b7e7449dc | 113 | virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y) = 0; |
WiredHome | 190:3132b7dfad82 | 114 | |
WiredHome | 190:3132b7dfad82 | 115 | |
WiredHome | 136:224e03d5c31f | 116 | /// Prepare the controller to write binary data to the screen by positioning |
WiredHome | 136:224e03d5c31f | 117 | /// the memory cursor. |
WiredHome | 136:224e03d5c31f | 118 | /// |
WiredHome | 136:224e03d5c31f | 119 | /// @param[in] p is the point representing the cursor position to set |
WiredHome | 167:8aa3fb2a5a31 | 120 | /// @returns @ref RetCode_t value. |
WiredHome | 136:224e03d5c31f | 121 | /// |
WiredHome | 136:224e03d5c31f | 122 | virtual RetCode_t SetGraphicsCursor(point_t p) = 0; |
WiredHome | 190:3132b7dfad82 | 123 | |
WiredHome | 136:224e03d5c31f | 124 | /// Read the current graphics cursor position as a point. |
WiredHome | 136:224e03d5c31f | 125 | /// |
WiredHome | 136:224e03d5c31f | 126 | /// @returns the graphics cursor as a point. |
WiredHome | 136:224e03d5c31f | 127 | /// |
WiredHome | 136:224e03d5c31f | 128 | virtual point_t GetGraphicsCursor(void) = 0; |
WiredHome | 136:224e03d5c31f | 129 | |
WiredHome | 41:2956a0a221e5 | 130 | /// Prepare the controller to read binary data from the screen by positioning |
WiredHome | 41:2956a0a221e5 | 131 | /// the memory read cursor. |
WiredHome | 41:2956a0a221e5 | 132 | /// |
WiredHome | 76:c981284eb513 | 133 | /// @param[in] x is the horizontal position in pixels (from the left edge) |
WiredHome | 76:c981284eb513 | 134 | /// @param[in] y is the vertical position in pixels (from the top edge) |
WiredHome | 41:2956a0a221e5 | 135 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 41:2956a0a221e5 | 136 | /// |
WiredHome | 41:2956a0a221e5 | 137 | virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y) = 0; |
WiredHome | 190:3132b7dfad82 | 138 | |
WiredHome | 32:0e4f2ae512e2 | 139 | /// Draw a filled rectangle in the specified color |
WiredHome | 32:0e4f2ae512e2 | 140 | /// |
WiredHome | 32:0e4f2ae512e2 | 141 | /// @note As a side effect, this changes the current |
WiredHome | 32:0e4f2ae512e2 | 142 | /// foreground color for subsequent operations. |
WiredHome | 32:0e4f2ae512e2 | 143 | /// |
WiredHome | 32:0e4f2ae512e2 | 144 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 145 | /// |
WiredHome | 76:c981284eb513 | 146 | /// @param[in] x1 is the horizontal start of the line. |
WiredHome | 76:c981284eb513 | 147 | /// @param[in] y1 is the vertical start of the line. |
WiredHome | 76:c981284eb513 | 148 | /// @param[in] x2 is the horizontal end of the line. |
WiredHome | 76:c981284eb513 | 149 | /// @param[in] y2 is the vertical end of the line. |
WiredHome | 76:c981284eb513 | 150 | /// @param[in] color defines the foreground color. |
WiredHome | 76:c981284eb513 | 151 | /// @param[in] fillit is optional to NOFILL the rectangle. default is FILL. |
WiredHome | 32:0e4f2ae512e2 | 152 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 153 | /// |
WiredHome | 190:3132b7dfad82 | 154 | virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2, |
WiredHome | 32:0e4f2ae512e2 | 155 | color_t color, fill_t fillit = FILL) = 0; |
WiredHome | 32:0e4f2ae512e2 | 156 | |
WiredHome | 142:6e9bff59878a | 157 | /// Select the drawing layer for subsequent commands. |
WiredHome | 142:6e9bff59878a | 158 | /// |
WiredHome | 190:3132b7dfad82 | 159 | /// If the screen configuration is 480 x 272, or if it is 800 x 480 |
WiredHome | 190:3132b7dfad82 | 160 | /// and 8-bit color, the the display supports two layers, which can |
WiredHome | 142:6e9bff59878a | 161 | /// be independently drawn on and shown. Additionally, complex |
WiredHome | 142:6e9bff59878a | 162 | /// operations involving both layers are permitted. |
WiredHome | 142:6e9bff59878a | 163 | /// |
WiredHome | 142:6e9bff59878a | 164 | /// @code |
WiredHome | 142:6e9bff59878a | 165 | /// //lcd.SetLayerMode(OnlyLayer0); // default is layer 0 |
WiredHome | 142:6e9bff59878a | 166 | /// lcd.rect(400,130, 475,155,Brown); |
WiredHome | 142:6e9bff59878a | 167 | /// lcd.SelectDrawingLayer(1); |
WiredHome | 142:6e9bff59878a | 168 | /// lcd.circle(400,25, 25, BrightRed); |
WiredHome | 142:6e9bff59878a | 169 | /// wait(1); |
WiredHome | 142:6e9bff59878a | 170 | /// lcd.SetLayerMode(ShowLayer1); |
WiredHome | 142:6e9bff59878a | 171 | /// @endcode |
WiredHome | 142:6e9bff59878a | 172 | /// |
WiredHome | 142:6e9bff59878a | 173 | /// @attention The user manual refers to Layer 1 and Layer 2, however the |
WiredHome | 142:6e9bff59878a | 174 | /// actual register values are value 0 and 1. This API as well as |
WiredHome | 142:6e9bff59878a | 175 | /// others that reference the layers use the values 0 and 1 for |
WiredHome | 142:6e9bff59878a | 176 | /// cleaner iteration in the code. |
WiredHome | 142:6e9bff59878a | 177 | /// |
WiredHome | 190:3132b7dfad82 | 178 | /// @param[in] layer is 0 or 1 to select the layer for subsequent |
WiredHome | 142:6e9bff59878a | 179 | /// commands. |
WiredHome | 190:3132b7dfad82 | 180 | /// @param[out] prevLayer is an optional pointer to where the previous layer |
WiredHome | 143:e872d65a710d | 181 | /// will be written, making it a little easer to restore layers. |
WiredHome | 143:e872d65a710d | 182 | /// Writes 0 or 1 when the pointer is not NULL. |
WiredHome | 167:8aa3fb2a5a31 | 183 | /// @returns @ref RetCode_t value. |
WiredHome | 142:6e9bff59878a | 184 | /// |
WiredHome | 143:e872d65a710d | 185 | virtual RetCode_t SelectDrawingLayer(uint16_t layer, uint16_t * prevLayer = NULL) = 0; |
WiredHome | 190:3132b7dfad82 | 186 | |
WiredHome | 190:3132b7dfad82 | 187 | |
WiredHome | 142:6e9bff59878a | 188 | /// Get the currently active drawing layer. |
WiredHome | 142:6e9bff59878a | 189 | /// |
WiredHome | 142:6e9bff59878a | 190 | /// This returns a value, 0 or 1, based on the screen configuration |
WiredHome | 142:6e9bff59878a | 191 | /// and the currently active drawing layer. |
WiredHome | 142:6e9bff59878a | 192 | /// |
WiredHome | 142:6e9bff59878a | 193 | /// @code |
WiredHome | 143:e872d65a710d | 194 | /// uint16_t prevLayer; |
WiredHome | 143:e872d65a710d | 195 | /// lcd.SelectDrawingLayer(x, &prevLayer); |
WiredHome | 142:6e9bff59878a | 196 | /// lcd.circle(400,25, 25, BrightRed); |
WiredHome | 142:6e9bff59878a | 197 | /// lcd.SelectDrawingLayer(prevLayer); |
WiredHome | 142:6e9bff59878a | 198 | /// @endcode |
WiredHome | 142:6e9bff59878a | 199 | /// |
WiredHome | 142:6e9bff59878a | 200 | /// @attention The user manual refers to Layer 1 and Layer 2, however the |
WiredHome | 142:6e9bff59878a | 201 | /// actual register values are value 0 and 1. This API as well as |
WiredHome | 142:6e9bff59878a | 202 | /// others that reference the layers use the values 0 and 1 for |
WiredHome | 142:6e9bff59878a | 203 | /// cleaner iteration in the code. |
WiredHome | 142:6e9bff59878a | 204 | /// |
WiredHome | 142:6e9bff59878a | 205 | /// @returns the current drawing layer; 0 or 1. |
WiredHome | 190:3132b7dfad82 | 206 | /// |
WiredHome | 142:6e9bff59878a | 207 | virtual uint16_t GetDrawingLayer(void) = 0; |
WiredHome | 142:6e9bff59878a | 208 | |
WiredHome | 125:7a0b70f56550 | 209 | /// a function to write the command and data to the RA8875 chip. |
WiredHome | 125:7a0b70f56550 | 210 | /// |
WiredHome | 125:7a0b70f56550 | 211 | /// @param command is the RA8875 instruction to perform |
WiredHome | 125:7a0b70f56550 | 212 | /// @param data is the optional data to the instruction. |
WiredHome | 125:7a0b70f56550 | 213 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 125:7a0b70f56550 | 214 | /// |
WiredHome | 32:0e4f2ae512e2 | 215 | virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF) = 0; |
WiredHome | 190:3132b7dfad82 | 216 | |
WiredHome | 190:3132b7dfad82 | 217 | |
WiredHome | 125:7a0b70f56550 | 218 | /// a function to write the data to the RA8875 chip. |
WiredHome | 125:7a0b70f56550 | 219 | /// |
WiredHome | 125:7a0b70f56550 | 220 | /// This is typically used after a command has been initiated, and where |
WiredHome | 125:7a0b70f56550 | 221 | /// there may be a data stream to follow. |
WiredHome | 125:7a0b70f56550 | 222 | /// |
WiredHome | 125:7a0b70f56550 | 223 | /// @param data is the optional data to the instruction. |
WiredHome | 125:7a0b70f56550 | 224 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 125:7a0b70f56550 | 225 | /// |
WiredHome | 32:0e4f2ae512e2 | 226 | virtual RetCode_t WriteData(unsigned char data) = 0; |
WiredHome | 32:0e4f2ae512e2 | 227 | |
WiredHome | 32:0e4f2ae512e2 | 228 | /// Set the window, which controls where items are written to the screen. |
WiredHome | 32:0e4f2ae512e2 | 229 | /// |
WiredHome | 32:0e4f2ae512e2 | 230 | /// When something hits the window width, it wraps back to the left side |
WiredHome | 190:3132b7dfad82 | 231 | /// and down a row. |
WiredHome | 126:c91bd2e500b9 | 232 | /// |
WiredHome | 126:c91bd2e500b9 | 233 | /// @note If the initial write is outside the window, it will |
WiredHome | 126:c91bd2e500b9 | 234 | /// be captured into the window when it crosses a boundary. It may |
WiredHome | 126:c91bd2e500b9 | 235 | /// be appropriate to SetGraphicsCursor() to a point in the window. |
WiredHome | 32:0e4f2ae512e2 | 236 | /// |
WiredHome | 111:efe436c43aba | 237 | /// @param[in] r is the rect_t rect to define the window. |
WiredHome | 111:efe436c43aba | 238 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 111:efe436c43aba | 239 | /// |
WiredHome | 111:efe436c43aba | 240 | virtual RetCode_t window(rect_t r); |
WiredHome | 111:efe436c43aba | 241 | |
WiredHome | 111:efe436c43aba | 242 | /// Set the window, which controls where items are written to the screen. |
WiredHome | 111:efe436c43aba | 243 | /// |
WiredHome | 111:efe436c43aba | 244 | /// When something hits the window width, it wraps back to the left side |
WiredHome | 190:3132b7dfad82 | 245 | /// and down a row. |
WiredHome | 126:c91bd2e500b9 | 246 | /// |
WiredHome | 126:c91bd2e500b9 | 247 | /// @note If the initial write is outside the window, it will |
WiredHome | 126:c91bd2e500b9 | 248 | /// be captured into the window when it crosses a boundary. It may |
WiredHome | 126:c91bd2e500b9 | 249 | /// be appropriate to SetGraphicsCursor() to a point in the window. |
WiredHome | 111:efe436c43aba | 250 | /// |
WiredHome | 114:dbfb996bfbf3 | 251 | /// @note if no parameters are provided, it restores the window to full screen. |
WiredHome | 114:dbfb996bfbf3 | 252 | /// |
WiredHome | 76:c981284eb513 | 253 | /// @param[in] x is the left edge in pixels. |
WiredHome | 76:c981284eb513 | 254 | /// @param[in] y is the top edge in pixels. |
WiredHome | 76:c981284eb513 | 255 | /// @param[in] w is the window width in pixels. |
WiredHome | 76:c981284eb513 | 256 | /// @param[in] h is the window height in pixels. |
WiredHome | 32:0e4f2ae512e2 | 257 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 258 | /// |
WiredHome | 114:dbfb996bfbf3 | 259 | 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 | 190:3132b7dfad82 | 260 | |
WiredHome | 111:efe436c43aba | 261 | /// method to set the window region to the full screen. |
WiredHome | 111:efe436c43aba | 262 | /// |
WiredHome | 190:3132b7dfad82 | 263 | /// This restores the 'window' to the full screen, so that |
WiredHome | 111:efe436c43aba | 264 | /// other operations (@see cls) would clear the whole screen. |
WiredHome | 111:efe436c43aba | 265 | /// |
WiredHome | 111:efe436c43aba | 266 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 111:efe436c43aba | 267 | /// |
WiredHome | 111:efe436c43aba | 268 | virtual RetCode_t WindowMax(void); |
WiredHome | 190:3132b7dfad82 | 269 | |
WiredHome | 32:0e4f2ae512e2 | 270 | /// Clear the screen. |
WiredHome | 32:0e4f2ae512e2 | 271 | /// |
WiredHome | 32:0e4f2ae512e2 | 272 | /// The behavior is to clear the whole screen. |
WiredHome | 32:0e4f2ae512e2 | 273 | /// |
WiredHome | 190:3132b7dfad82 | 274 | /// @param[in] layers is ignored, but supports maintaining the same |
WiredHome | 61:8f3153bf0baa | 275 | /// API for the graphics layer. |
WiredHome | 32:0e4f2ae512e2 | 276 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 277 | /// |
WiredHome | 61:8f3153bf0baa | 278 | virtual RetCode_t cls(uint16_t layers = 0); |
WiredHome | 190:3132b7dfad82 | 279 | |
WiredHome | 32:0e4f2ae512e2 | 280 | /// method to put a single color pixel to the screen. |
WiredHome | 32:0e4f2ae512e2 | 281 | /// |
WiredHome | 190:3132b7dfad82 | 282 | /// This method may be called as many times as necessary after |
WiredHome | 190:3132b7dfad82 | 283 | /// @see _StartGraphicsStream() is called, and it should be followed |
WiredHome | 32:0e4f2ae512e2 | 284 | /// by _EndGraphicsStream. |
WiredHome | 32:0e4f2ae512e2 | 285 | /// |
WiredHome | 76:c981284eb513 | 286 | /// @param[in] pixel is a color value to be put on the screen. |
WiredHome | 79:544eb4964795 | 287 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 32:0e4f2ae512e2 | 288 | /// |
WiredHome | 55:dfbabef7003e | 289 | virtual RetCode_t _putp(color_t pixel); |
WiredHome | 32:0e4f2ae512e2 | 290 | |
WiredHome | 79:544eb4964795 | 291 | /// method to fill a region. |
WiredHome | 79:544eb4964795 | 292 | /// |
WiredHome | 125:7a0b70f56550 | 293 | /// This method fills a region with the specified color. It essentially |
WiredHome | 125:7a0b70f56550 | 294 | /// is an alias for fillrect, however this uses width and height rather |
WiredHome | 125:7a0b70f56550 | 295 | /// than a second x,y pair. |
WiredHome | 79:544eb4964795 | 296 | /// |
WiredHome | 79:544eb4964795 | 297 | /// @param[in] x is the left-edge of the region. |
WiredHome | 79:544eb4964795 | 298 | /// @param[in] y is the top-edge of the region. |
WiredHome | 79:544eb4964795 | 299 | /// @param[in] w specifies the width of the region. |
WiredHome | 79:544eb4964795 | 300 | /// @param[in] h specifies the height of the region. |
WiredHome | 125:7a0b70f56550 | 301 | /// @param[in] color is the color value to use to fill the region |
WiredHome | 79:544eb4964795 | 302 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 190:3132b7dfad82 | 303 | /// |
WiredHome | 109:7b94f06f085b | 304 | virtual RetCode_t fill(loc_t x, loc_t y, dim_t w, dim_t h, color_t color); |
WiredHome | 190:3132b7dfad82 | 305 | |
WiredHome | 125:7a0b70f56550 | 306 | /// method to stream bitmap data to the display |
WiredHome | 125:7a0b70f56550 | 307 | /// |
WiredHome | 125:7a0b70f56550 | 308 | /// This method fills a region from a stream of color data. |
WiredHome | 125:7a0b70f56550 | 309 | /// |
WiredHome | 125:7a0b70f56550 | 310 | /// @param[in] x is the left-edge of the region. |
WiredHome | 125:7a0b70f56550 | 311 | /// @param[in] y is the top-edge of the region. |
WiredHome | 125:7a0b70f56550 | 312 | /// @param[in] w specifies the width of the region. |
WiredHome | 125:7a0b70f56550 | 313 | /// @param[in] h specifies the height of the region. |
WiredHome | 125:7a0b70f56550 | 314 | /// @param[in] color is a pointer to a color stream with w x h values. |
WiredHome | 125:7a0b70f56550 | 315 | /// @returns success/failure code. @see RetCode_t. |
WiredHome | 190:3132b7dfad82 | 316 | /// |
WiredHome | 190:3132b7dfad82 | 317 | virtual RetCode_t blit(loc_t x, loc_t y, dim_t w, dim_t h, const int * color); |
WiredHome | 190:3132b7dfad82 | 318 | |
WiredHome | 101:e0aad446094a | 319 | /// This method returns the width in pixels of the chosen character |
WiredHome | 101:e0aad446094a | 320 | /// from the previously selected external font. |
WiredHome | 101:e0aad446094a | 321 | /// |
WiredHome | 101:e0aad446094a | 322 | /// @param[in] c is the character of interest. |
WiredHome | 106:c80828f5dea4 | 323 | /// @param[in, out] width is a pointer to where the width will be stored. |
WiredHome | 101:e0aad446094a | 324 | /// This parameter is NULL tested and will only be written if not null |
WiredHome | 101:e0aad446094a | 325 | /// which is convenient if you only want the height. |
WiredHome | 106:c80828f5dea4 | 326 | /// @param[in, out] height is a pointer to where the height will be stored. |
WiredHome | 101:e0aad446094a | 327 | /// This parameter is NULL tested and will only be written if not null |
WiredHome | 101:e0aad446094a | 328 | /// which is convenient if you only want the width. |
WiredHome | 101:e0aad446094a | 329 | /// @returns a pointer to the raw character data or NULL if not found. |
WiredHome | 101:e0aad446094a | 330 | /// |
WiredHome | 109:7b94f06f085b | 331 | virtual const uint8_t * getCharMetrics(const unsigned char c, dim_t * width, dim_t * height); |
WiredHome | 190:3132b7dfad82 | 332 | |
WiredHome | 29:422616aa04bd | 333 | /// This method transfers one character from the external font data |
WiredHome | 29:422616aa04bd | 334 | /// to the screen. |
WiredHome | 29:422616aa04bd | 335 | /// |
WiredHome | 101:e0aad446094a | 336 | /// The font being used has already been set with the SelectUserFont |
WiredHome | 101:e0aad446094a | 337 | /// API. |
WiredHome | 101:e0aad446094a | 338 | /// |
WiredHome | 29:422616aa04bd | 339 | /// @note the font data is in a special format as generate by |
WiredHome | 95:ef538bd687c0 | 340 | /// the mikroe font creator. |
WiredHome | 29:422616aa04bd | 341 | /// See http://www.mikroe.com/glcd-font-creator/ |
WiredHome | 29:422616aa04bd | 342 | /// |
WiredHome | 76:c981284eb513 | 343 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 344 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 98:ecebed9b80b2 | 345 | /// @param[in] c is the character to render |
WiredHome | 98:ecebed9b80b2 | 346 | /// @returns how far the cursor should advance to the right in pixels. |
WiredHome | 98:ecebed9b80b2 | 347 | /// @returns zero if the character could not be rendered. |
WiredHome | 29:422616aa04bd | 348 | /// |
WiredHome | 109:7b94f06f085b | 349 | virtual int fontblit(loc_t x, loc_t y, const unsigned char c); |
WiredHome | 190:3132b7dfad82 | 350 | |
WiredHome | 32:0e4f2ae512e2 | 351 | /// This method returns the color value from a palette. |
WiredHome | 32:0e4f2ae512e2 | 352 | /// |
WiredHome | 32:0e4f2ae512e2 | 353 | /// This method accepts a pointer to a Bitmap color palette, which |
WiredHome | 32:0e4f2ae512e2 | 354 | /// is a table in memory composed of RGB Quad values (r, g, b, 0), |
WiredHome | 32:0e4f2ae512e2 | 355 | /// and an index into that table. It then extracts the color information |
WiredHome | 190:3132b7dfad82 | 356 | /// and down-samples it to a color_t value which it returns. |
WiredHome | 32:0e4f2ae512e2 | 357 | /// |
WiredHome | 32:0e4f2ae512e2 | 358 | /// @note This method probably has very little value outside of |
WiredHome | 32:0e4f2ae512e2 | 359 | /// the internal methods for reading BMP files. |
WiredHome | 32:0e4f2ae512e2 | 360 | /// |
WiredHome | 76:c981284eb513 | 361 | /// @param[in] colorPaletteArray is the handle to the color palette array to use. |
WiredHome | 76:c981284eb513 | 362 | /// @param[in] index is the index into the color palette. |
WiredHome | 32:0e4f2ae512e2 | 363 | /// @returns the color in color_t format. |
WiredHome | 32:0e4f2ae512e2 | 364 | /// |
WiredHome | 73:f22a18707b5e | 365 | color_t RGBQuadToRGB16(RGBQUAD * colorPaletteArray, uint16_t index); |
WiredHome | 190:3132b7dfad82 | 366 | |
WiredHome | 41:2956a0a221e5 | 367 | /// This method converts a 16-bit color value into a 24-bit RGB Quad. |
WiredHome | 41:2956a0a221e5 | 368 | /// |
WiredHome | 76:c981284eb513 | 369 | /// @param[in] c is the 16-bit color. @see color_t. |
WiredHome | 41:2956a0a221e5 | 370 | /// @returns an RGBQUAD value. @see RGBQUAD |
WiredHome | 41:2956a0a221e5 | 371 | /// |
WiredHome | 41:2956a0a221e5 | 372 | RGBQUAD RGB16ToRGBQuad(color_t c); |
WiredHome | 41:2956a0a221e5 | 373 | |
WiredHome | 190:3132b7dfad82 | 374 | |
WiredHome | 190:3132b7dfad82 | 375 | /// This method gets the rectangle that would render a specified image file. |
WiredHome | 190:3132b7dfad82 | 376 | /// |
WiredHome | 190:3132b7dfad82 | 377 | /// This is the more programmer "obvious" method of getting the size of |
WiredHome | 190:3132b7dfad82 | 378 | /// an image file. |
WiredHome | 190:3132b7dfad82 | 379 | /// |
WiredHome | 190:3132b7dfad82 | 380 | /// @note The present implementation calls the RenderImageFile API with the |
WiredHome | 190:3132b7dfad82 | 381 | /// optional getDim parameter. |
WiredHome | 190:3132b7dfad82 | 382 | /// |
WiredHome | 190:3132b7dfad82 | 383 | /// @note Not all image file formats are supported. Check the return value. |
WiredHome | 190:3132b7dfad82 | 384 | /// |
WiredHome | 190:3132b7dfad82 | 385 | /// @param[in] x is the horizontal pixel coordinate of the top-left corner. |
WiredHome | 190:3132b7dfad82 | 386 | /// @param[in] y is the vertical pixel coordinate of the top-left corner. |
WiredHome | 190:3132b7dfad82 | 387 | /// @param[in] FileName refers to the fully qualified path and file on |
WiredHome | 190:3132b7dfad82 | 388 | /// a mounted file system. The filename is optional, in which case |
WiredHome | 190:3132b7dfad82 | 389 | /// it simply returns a rect_t with all elements set to zero. |
WiredHome | 190:3132b7dfad82 | 390 | /// @returns a rect_t that would contain the specified image. When the |
WiredHome | 190:3132b7dfad82 | 391 | /// specified file cannot be found, or where this method is not yet |
WiredHome | 190:3132b7dfad82 | 392 | /// supported, all elements of the returned rect_r will be zero. |
WiredHome | 190:3132b7dfad82 | 393 | /// |
WiredHome | 190:3132b7dfad82 | 394 | rect_t GetImageRect(loc_t x, loc_t y, const char * FileName = NULL); |
WiredHome | 190:3132b7dfad82 | 395 | |
WiredHome | 42:7cbdfd2bbfc5 | 396 | /// This method attempts to render a specified graphics image file at |
WiredHome | 42:7cbdfd2bbfc5 | 397 | /// the specified screen location. |
WiredHome | 42:7cbdfd2bbfc5 | 398 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 399 | /// This supports several variants of the following file types: |
WiredHome | 190:3132b7dfad82 | 400 | /// @li Bitmap file format, |
WiredHome | 190:3132b7dfad82 | 401 | /// @li Icon file format. |
WiredHome | 190:3132b7dfad82 | 402 | /// @li Jpeg file format. |
WiredHome | 42:7cbdfd2bbfc5 | 403 | /// |
WiredHome | 190:3132b7dfad82 | 404 | /// @note The specified image width and height, when adjusted for the |
WiredHome | 42:7cbdfd2bbfc5 | 405 | /// x and y origin, must fit on the screen, or the image will not |
WiredHome | 42:7cbdfd2bbfc5 | 406 | /// be shown (it does not clip the image). |
WiredHome | 42:7cbdfd2bbfc5 | 407 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 408 | /// @note The file extension is tested, and if it ends in a supported |
WiredHome | 42:7cbdfd2bbfc5 | 409 | /// format, the appropriate handler is called to render that image. |
WiredHome | 42:7cbdfd2bbfc5 | 410 | /// |
WiredHome | 190:3132b7dfad82 | 411 | /// @param[in] x is the horizontal pixel coordinate of the top-left corner. |
WiredHome | 190:3132b7dfad82 | 412 | /// @param[in] y is the vertical pixel coordinate of the top-left corner. |
WiredHome | 190:3132b7dfad82 | 413 | /// @param[in] FileName refers to the fully qualified path and file on |
WiredHome | 42:7cbdfd2bbfc5 | 414 | /// a mounted file system. |
WiredHome | 190:3132b7dfad82 | 415 | /// @param[in] getDim when not NULL the image is not drawn. Instead, the |
WiredHome | 190:3132b7dfad82 | 416 | /// getDim is filled in as the rectangle that would be drawn |
WiredHome | 190:3132b7dfad82 | 417 | /// relative to the provided x,y origin. This basically |
WiredHome | 190:3132b7dfad82 | 418 | /// provides a GetImageRect on a specified file. |
WiredHome | 42:7cbdfd2bbfc5 | 419 | /// @returns success or error code. |
WiredHome | 42:7cbdfd2bbfc5 | 420 | /// |
WiredHome | 190:3132b7dfad82 | 421 | RetCode_t RenderImageFile(loc_t x, loc_t y, const char * FileName, rect_t * getDim = NULL); |
WiredHome | 42:7cbdfd2bbfc5 | 422 | |
WiredHome | 190:3132b7dfad82 | 423 | /// This method reads a disk file that is in jpeg format and |
WiredHome | 115:c9862fd0c689 | 424 | /// puts it on the screen. |
WiredHome | 115:c9862fd0c689 | 425 | /// |
WiredHome | 115:c9862fd0c689 | 426 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 115:c9862fd0c689 | 427 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 115:c9862fd0c689 | 428 | /// @param[in] Name_JPG is the filename on the mounted file system. |
WiredHome | 115:c9862fd0c689 | 429 | /// @returns success or error code. |
WiredHome | 115:c9862fd0c689 | 430 | /// |
WiredHome | 115:c9862fd0c689 | 431 | RetCode_t RenderJpegFile(loc_t x, loc_t y, const char *Name_JPG); |
WiredHome | 115:c9862fd0c689 | 432 | |
WiredHome | 190:3132b7dfad82 | 433 | /// This method reads a disk file that is in bitmap format and |
WiredHome | 31:c72e12cd5c67 | 434 | /// puts it on the screen. |
WiredHome | 31:c72e12cd5c67 | 435 | /// |
WiredHome | 36:300f6ee0b2cf | 436 | /// Supported formats: |
WiredHome | 190:3132b7dfad82 | 437 | /// @li 1-bit color format (2 colors) |
WiredHome | 190:3132b7dfad82 | 438 | /// @li 4-bit color format (16 colors) |
WiredHome | 190:3132b7dfad82 | 439 | /// @li 8-bit color format (256 colors) |
WiredHome | 190:3132b7dfad82 | 440 | /// @li 16-bit color format (65k colors) |
WiredHome | 190:3132b7dfad82 | 441 | /// @li 24-bit color format (16M colors) |
WiredHome | 190:3132b7dfad82 | 442 | /// @li compression: no. |
WiredHome | 36:300f6ee0b2cf | 443 | /// |
WiredHome | 36:300f6ee0b2cf | 444 | /// @note This is a slow operation, typically due to the use of |
WiredHome | 36:300f6ee0b2cf | 445 | /// the file system, and partially because bmp files |
WiredHome | 31:c72e12cd5c67 | 446 | /// are stored from the bottom up, and the memory is written |
WiredHome | 32:0e4f2ae512e2 | 447 | /// from the top down; as a result, it constantly 'seeks' |
WiredHome | 32:0e4f2ae512e2 | 448 | /// on the file system for the next row of information. |
WiredHome | 31:c72e12cd5c67 | 449 | /// |
WiredHome | 34:c99ec28fac66 | 450 | /// As a performance test, a sample picture was timed. A family picture |
WiredHome | 34:c99ec28fac66 | 451 | /// was converted to Bitmap format; shrunk to 352 x 272 pixels and save |
WiredHome | 34:c99ec28fac66 | 452 | /// in 8-bit color format. The resulting file size was 94.5 KByte. |
WiredHome | 34:c99ec28fac66 | 453 | /// The SPI port interface was set to 20 MHz. |
WiredHome | 190:3132b7dfad82 | 454 | /// The original bitmap rendering software was purely in software, |
WiredHome | 34:c99ec28fac66 | 455 | /// pushing 1 pixel at a time to the write function, which did use SPI |
WiredHome | 190:3132b7dfad82 | 456 | /// hardware (not pin wiggling) to transfer commands and data to the |
WiredHome | 34:c99ec28fac66 | 457 | /// display. Then, the driver was improved to leverage the capability |
WiredHome | 34:c99ec28fac66 | 458 | /// of the derived display driver. As a final check, instead of the |
WiredHome | 190:3132b7dfad82 | 459 | /// [known slow] local file system, a randomly chosen USB stick was |
WiredHome | 34:c99ec28fac66 | 460 | /// used. The performance results are impressive (but depend on the |
WiredHome | 190:3132b7dfad82 | 461 | /// listed factors). |
WiredHome | 34:c99ec28fac66 | 462 | /// |
WiredHome | 190:3132b7dfad82 | 463 | /// @li 34 seconds, LocalFileSystem, Software Rendering |
WiredHome | 190:3132b7dfad82 | 464 | /// @li 9 seconds, LocalFileSystem, Hardware Rending for RA8875 |
WiredHome | 190:3132b7dfad82 | 465 | /// @li 3 seconds, MSCFileSystem, Hardware Rendering for RA8875 |
WiredHome | 190:3132b7dfad82 | 466 | /// |
WiredHome | 76:c981284eb513 | 467 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 468 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 76:c981284eb513 | 469 | /// @param[in] Name_BMP is the filename on the mounted file system. |
WiredHome | 190:3132b7dfad82 | 470 | /// @param[in] getDim when not NULL is filled in initialized to the x,y |
WiredHome | 190:3132b7dfad82 | 471 | /// origin, and from the size of the image, which is not drawn. |
WiredHome | 31:c72e12cd5c67 | 472 | /// @returns success or error code. |
WiredHome | 31:c72e12cd5c67 | 473 | /// |
WiredHome | 190:3132b7dfad82 | 474 | RetCode_t RenderBitmapFile(loc_t x, loc_t y, const char *Name_BMP, rect_t * getDim = NULL); |
WiredHome | 190:3132b7dfad82 | 475 | |
WiredHome | 190:3132b7dfad82 | 476 | |
WiredHome | 190:3132b7dfad82 | 477 | /// This method reads a disk file that is in ico format and |
WiredHome | 42:7cbdfd2bbfc5 | 478 | /// puts it on the screen. |
WiredHome | 42:7cbdfd2bbfc5 | 479 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 480 | /// Reading the disk is slow, but a typical icon file is small |
WiredHome | 42:7cbdfd2bbfc5 | 481 | /// so it should be ok. |
WiredHome | 42:7cbdfd2bbfc5 | 482 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 483 | /// @note An Icon file can have more than one icon in it. This |
WiredHome | 42:7cbdfd2bbfc5 | 484 | /// implementation only processes the first image in the file. |
WiredHome | 42:7cbdfd2bbfc5 | 485 | /// |
WiredHome | 76:c981284eb513 | 486 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 487 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 76:c981284eb513 | 488 | /// @param[in] Name_ICO is the filename on the mounted file system. |
WiredHome | 42:7cbdfd2bbfc5 | 489 | /// @returns success or error code. |
WiredHome | 42:7cbdfd2bbfc5 | 490 | /// |
WiredHome | 42:7cbdfd2bbfc5 | 491 | RetCode_t RenderIconFile(loc_t x, loc_t y, const char *Name_ICO); |
WiredHome | 42:7cbdfd2bbfc5 | 492 | |
WiredHome | 190:3132b7dfad82 | 493 | |
WiredHome | 152:a013ac0133e4 | 494 | /// Render a GIF file on screen. |
WiredHome | 152:a013ac0133e4 | 495 | /// |
WiredHome | 190:3132b7dfad82 | 496 | /// This function reads a GIF file, and places it on-screen at the specified |
WiredHome | 152:a013ac0133e4 | 497 | /// coordinates. |
WiredHome | 152:a013ac0133e4 | 498 | /// |
WiredHome | 152:a013ac0133e4 | 499 | /// @param[in] x is the left edge of the on-screen coordinates. |
WiredHome | 152:a013ac0133e4 | 500 | /// @param[in] y is the top edge of the on-screen coordinates. |
WiredHome | 152:a013ac0133e4 | 501 | /// @param[in] Name_GIF is a pointer to the fully qualified filename. |
WiredHome | 152:a013ac0133e4 | 502 | /// @returns noerror, or a variety of error codes. |
WiredHome | 152:a013ac0133e4 | 503 | /// |
WiredHome | 152:a013ac0133e4 | 504 | RetCode_t RenderGIFFile(loc_t x, loc_t y, const char *Name_GIF); |
WiredHome | 152:a013ac0133e4 | 505 | |
WiredHome | 152:a013ac0133e4 | 506 | |
WiredHome | 152:a013ac0133e4 | 507 | /// GetGIFMetrics |
WiredHome | 152:a013ac0133e4 | 508 | /// |
WiredHome | 152:a013ac0133e4 | 509 | /// Get the GIF Image metrics. |
WiredHome | 190:3132b7dfad82 | 510 | /// |
WiredHome | 152:a013ac0133e4 | 511 | /// @param[out] imageDescriptor contains the image metrics on success. |
WiredHome | 152:a013ac0133e4 | 512 | /// @param[in] Name_GIF is the filename of the GIF file of interest. |
WiredHome | 152:a013ac0133e4 | 513 | /// @returns noerror, or a variety of error codes. |
WiredHome | 152:a013ac0133e4 | 514 | /// |
WiredHome | 152:a013ac0133e4 | 515 | RetCode_t GetGIFMetrics(gif_screen_descriptor_t * imageDescriptor, const char * Name_GIF); |
WiredHome | 152:a013ac0133e4 | 516 | |
WiredHome | 152:a013ac0133e4 | 517 | |
WiredHome | 29:422616aa04bd | 518 | /// prints one character at the specified coordinates. |
WiredHome | 29:422616aa04bd | 519 | /// |
WiredHome | 29:422616aa04bd | 520 | /// This will print the character at the specified pixel coordinates. |
WiredHome | 29:422616aa04bd | 521 | /// |
WiredHome | 76:c981284eb513 | 522 | /// @param[in] x is the horizontal offset in pixels. |
WiredHome | 76:c981284eb513 | 523 | /// @param[in] y is the vertical offset in pixels. |
WiredHome | 76:c981284eb513 | 524 | /// @param[in] value is the character to print. |
WiredHome | 29:422616aa04bd | 525 | /// @returns number of pixels to index to the right if a character was printed, 0 otherwise. |
WiredHome | 29:422616aa04bd | 526 | /// |
WiredHome | 29:422616aa04bd | 527 | virtual int character(int x, int y, int value); |
WiredHome | 190:3132b7dfad82 | 528 | |
WiredHome | 190:3132b7dfad82 | 529 | /// get the number of columns based on the currently active font |
WiredHome | 32:0e4f2ae512e2 | 530 | /// |
WiredHome | 32:0e4f2ae512e2 | 531 | /// @returns number of columns. |
WiredHome | 190:3132b7dfad82 | 532 | /// |
WiredHome | 32:0e4f2ae512e2 | 533 | virtual int columns(void); |
WiredHome | 32:0e4f2ae512e2 | 534 | |
WiredHome | 32:0e4f2ae512e2 | 535 | /// get the number of rows based on the currently active font |
WiredHome | 32:0e4f2ae512e2 | 536 | /// |
WiredHome | 32:0e4f2ae512e2 | 537 | /// @returns number of rows. |
WiredHome | 190:3132b7dfad82 | 538 | /// |
WiredHome | 32:0e4f2ae512e2 | 539 | virtual int rows(void); |
WiredHome | 190:3132b7dfad82 | 540 | |
WiredHome | 98:ecebed9b80b2 | 541 | /// Select a User Font for all subsequent text. |
WiredHome | 98:ecebed9b80b2 | 542 | /// |
WiredHome | 98:ecebed9b80b2 | 543 | /// @note Tool to create the fonts is accessible from its creator |
WiredHome | 190:3132b7dfad82 | 544 | /// available at http://www.mikroe.com. |
WiredHome | 98:ecebed9b80b2 | 545 | /// For version 1.2.0.0, choose the "Export for TFT and new GLCD" |
WiredHome | 98:ecebed9b80b2 | 546 | /// format. |
WiredHome | 98:ecebed9b80b2 | 547 | /// |
WiredHome | 98:ecebed9b80b2 | 548 | /// @param[in] font is a pointer to a specially formed font resource. |
WiredHome | 167:8aa3fb2a5a31 | 549 | /// @returns @ref RetCode_t value. |
WiredHome | 98:ecebed9b80b2 | 550 | /// |
WiredHome | 98:ecebed9b80b2 | 551 | virtual RetCode_t SelectUserFont(const uint8_t * font = NULL); |
WiredHome | 98:ecebed9b80b2 | 552 | |
WiredHome | 32:0e4f2ae512e2 | 553 | |
WiredHome | 32:0e4f2ae512e2 | 554 | protected: |
WiredHome | 32:0e4f2ae512e2 | 555 | |
WiredHome | 32:0e4f2ae512e2 | 556 | /// Pure virtual method indicating the start of a graphics stream. |
WiredHome | 32:0e4f2ae512e2 | 557 | /// |
WiredHome | 32:0e4f2ae512e2 | 558 | /// This is called prior to a stream of pixel data being sent. |
WiredHome | 32:0e4f2ae512e2 | 559 | /// This may cause register configuration changes in the derived |
WiredHome | 32:0e4f2ae512e2 | 560 | /// class in order to prepare the hardware to accept the streaming |
WiredHome | 32:0e4f2ae512e2 | 561 | /// data. |
WiredHome | 32:0e4f2ae512e2 | 562 | /// |
WiredHome | 32:0e4f2ae512e2 | 563 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 564 | /// |
WiredHome | 167:8aa3fb2a5a31 | 565 | /// @returns @ref RetCode_t value. |
WiredHome | 32:0e4f2ae512e2 | 566 | /// |
WiredHome | 32:0e4f2ae512e2 | 567 | virtual RetCode_t _StartGraphicsStream(void) = 0; |
WiredHome | 190:3132b7dfad82 | 568 | |
WiredHome | 32:0e4f2ae512e2 | 569 | /// Pure virtual method indicating the end of a graphics stream. |
WiredHome | 32:0e4f2ae512e2 | 570 | /// |
WiredHome | 32:0e4f2ae512e2 | 571 | /// This is called to conclude a stream of pixel data that was sent. |
WiredHome | 32:0e4f2ae512e2 | 572 | /// This may cause register configuration changes in the derived |
WiredHome | 32:0e4f2ae512e2 | 573 | /// class in order to stop the hardware from accept the streaming |
WiredHome | 32:0e4f2ae512e2 | 574 | /// data. |
WiredHome | 32:0e4f2ae512e2 | 575 | /// |
WiredHome | 32:0e4f2ae512e2 | 576 | /// @note this method must be supported in the derived class. |
WiredHome | 32:0e4f2ae512e2 | 577 | /// |
WiredHome | 167:8aa3fb2a5a31 | 578 | /// @returns @ref RetCode_t value. |
WiredHome | 32:0e4f2ae512e2 | 579 | /// |
WiredHome | 32:0e4f2ae512e2 | 580 | virtual RetCode_t _EndGraphicsStream(void) = 0; |
WiredHome | 32:0e4f2ae512e2 | 581 | |
WiredHome | 190:3132b7dfad82 | 582 | /// Protected method to render an image given a file handle and |
WiredHome | 42:7cbdfd2bbfc5 | 583 | /// coordinates. |
WiredHome | 42:7cbdfd2bbfc5 | 584 | /// |
WiredHome | 76:c981284eb513 | 585 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 76:c981284eb513 | 586 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 76:c981284eb513 | 587 | /// @param[in] fileOffset is the offset into the file where the image data starts |
WiredHome | 167:8aa3fb2a5a31 | 588 | /// @param[in] fh is the file handle to the stream already opened for the data. |
WiredHome | 190:3132b7dfad82 | 589 | /// @param[in] getDim when not NULL is filled in from the size of the image, and the image is not drawn. |
WiredHome | 42:7cbdfd2bbfc5 | 590 | /// @returns success or error code. |
WiredHome | 42:7cbdfd2bbfc5 | 591 | /// |
WiredHome | 190:3132b7dfad82 | 592 | RetCode_t _RenderBitmap(loc_t x, loc_t y, uint32_t fileOffset, FILE * fh, rect_t * getDim = NULL); |
WiredHome | 42:7cbdfd2bbfc5 | 593 | |
WiredHome | 152:a013ac0133e4 | 594 | |
WiredHome | 190:3132b7dfad82 | 595 | /// Protected method to render a GIF given a file handle and |
WiredHome | 152:a013ac0133e4 | 596 | /// coordinates. |
WiredHome | 152:a013ac0133e4 | 597 | /// |
WiredHome | 152:a013ac0133e4 | 598 | /// @param[in] x is the horizontal pixel coordinate |
WiredHome | 152:a013ac0133e4 | 599 | /// @param[in] y is the vertical pixel coordinate |
WiredHome | 167:8aa3fb2a5a31 | 600 | /// @param[in] fh is the file handle to the stream already opened for the data. |
WiredHome | 152:a013ac0133e4 | 601 | /// @returns success or error code. |
WiredHome | 152:a013ac0133e4 | 602 | /// |
WiredHome | 152:a013ac0133e4 | 603 | RetCode_t _RenderGIF(loc_t x, loc_t y, FILE * fh); |
WiredHome | 152:a013ac0133e4 | 604 | |
WiredHome | 152:a013ac0133e4 | 605 | |
WiredHome | 115:c9862fd0c689 | 606 | private: |
WiredHome | 122:79e431f98fa9 | 607 | |
WiredHome | 136:224e03d5c31f | 608 | loc_t img_x; /// x position of a rendered jpg |
WiredHome | 136:224e03d5c31f | 609 | loc_t img_y; /// y position of a rendered jpg |
WiredHome | 136:224e03d5c31f | 610 | |
WiredHome | 122:79e431f98fa9 | 611 | /// Analyze the jpeg data in preparation for decompression. |
WiredHome | 122:79e431f98fa9 | 612 | /// |
WiredHome | 115:c9862fd0c689 | 613 | JRESULT jd_prepare(JDEC * jd, uint16_t(* infunc)(JDEC * jd, uint8_t * buffer, uint16_t bufsize), void * pool, uint16_t poolsize, void * filehandle); |
WiredHome | 190:3132b7dfad82 | 614 | |
WiredHome | 122:79e431f98fa9 | 615 | /// Decompress the jpeg and render it. |
WiredHome | 122:79e431f98fa9 | 616 | /// |
WiredHome | 115:c9862fd0c689 | 617 | JRESULT jd_decomp(JDEC * jd, uint16_t(* outfunct)(JDEC * jd, void * stream, JRECT * rect), uint8_t scale); |
WiredHome | 115:c9862fd0c689 | 618 | |
WiredHome | 122:79e431f98fa9 | 619 | /// helper function to read data from the file system |
WiredHome | 122:79e431f98fa9 | 620 | /// |
WiredHome | 115:c9862fd0c689 | 621 | uint16_t privInFunc(JDEC * jd, uint8_t * buff, uint16_t ndata); |
WiredHome | 115:c9862fd0c689 | 622 | |
WiredHome | 122:79e431f98fa9 | 623 | /// helper function to read data from the file system |
WiredHome | 122:79e431f98fa9 | 624 | /// |
WiredHome | 115:c9862fd0c689 | 625 | uint16_t getJpegData(JDEC * jd, uint8_t *buff, uint16_t ndata); |
WiredHome | 115:c9862fd0c689 | 626 | |
WiredHome | 122:79e431f98fa9 | 627 | /// helper function to write data to the display |
WiredHome | 122:79e431f98fa9 | 628 | /// |
WiredHome | 115:c9862fd0c689 | 629 | uint16_t privOutFunc(JDEC * jd, void * bitmap, JRECT * rect); |
WiredHome | 190:3132b7dfad82 | 630 | |
WiredHome | 115:c9862fd0c689 | 631 | JRESULT mcu_output ( |
WiredHome | 115:c9862fd0c689 | 632 | JDEC * jd, /* Pointer to the decompressor object */ |
WiredHome | 115:c9862fd0c689 | 633 | uint16_t (* outfunc)(JDEC * jd, void * stream, JRECT * rect), /* RGB output function */ |
WiredHome | 115:c9862fd0c689 | 634 | uint16_t x, /* MCU position in the image (left of the MCU) */ |
WiredHome | 115:c9862fd0c689 | 635 | uint16_t y /* MCU position in the image (top of the MCU) */ |
WiredHome | 115:c9862fd0c689 | 636 | ); |
WiredHome | 115:c9862fd0c689 | 637 | |
WiredHome | 115:c9862fd0c689 | 638 | int16_t bitext ( /* >=0: extracted data, <0: error code */ |
WiredHome | 115:c9862fd0c689 | 639 | JDEC * jd, /* Pointer to the decompressor object */ |
WiredHome | 115:c9862fd0c689 | 640 | uint16_t nbit /* Number of bits to extract (1 to 11) */ |
WiredHome | 115:c9862fd0c689 | 641 | ); |
WiredHome | 115:c9862fd0c689 | 642 | |
WiredHome | 115:c9862fd0c689 | 643 | int16_t huffext ( /* >=0: decoded data, <0: error code */ |
WiredHome | 115:c9862fd0c689 | 644 | JDEC * jd, /* Pointer to the decompressor object */ |
WiredHome | 115:c9862fd0c689 | 645 | const uint8_t * hbits, /* Pointer to the bit distribution table */ |
WiredHome | 115:c9862fd0c689 | 646 | const uint16_t * hcode, /* Pointer to the code word table */ |
WiredHome | 115:c9862fd0c689 | 647 | const uint8_t * hdata /* Pointer to the data table */ |
WiredHome | 115:c9862fd0c689 | 648 | ); |
WiredHome | 115:c9862fd0c689 | 649 | |
WiredHome | 115:c9862fd0c689 | 650 | JRESULT restart ( |
WiredHome | 115:c9862fd0c689 | 651 | JDEC * jd, /* Pointer to the decompressor object */ |
WiredHome | 190:3132b7dfad82 | 652 | uint16_t rstn /* Expected restart sequence number */ |
WiredHome | 115:c9862fd0c689 | 653 | ); |
WiredHome | 115:c9862fd0c689 | 654 | |
WiredHome | 115:c9862fd0c689 | 655 | JRESULT mcu_load ( |
WiredHome | 115:c9862fd0c689 | 656 | JDEC * jd /* Pointer to the decompressor object */ |
WiredHome | 115:c9862fd0c689 | 657 | ); |
WiredHome | 115:c9862fd0c689 | 658 | |
WiredHome | 152:a013ac0133e4 | 659 | gif_screen_descriptor_t screen_descriptor; // attributes for the whole screen |
WiredHome | 152:a013ac0133e4 | 660 | bool screen_descriptor_isvalid; // has been read |
WiredHome | 152:a013ac0133e4 | 661 | color_t * global_color_table; |
WiredHome | 152:a013ac0133e4 | 662 | int global_color_table_size; |
WiredHome | 152:a013ac0133e4 | 663 | color_t * local_color_table; |
WiredHome | 152:a013ac0133e4 | 664 | int local_color_table_size; |
WiredHome | 152:a013ac0133e4 | 665 | RetCode_t GetGIFHeader(FILE * fh); |
WiredHome | 152:a013ac0133e4 | 666 | bool hasGIFHeader(FILE * fh); |
WiredHome | 152:a013ac0133e4 | 667 | int process_gif_extension(FILE * fh); |
WiredHome | 152:a013ac0133e4 | 668 | RetCode_t process_gif_image_descriptor(FILE * fh, uint8_t ** uncompress_gifed_data, int width, int height); |
WiredHome | 152:a013ac0133e4 | 669 | int read_gif_sub_blocks(FILE * fh, unsigned char **data); |
WiredHome | 152:a013ac0133e4 | 670 | RetCode_t uncompress_gif(int code_length, const unsigned char *input, int input_length, unsigned char *out); |
WiredHome | 152:a013ac0133e4 | 671 | size_t read_filesystem_bytes(void * buffer, int numBytes, FILE * fh); |
WiredHome | 152:a013ac0133e4 | 672 | RetCode_t readGIFImageDescriptor(FILE * fh, gif_image_descriptor_t * gif_image_descriptor); |
WiredHome | 152:a013ac0133e4 | 673 | RetCode_t readColorTable(color_t * colorTable, int colorTableSize, FILE * fh); |
WiredHome | 152:a013ac0133e4 | 674 | |
WiredHome | 122:79e431f98fa9 | 675 | |
WiredHome | 115:c9862fd0c689 | 676 | protected: |
WiredHome | 109:7b94f06f085b | 677 | /// Pure virtual method to write a boolean stream to the display. |
WiredHome | 109:7b94f06f085b | 678 | /// |
WiredHome | 109:7b94f06f085b | 679 | /// This takes a bit stream in memory and using the current color settings |
WiredHome | 109:7b94f06f085b | 680 | /// it will stream it to the display. Along the way, each bit is translated |
WiredHome | 109:7b94f06f085b | 681 | /// to either the foreground or background color value and then that pixel |
WiredHome | 109:7b94f06f085b | 682 | /// is pushed onward. |
WiredHome | 109:7b94f06f085b | 683 | /// |
WiredHome | 190:3132b7dfad82 | 684 | /// This is similar, but different, to the @ref pixelStream API, which is |
WiredHome | 109:7b94f06f085b | 685 | /// given a stream of color values. |
WiredHome | 190:3132b7dfad82 | 686 | /// |
WiredHome | 109:7b94f06f085b | 687 | /// @param[in] x is the horizontal position on the display. |
WiredHome | 109:7b94f06f085b | 688 | /// @param[in] y is the vertical position on the display. |
WiredHome | 109:7b94f06f085b | 689 | /// @param[in] w is the width of the rectangular region to fill. |
WiredHome | 109:7b94f06f085b | 690 | /// @param[in] h is the height of the rectangular region to fill. |
WiredHome | 109:7b94f06f085b | 691 | /// @param[in] boolStream is the inline memory image from which to extract |
WiredHome | 109:7b94f06f085b | 692 | /// the bitstream. |
WiredHome | 167:8aa3fb2a5a31 | 693 | /// @returns @ref RetCode_t value. |
WiredHome | 109:7b94f06f085b | 694 | /// |
WiredHome | 109:7b94f06f085b | 695 | virtual RetCode_t booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) = 0; |
WiredHome | 190:3132b7dfad82 | 696 | |
WiredHome | 109:7b94f06f085b | 697 | |
WiredHome | 29:422616aa04bd | 698 | const unsigned char * font; ///< reference to an external font somewhere in memory |
WiredHome | 190:3132b7dfad82 | 699 | |
dreschpe | 0:de9d1462a835 | 700 | // pixel location |
WiredHome | 125:7a0b70f56550 | 701 | short _x; ///< keeps track of current X location |
WiredHome | 125:7a0b70f56550 | 702 | short _y; ///< keeps track of current Y location |
WiredHome | 190:3132b7dfad82 | 703 | |
WiredHome | 153:8a85efb3eb71 | 704 | uint8_t fontScaleX; ///< tracks the font scale factor for Soft fonts. Range: 1 .. 4 |
WiredHome | 153:8a85efb3eb71 | 705 | uint8_t fontScaleY; ///< tracks the font scale factor for soft fonts. Range: 1 .. 4 |
WiredHome | 153:8a85efb3eb71 | 706 | |
WiredHome | 190:3132b7dfad82 | 707 | rect_t windowrect; ///< window commands are held here for speed of access |
dreschpe | 0:de9d1462a835 | 708 | }; |
dreschpe | 0:de9d1462a835 | 709 | |
dreschpe | 0:de9d1462a835 | 710 | #endif |
WiredHome | 33:b6b710758ab3 | 711 |