Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

See Components - RA8875 Based Display

Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.

Offline Help Manual (Windows chm)

/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)

Committer:
WiredHome
Date:
Tue Feb 11 21:26:59 2020 +0000
Revision:
196:56820026701b
Parent:
190:3132b7dfad82
Child:
197:853d08e2fb53
Added puts w/point_t parameter.

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 42:7cbdfd2bbfc5 400 /// This method attempts to render a specified graphics image file at
WiredHome 42:7cbdfd2bbfc5 401 /// the specified screen location.
WiredHome 42:7cbdfd2bbfc5 402 ///
WiredHome 42:7cbdfd2bbfc5 403 /// This supports several variants of the following file types:
WiredHome 190:3132b7dfad82 404 /// @li Bitmap file format,
WiredHome 190:3132b7dfad82 405 /// @li Icon file format.
WiredHome 190:3132b7dfad82 406 /// @li Jpeg file format.
WiredHome 42:7cbdfd2bbfc5 407 ///
WiredHome 190:3132b7dfad82 408 /// @note The specified image width and height, when adjusted for the
WiredHome 42:7cbdfd2bbfc5 409 /// x and y origin, must fit on the screen, or the image will not
WiredHome 42:7cbdfd2bbfc5 410 /// be shown (it does not clip the image).
WiredHome 42:7cbdfd2bbfc5 411 ///
WiredHome 42:7cbdfd2bbfc5 412 /// @note The file extension is tested, and if it ends in a supported
WiredHome 42:7cbdfd2bbfc5 413 /// format, the appropriate handler is called to render that image.
WiredHome 42:7cbdfd2bbfc5 414 ///
WiredHome 190:3132b7dfad82 415 /// @param[in] x is the horizontal pixel coordinate of the top-left corner.
WiredHome 190:3132b7dfad82 416 /// @param[in] y is the vertical pixel coordinate of the top-left corner.
WiredHome 190:3132b7dfad82 417 /// @param[in] FileName refers to the fully qualified path and file on
WiredHome 42:7cbdfd2bbfc5 418 /// a mounted file system.
WiredHome 190:3132b7dfad82 419 /// @param[in] getDim when not NULL the image is not drawn. Instead, the
WiredHome 190:3132b7dfad82 420 /// getDim is filled in as the rectangle that would be drawn
WiredHome 190:3132b7dfad82 421 /// relative to the provided x,y origin. This basically
WiredHome 190:3132b7dfad82 422 /// provides a GetImageRect on a specified file.
WiredHome 42:7cbdfd2bbfc5 423 /// @returns success or error code.
WiredHome 42:7cbdfd2bbfc5 424 ///
WiredHome 190:3132b7dfad82 425 RetCode_t RenderImageFile(loc_t x, loc_t y, const char * FileName, rect_t * getDim = NULL);
WiredHome 42:7cbdfd2bbfc5 426
WiredHome 190:3132b7dfad82 427 /// This method reads a disk file that is in jpeg format and
WiredHome 115:c9862fd0c689 428 /// puts it on the screen.
WiredHome 115:c9862fd0c689 429 ///
WiredHome 115:c9862fd0c689 430 /// @param[in] x is the horizontal pixel coordinate
WiredHome 115:c9862fd0c689 431 /// @param[in] y is the vertical pixel coordinate
WiredHome 115:c9862fd0c689 432 /// @param[in] Name_JPG is the filename on the mounted file system.
WiredHome 115:c9862fd0c689 433 /// @returns success or error code.
WiredHome 115:c9862fd0c689 434 ///
WiredHome 115:c9862fd0c689 435 RetCode_t RenderJpegFile(loc_t x, loc_t y, const char *Name_JPG);
WiredHome 115:c9862fd0c689 436
WiredHome 190:3132b7dfad82 437 /// This method reads a disk file that is in bitmap format and
WiredHome 31:c72e12cd5c67 438 /// puts it on the screen.
WiredHome 31:c72e12cd5c67 439 ///
WiredHome 36:300f6ee0b2cf 440 /// Supported formats:
WiredHome 190:3132b7dfad82 441 /// @li 1-bit color format (2 colors)
WiredHome 190:3132b7dfad82 442 /// @li 4-bit color format (16 colors)
WiredHome 190:3132b7dfad82 443 /// @li 8-bit color format (256 colors)
WiredHome 190:3132b7dfad82 444 /// @li 16-bit color format (65k colors)
WiredHome 190:3132b7dfad82 445 /// @li 24-bit color format (16M colors)
WiredHome 190:3132b7dfad82 446 /// @li compression: no.
WiredHome 36:300f6ee0b2cf 447 ///
WiredHome 36:300f6ee0b2cf 448 /// @note This is a slow operation, typically due to the use of
WiredHome 36:300f6ee0b2cf 449 /// the file system, and partially because bmp files
WiredHome 31:c72e12cd5c67 450 /// are stored from the bottom up, and the memory is written
WiredHome 32:0e4f2ae512e2 451 /// from the top down; as a result, it constantly 'seeks'
WiredHome 32:0e4f2ae512e2 452 /// on the file system for the next row of information.
WiredHome 31:c72e12cd5c67 453 ///
WiredHome 34:c99ec28fac66 454 /// As a performance test, a sample picture was timed. A family picture
WiredHome 34:c99ec28fac66 455 /// was converted to Bitmap format; shrunk to 352 x 272 pixels and save
WiredHome 34:c99ec28fac66 456 /// in 8-bit color format. The resulting file size was 94.5 KByte.
WiredHome 34:c99ec28fac66 457 /// The SPI port interface was set to 20 MHz.
WiredHome 190:3132b7dfad82 458 /// The original bitmap rendering software was purely in software,
WiredHome 34:c99ec28fac66 459 /// pushing 1 pixel at a time to the write function, which did use SPI
WiredHome 190:3132b7dfad82 460 /// hardware (not pin wiggling) to transfer commands and data to the
WiredHome 34:c99ec28fac66 461 /// display. Then, the driver was improved to leverage the capability
WiredHome 34:c99ec28fac66 462 /// of the derived display driver. As a final check, instead of the
WiredHome 190:3132b7dfad82 463 /// [known slow] local file system, a randomly chosen USB stick was
WiredHome 34:c99ec28fac66 464 /// used. The performance results are impressive (but depend on the
WiredHome 190:3132b7dfad82 465 /// listed factors).
WiredHome 34:c99ec28fac66 466 ///
WiredHome 190:3132b7dfad82 467 /// @li 34 seconds, LocalFileSystem, Software Rendering
WiredHome 190:3132b7dfad82 468 /// @li 9 seconds, LocalFileSystem, Hardware Rending for RA8875
WiredHome 190:3132b7dfad82 469 /// @li 3 seconds, MSCFileSystem, Hardware Rendering for RA8875
WiredHome 190:3132b7dfad82 470 ///
WiredHome 76:c981284eb513 471 /// @param[in] x is the horizontal pixel coordinate
WiredHome 76:c981284eb513 472 /// @param[in] y is the vertical pixel coordinate
WiredHome 76:c981284eb513 473 /// @param[in] Name_BMP is the filename on the mounted file system.
WiredHome 190:3132b7dfad82 474 /// @param[in] getDim when not NULL is filled in initialized to the x,y
WiredHome 190:3132b7dfad82 475 /// origin, and from the size of the image, which is not drawn.
WiredHome 31:c72e12cd5c67 476 /// @returns success or error code.
WiredHome 31:c72e12cd5c67 477 ///
WiredHome 190:3132b7dfad82 478 RetCode_t RenderBitmapFile(loc_t x, loc_t y, const char *Name_BMP, rect_t * getDim = NULL);
WiredHome 190:3132b7dfad82 479
WiredHome 190:3132b7dfad82 480
WiredHome 190:3132b7dfad82 481 /// This method reads a disk file that is in ico format and
WiredHome 42:7cbdfd2bbfc5 482 /// puts it on the screen.
WiredHome 42:7cbdfd2bbfc5 483 ///
WiredHome 42:7cbdfd2bbfc5 484 /// Reading the disk is slow, but a typical icon file is small
WiredHome 42:7cbdfd2bbfc5 485 /// so it should be ok.
WiredHome 42:7cbdfd2bbfc5 486 ///
WiredHome 42:7cbdfd2bbfc5 487 /// @note An Icon file can have more than one icon in it. This
WiredHome 42:7cbdfd2bbfc5 488 /// implementation only processes the first image in the file.
WiredHome 42:7cbdfd2bbfc5 489 ///
WiredHome 76:c981284eb513 490 /// @param[in] x is the horizontal pixel coordinate
WiredHome 76:c981284eb513 491 /// @param[in] y is the vertical pixel coordinate
WiredHome 76:c981284eb513 492 /// @param[in] Name_ICO is the filename on the mounted file system.
WiredHome 42:7cbdfd2bbfc5 493 /// @returns success or error code.
WiredHome 42:7cbdfd2bbfc5 494 ///
WiredHome 42:7cbdfd2bbfc5 495 RetCode_t RenderIconFile(loc_t x, loc_t y, const char *Name_ICO);
WiredHome 42:7cbdfd2bbfc5 496
WiredHome 190:3132b7dfad82 497
WiredHome 152:a013ac0133e4 498 /// Render a GIF file on screen.
WiredHome 152:a013ac0133e4 499 ///
WiredHome 190:3132b7dfad82 500 /// This function reads a GIF file, and places it on-screen at the specified
WiredHome 152:a013ac0133e4 501 /// coordinates.
WiredHome 152:a013ac0133e4 502 ///
WiredHome 152:a013ac0133e4 503 /// @param[in] x is the left edge of the on-screen coordinates.
WiredHome 152:a013ac0133e4 504 /// @param[in] y is the top edge of the on-screen coordinates.
WiredHome 152:a013ac0133e4 505 /// @param[in] Name_GIF is a pointer to the fully qualified filename.
WiredHome 152:a013ac0133e4 506 /// @returns noerror, or a variety of error codes.
WiredHome 152:a013ac0133e4 507 ///
WiredHome 152:a013ac0133e4 508 RetCode_t RenderGIFFile(loc_t x, loc_t y, const char *Name_GIF);
WiredHome 152:a013ac0133e4 509
WiredHome 152:a013ac0133e4 510
WiredHome 152:a013ac0133e4 511 /// GetGIFMetrics
WiredHome 152:a013ac0133e4 512 ///
WiredHome 152:a013ac0133e4 513 /// Get the GIF Image metrics.
WiredHome 190:3132b7dfad82 514 ///
WiredHome 152:a013ac0133e4 515 /// @param[out] imageDescriptor contains the image metrics on success.
WiredHome 152:a013ac0133e4 516 /// @param[in] Name_GIF is the filename of the GIF file of interest.
WiredHome 152:a013ac0133e4 517 /// @returns noerror, or a variety of error codes.
WiredHome 152:a013ac0133e4 518 ///
WiredHome 152:a013ac0133e4 519 RetCode_t GetGIFMetrics(gif_screen_descriptor_t * imageDescriptor, const char * Name_GIF);
WiredHome 152:a013ac0133e4 520
WiredHome 152:a013ac0133e4 521
WiredHome 29:422616aa04bd 522 /// prints one character at the specified coordinates.
WiredHome 29:422616aa04bd 523 ///
WiredHome 29:422616aa04bd 524 /// This will print the character at the specified pixel coordinates.
WiredHome 29:422616aa04bd 525 ///
WiredHome 76:c981284eb513 526 /// @param[in] x is the horizontal offset in pixels.
WiredHome 76:c981284eb513 527 /// @param[in] y is the vertical offset in pixels.
WiredHome 76:c981284eb513 528 /// @param[in] value is the character to print.
WiredHome 29:422616aa04bd 529 /// @returns number of pixels to index to the right if a character was printed, 0 otherwise.
WiredHome 29:422616aa04bd 530 ///
WiredHome 29:422616aa04bd 531 virtual int character(int x, int y, int value);
WiredHome 190:3132b7dfad82 532
WiredHome 190:3132b7dfad82 533 /// get the number of columns based on the currently active font
WiredHome 32:0e4f2ae512e2 534 ///
WiredHome 32:0e4f2ae512e2 535 /// @returns number of columns.
WiredHome 190:3132b7dfad82 536 ///
WiredHome 32:0e4f2ae512e2 537 virtual int columns(void);
WiredHome 32:0e4f2ae512e2 538
WiredHome 32:0e4f2ae512e2 539 /// get the number of rows based on the currently active font
WiredHome 32:0e4f2ae512e2 540 ///
WiredHome 32:0e4f2ae512e2 541 /// @returns number of rows.
WiredHome 190:3132b7dfad82 542 ///
WiredHome 32:0e4f2ae512e2 543 virtual int rows(void);
WiredHome 190:3132b7dfad82 544
WiredHome 98:ecebed9b80b2 545 /// Select a User Font for all subsequent text.
WiredHome 98:ecebed9b80b2 546 ///
WiredHome 98:ecebed9b80b2 547 /// @note Tool to create the fonts is accessible from its creator
WiredHome 190:3132b7dfad82 548 /// available at http://www.mikroe.com.
WiredHome 98:ecebed9b80b2 549 /// For version 1.2.0.0, choose the "Export for TFT and new GLCD"
WiredHome 98:ecebed9b80b2 550 /// format.
WiredHome 98:ecebed9b80b2 551 ///
WiredHome 98:ecebed9b80b2 552 /// @param[in] font is a pointer to a specially formed font resource.
WiredHome 167:8aa3fb2a5a31 553 /// @returns @ref RetCode_t value.
WiredHome 98:ecebed9b80b2 554 ///
WiredHome 98:ecebed9b80b2 555 virtual RetCode_t SelectUserFont(const uint8_t * font = NULL);
WiredHome 98:ecebed9b80b2 556
WiredHome 32:0e4f2ae512e2 557
WiredHome 32:0e4f2ae512e2 558 protected:
WiredHome 32:0e4f2ae512e2 559
WiredHome 32:0e4f2ae512e2 560 /// Pure virtual method indicating the start of a graphics stream.
WiredHome 32:0e4f2ae512e2 561 ///
WiredHome 32:0e4f2ae512e2 562 /// This is called prior to a stream of pixel data being sent.
WiredHome 32:0e4f2ae512e2 563 /// This may cause register configuration changes in the derived
WiredHome 32:0e4f2ae512e2 564 /// class in order to prepare the hardware to accept the streaming
WiredHome 32:0e4f2ae512e2 565 /// data.
WiredHome 32:0e4f2ae512e2 566 ///
WiredHome 32:0e4f2ae512e2 567 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 568 ///
WiredHome 167:8aa3fb2a5a31 569 /// @returns @ref RetCode_t value.
WiredHome 32:0e4f2ae512e2 570 ///
WiredHome 32:0e4f2ae512e2 571 virtual RetCode_t _StartGraphicsStream(void) = 0;
WiredHome 190:3132b7dfad82 572
WiredHome 32:0e4f2ae512e2 573 /// Pure virtual method indicating the end of a graphics stream.
WiredHome 32:0e4f2ae512e2 574 ///
WiredHome 32:0e4f2ae512e2 575 /// This is called to conclude a stream of pixel data that was sent.
WiredHome 32:0e4f2ae512e2 576 /// This may cause register configuration changes in the derived
WiredHome 32:0e4f2ae512e2 577 /// class in order to stop the hardware from accept the streaming
WiredHome 32:0e4f2ae512e2 578 /// data.
WiredHome 32:0e4f2ae512e2 579 ///
WiredHome 32:0e4f2ae512e2 580 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 581 ///
WiredHome 167:8aa3fb2a5a31 582 /// @returns @ref RetCode_t value.
WiredHome 32:0e4f2ae512e2 583 ///
WiredHome 32:0e4f2ae512e2 584 virtual RetCode_t _EndGraphicsStream(void) = 0;
WiredHome 32:0e4f2ae512e2 585
WiredHome 190:3132b7dfad82 586 /// Protected method to render an image given a file handle and
WiredHome 42:7cbdfd2bbfc5 587 /// coordinates.
WiredHome 42:7cbdfd2bbfc5 588 ///
WiredHome 76:c981284eb513 589 /// @param[in] x is the horizontal pixel coordinate
WiredHome 76:c981284eb513 590 /// @param[in] y is the vertical pixel coordinate
WiredHome 76:c981284eb513 591 /// @param[in] fileOffset is the offset into the file where the image data starts
WiredHome 167:8aa3fb2a5a31 592 /// @param[in] fh is the file handle to the stream already opened for the data.
WiredHome 190:3132b7dfad82 593 /// @param[in] getDim when not NULL is filled in from the size of the image, and the image is not drawn.
WiredHome 42:7cbdfd2bbfc5 594 /// @returns success or error code.
WiredHome 42:7cbdfd2bbfc5 595 ///
WiredHome 190:3132b7dfad82 596 RetCode_t _RenderBitmap(loc_t x, loc_t y, uint32_t fileOffset, FILE * fh, rect_t * getDim = NULL);
WiredHome 42:7cbdfd2bbfc5 597
WiredHome 152:a013ac0133e4 598
WiredHome 190:3132b7dfad82 599 /// Protected method to render a GIF given a file handle and
WiredHome 152:a013ac0133e4 600 /// coordinates.
WiredHome 152:a013ac0133e4 601 ///
WiredHome 152:a013ac0133e4 602 /// @param[in] x is the horizontal pixel coordinate
WiredHome 152:a013ac0133e4 603 /// @param[in] y is the vertical pixel coordinate
WiredHome 167:8aa3fb2a5a31 604 /// @param[in] fh is the file handle to the stream already opened for the data.
WiredHome 152:a013ac0133e4 605 /// @returns success or error code.
WiredHome 152:a013ac0133e4 606 ///
WiredHome 152:a013ac0133e4 607 RetCode_t _RenderGIF(loc_t x, loc_t y, FILE * fh);
WiredHome 152:a013ac0133e4 608
WiredHome 152:a013ac0133e4 609
WiredHome 115:c9862fd0c689 610 private:
WiredHome 122:79e431f98fa9 611
WiredHome 136:224e03d5c31f 612 loc_t img_x; /// x position of a rendered jpg
WiredHome 136:224e03d5c31f 613 loc_t img_y; /// y position of a rendered jpg
WiredHome 136:224e03d5c31f 614
WiredHome 122:79e431f98fa9 615 /// Analyze the jpeg data in preparation for decompression.
WiredHome 122:79e431f98fa9 616 ///
WiredHome 115:c9862fd0c689 617 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 618
WiredHome 122:79e431f98fa9 619 /// Decompress the jpeg and render it.
WiredHome 122:79e431f98fa9 620 ///
WiredHome 115:c9862fd0c689 621 JRESULT jd_decomp(JDEC * jd, uint16_t(* outfunct)(JDEC * jd, void * stream, JRECT * rect), uint8_t scale);
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 privInFunc(JDEC * jd, uint8_t * buff, uint16_t ndata);
WiredHome 115:c9862fd0c689 626
WiredHome 122:79e431f98fa9 627 /// helper function to read data from the file system
WiredHome 122:79e431f98fa9 628 ///
WiredHome 115:c9862fd0c689 629 uint16_t getJpegData(JDEC * jd, uint8_t *buff, uint16_t ndata);
WiredHome 115:c9862fd0c689 630
WiredHome 122:79e431f98fa9 631 /// helper function to write data to the display
WiredHome 122:79e431f98fa9 632 ///
WiredHome 115:c9862fd0c689 633 uint16_t privOutFunc(JDEC * jd, void * bitmap, JRECT * rect);
WiredHome 190:3132b7dfad82 634
WiredHome 115:c9862fd0c689 635 JRESULT mcu_output (
WiredHome 115:c9862fd0c689 636 JDEC * jd, /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 637 uint16_t (* outfunc)(JDEC * jd, void * stream, JRECT * rect), /* RGB output function */
WiredHome 115:c9862fd0c689 638 uint16_t x, /* MCU position in the image (left of the MCU) */
WiredHome 115:c9862fd0c689 639 uint16_t y /* MCU position in the image (top of the MCU) */
WiredHome 115:c9862fd0c689 640 );
WiredHome 115:c9862fd0c689 641
WiredHome 115:c9862fd0c689 642 int16_t bitext ( /* >=0: extracted data, <0: error code */
WiredHome 115:c9862fd0c689 643 JDEC * jd, /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 644 uint16_t nbit /* Number of bits to extract (1 to 11) */
WiredHome 115:c9862fd0c689 645 );
WiredHome 115:c9862fd0c689 646
WiredHome 115:c9862fd0c689 647 int16_t huffext ( /* >=0: decoded data, <0: error code */
WiredHome 115:c9862fd0c689 648 JDEC * jd, /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 649 const uint8_t * hbits, /* Pointer to the bit distribution table */
WiredHome 115:c9862fd0c689 650 const uint16_t * hcode, /* Pointer to the code word table */
WiredHome 115:c9862fd0c689 651 const uint8_t * hdata /* Pointer to the data table */
WiredHome 115:c9862fd0c689 652 );
WiredHome 115:c9862fd0c689 653
WiredHome 115:c9862fd0c689 654 JRESULT restart (
WiredHome 115:c9862fd0c689 655 JDEC * jd, /* Pointer to the decompressor object */
WiredHome 190:3132b7dfad82 656 uint16_t rstn /* Expected restart sequence number */
WiredHome 115:c9862fd0c689 657 );
WiredHome 115:c9862fd0c689 658
WiredHome 115:c9862fd0c689 659 JRESULT mcu_load (
WiredHome 115:c9862fd0c689 660 JDEC * jd /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 661 );
WiredHome 115:c9862fd0c689 662
WiredHome 152:a013ac0133e4 663 gif_screen_descriptor_t screen_descriptor; // attributes for the whole screen
WiredHome 152:a013ac0133e4 664 bool screen_descriptor_isvalid; // has been read
WiredHome 152:a013ac0133e4 665 color_t * global_color_table;
WiredHome 152:a013ac0133e4 666 int global_color_table_size;
WiredHome 152:a013ac0133e4 667 color_t * local_color_table;
WiredHome 152:a013ac0133e4 668 int local_color_table_size;
WiredHome 152:a013ac0133e4 669 RetCode_t GetGIFHeader(FILE * fh);
WiredHome 152:a013ac0133e4 670 bool hasGIFHeader(FILE * fh);
WiredHome 152:a013ac0133e4 671 int process_gif_extension(FILE * fh);
WiredHome 152:a013ac0133e4 672 RetCode_t process_gif_image_descriptor(FILE * fh, uint8_t ** uncompress_gifed_data, int width, int height);
WiredHome 152:a013ac0133e4 673 int read_gif_sub_blocks(FILE * fh, unsigned char **data);
WiredHome 152:a013ac0133e4 674 RetCode_t uncompress_gif(int code_length, const unsigned char *input, int input_length, unsigned char *out);
WiredHome 152:a013ac0133e4 675 size_t read_filesystem_bytes(void * buffer, int numBytes, FILE * fh);
WiredHome 152:a013ac0133e4 676 RetCode_t readGIFImageDescriptor(FILE * fh, gif_image_descriptor_t * gif_image_descriptor);
WiredHome 152:a013ac0133e4 677 RetCode_t readColorTable(color_t * colorTable, int colorTableSize, FILE * fh);
WiredHome 152:a013ac0133e4 678
WiredHome 122:79e431f98fa9 679
WiredHome 115:c9862fd0c689 680 protected:
WiredHome 109:7b94f06f085b 681 /// Pure virtual method to write a boolean stream to the display.
WiredHome 109:7b94f06f085b 682 ///
WiredHome 109:7b94f06f085b 683 /// This takes a bit stream in memory and using the current color settings
WiredHome 109:7b94f06f085b 684 /// it will stream it to the display. Along the way, each bit is translated
WiredHome 109:7b94f06f085b 685 /// to either the foreground or background color value and then that pixel
WiredHome 109:7b94f06f085b 686 /// is pushed onward.
WiredHome 109:7b94f06f085b 687 ///
WiredHome 190:3132b7dfad82 688 /// This is similar, but different, to the @ref pixelStream API, which is
WiredHome 109:7b94f06f085b 689 /// given a stream of color values.
WiredHome 190:3132b7dfad82 690 ///
WiredHome 109:7b94f06f085b 691 /// @param[in] x is the horizontal position on the display.
WiredHome 109:7b94f06f085b 692 /// @param[in] y is the vertical position on the display.
WiredHome 109:7b94f06f085b 693 /// @param[in] w is the width of the rectangular region to fill.
WiredHome 109:7b94f06f085b 694 /// @param[in] h is the height of the rectangular region to fill.
WiredHome 109:7b94f06f085b 695 /// @param[in] boolStream is the inline memory image from which to extract
WiredHome 109:7b94f06f085b 696 /// the bitstream.
WiredHome 167:8aa3fb2a5a31 697 /// @returns @ref RetCode_t value.
WiredHome 109:7b94f06f085b 698 ///
WiredHome 109:7b94f06f085b 699 virtual RetCode_t booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) = 0;
WiredHome 190:3132b7dfad82 700
WiredHome 109:7b94f06f085b 701
WiredHome 29:422616aa04bd 702 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 190:3132b7dfad82 703
dreschpe 0:de9d1462a835 704 // pixel location
WiredHome 125:7a0b70f56550 705 short _x; ///< keeps track of current X location
WiredHome 125:7a0b70f56550 706 short _y; ///< keeps track of current Y location
WiredHome 190:3132b7dfad82 707
WiredHome 153:8a85efb3eb71 708 uint8_t fontScaleX; ///< tracks the font scale factor for Soft fonts. Range: 1 .. 4
WiredHome 153:8a85efb3eb71 709 uint8_t fontScaleY; ///< tracks the font scale factor for soft fonts. Range: 1 .. 4
WiredHome 153:8a85efb3eb71 710
WiredHome 190:3132b7dfad82 711 rect_t windowrect; ///< window commands are held here for speed of access
dreschpe 0:de9d1462a835 712 };
dreschpe 0:de9d1462a835 713
dreschpe 0:de9d1462a835 714 #endif
WiredHome 33:b6b710758ab3 715