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:
Sat Mar 28 15:08:43 2020 +0000
Revision:
199:fb06805f447f
Parent:
198:9b6851107426
Warning reduction

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