This is the David Smart RA8875 Library with mods for working with FRDM-K64F

Committer:
lamell
Date:
Sun May 03 10:16:02 2020 -0400
Revision:
201:1119f1e9f4e4
Parent:
197:853d08e2fb53
Slight modifications to the library. Mainly to make the speed faster and also changing some parameters from private to public.

Who changed what in which revision?

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