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 Aug 06 15:09:34 2016 +0000
Revision:
126:c91bd2e500b9
Parent:
125:7a0b70f56550
Child:
136:224e03d5c31f
Small documentation update on the window command

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:de9d1462a835 1 /* mbed GraphicsDisplay Display Library Base Class
dreschpe 0:de9d1462a835 2 * Copyright (c) 2007-2009 sford
dreschpe 0:de9d1462a835 3 * Released under the MIT License: http://mbed.org/license/mit
dreschpe 0:de9d1462a835 4 *
dreschpe 0:de9d1462a835 5 * A library for providing a common base class for Graphics displays
dreschpe 0:de9d1462a835 6 * To port a new display, derive from this class and implement
dreschpe 0:de9d1462a835 7 * the constructor (setup the display), pixel (put a pixel
dreschpe 0:de9d1462a835 8 * at a location), width and height functions. Everything else
dreschpe 0:de9d1462a835 9 * (locate, printf, putc, cls, window, putp, fill, blit, blitbit)
dreschpe 0:de9d1462a835 10 * will come for free. You can also provide a specialised implementation
dreschpe 0:de9d1462a835 11 * of window and putp to speed up the results
dreschpe 0:de9d1462a835 12 */
dreschpe 0:de9d1462a835 13
dreschpe 0:de9d1462a835 14 #ifndef MBED_GRAPHICSDISPLAY_H
dreschpe 0:de9d1462a835 15 #define MBED_GRAPHICSDISPLAY_H
WiredHome 32:0e4f2ae512e2 16 #include "Bitmap.h"
dreschpe 0:de9d1462a835 17 #include "TextDisplay.h"
WiredHome 115:c9862fd0c689 18 #include "GraphicsDisplayJPEG.h"
dreschpe 0:de9d1462a835 19
WiredHome 32:0e4f2ae512e2 20 /// The GraphicsDisplay class
WiredHome 32:0e4f2ae512e2 21 ///
WiredHome 32:0e4f2ae512e2 22 /// This graphics display class supports both graphics and text operations.
WiredHome 32:0e4f2ae512e2 23 /// Typically, a subclass is derived from this which has localizations to
WiredHome 32:0e4f2ae512e2 24 /// adapt to a specific hardware platform (e.g. a display controller chip),
WiredHome 32:0e4f2ae512e2 25 /// that overrides methods in here to either add more capability or perhaps
WiredHome 32:0e4f2ae512e2 26 /// to improve performance, by leveraging specific hardware capabilities.
WiredHome 32:0e4f2ae512e2 27 ///
WiredHome 32:0e4f2ae512e2 28 class GraphicsDisplay : public TextDisplay
WiredHome 32:0e4f2ae512e2 29 {
WiredHome 32:0e4f2ae512e2 30 public:
WiredHome 32:0e4f2ae512e2 31 /// The constructor
dreschpe 0:de9d1462a835 32 GraphicsDisplay(const char* name);
WiredHome 32:0e4f2ae512e2 33
WiredHome 104:8d1d3832a215 34 //~GraphicsDisplay();
WiredHome 104:8d1d3832a215 35
WiredHome 32:0e4f2ae512e2 36 /// Draw a pixel in the specified color.
WiredHome 32:0e4f2ae512e2 37 ///
WiredHome 32:0e4f2ae512e2 38 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 39 ///
WiredHome 76:c981284eb513 40 /// @param[in] x is the horizontal offset to this pixel.
WiredHome 76:c981284eb513 41 /// @param[in] y is the vertical offset to this pixel.
WiredHome 76:c981284eb513 42 /// @param[in] color defines the color for the pixel.
WiredHome 32:0e4f2ae512e2 43 /// @returns success/failure code. @see RetCode_t.
WiredHome 32:0e4f2ae512e2 44 ///
WiredHome 37:f19b7e7449dc 45 virtual RetCode_t pixel(loc_t x, loc_t y, color_t color) = 0;
WiredHome 32:0e4f2ae512e2 46
WiredHome 41:2956a0a221e5 47 /// Write a stream of pixels to the display.
WiredHome 41:2956a0a221e5 48 ///
WiredHome 41:2956a0a221e5 49 /// @note this method must be supported in the derived class.
WiredHome 41:2956a0a221e5 50 ///
WiredHome 76:c981284eb513 51 /// @param[in] p is a pointer to a color_t array to write.
WiredHome 76:c981284eb513 52 /// @param[in] count is the number of pixels to write.
WiredHome 76:c981284eb513 53 /// @param[in] x is the horizontal position on the display.
WiredHome 76:c981284eb513 54 /// @param[in] y is the vertical position on the display.
WiredHome 41:2956a0a221e5 55 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 56 ///
WiredHome 41:2956a0a221e5 57 virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) = 0;
WiredHome 41:2956a0a221e5 58
WiredHome 41:2956a0a221e5 59 /// Get a pixel from 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] x is the horizontal offset to this pixel.
WiredHome 76:c981284eb513 64 /// @param[in] y is the vertical offset to this pixel.
WiredHome 125:7a0b70f56550 65 /// @returns the pixel. @see color_t
WiredHome 41:2956a0a221e5 66 ///
WiredHome 41:2956a0a221e5 67 virtual color_t getPixel(loc_t x, loc_t y) = 0;
WiredHome 41:2956a0a221e5 68
WiredHome 41:2956a0a221e5 69 /// Get a stream of pixels from the display.
WiredHome 41:2956a0a221e5 70 ///
WiredHome 41:2956a0a221e5 71 /// @note this method must be supported in the derived class.
WiredHome 41:2956a0a221e5 72 ///
WiredHome 76:c981284eb513 73 /// @param[out] p is a pointer to a color_t array to accept the stream.
WiredHome 76:c981284eb513 74 /// @param[in] count is the number of pixels to read.
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 41:2956a0a221e5 77 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 78 ///
WiredHome 41:2956a0a221e5 79 virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) = 0;
WiredHome 41:2956a0a221e5 80
WiredHome 32:0e4f2ae512e2 81 /// get the screen width in pixels
WiredHome 32:0e4f2ae512e2 82 ///
WiredHome 32:0e4f2ae512e2 83 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 84 ///
WiredHome 32:0e4f2ae512e2 85 /// @returns screen width in pixels.
WiredHome 32:0e4f2ae512e2 86 ///
WiredHome 32:0e4f2ae512e2 87 virtual uint16_t width() = 0;
WiredHome 32:0e4f2ae512e2 88
WiredHome 32:0e4f2ae512e2 89 /// get the screen height in pixels
WiredHome 32:0e4f2ae512e2 90 ///
WiredHome 32:0e4f2ae512e2 91 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 92 ///
WiredHome 32:0e4f2ae512e2 93 /// @returns screen height in pixels.
WiredHome 32:0e4f2ae512e2 94 ///
WiredHome 32:0e4f2ae512e2 95 virtual uint16_t height() = 0;
WiredHome 32:0e4f2ae512e2 96
WiredHome 32:0e4f2ae512e2 97 /// Prepare the controller to write binary data to the screen by positioning
WiredHome 32:0e4f2ae512e2 98 /// the memory cursor.
WiredHome 32:0e4f2ae512e2 99 ///
WiredHome 32:0e4f2ae512e2 100 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 101 ///
WiredHome 76:c981284eb513 102 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 76:c981284eb513 103 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 32:0e4f2ae512e2 104 /// @returns success/failure code. @see RetCode_t.
WiredHome 32:0e4f2ae512e2 105 ///
WiredHome 37:f19b7e7449dc 106 virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y) = 0;
WiredHome 32:0e4f2ae512e2 107
WiredHome 41:2956a0a221e5 108 /// Prepare the controller to read binary data from the screen by positioning
WiredHome 41:2956a0a221e5 109 /// the memory read cursor.
WiredHome 41:2956a0a221e5 110 ///
WiredHome 76:c981284eb513 111 /// @param[in] x is the horizontal position in pixels (from the left edge)
WiredHome 76:c981284eb513 112 /// @param[in] y is the vertical position in pixels (from the top edge)
WiredHome 41:2956a0a221e5 113 /// @returns success/failure code. @see RetCode_t.
WiredHome 41:2956a0a221e5 114 ///
WiredHome 41:2956a0a221e5 115 virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y) = 0;
WiredHome 41:2956a0a221e5 116
WiredHome 32:0e4f2ae512e2 117 /// Draw a filled rectangle in the specified color
WiredHome 32:0e4f2ae512e2 118 ///
WiredHome 32:0e4f2ae512e2 119 /// @note As a side effect, this changes the current
WiredHome 32:0e4f2ae512e2 120 /// foreground color for subsequent operations.
WiredHome 32:0e4f2ae512e2 121 ///
WiredHome 32:0e4f2ae512e2 122 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 123 ///
WiredHome 76:c981284eb513 124 /// @param[in] x1 is the horizontal start of the line.
WiredHome 76:c981284eb513 125 /// @param[in] y1 is the vertical start of the line.
WiredHome 76:c981284eb513 126 /// @param[in] x2 is the horizontal end of the line.
WiredHome 76:c981284eb513 127 /// @param[in] y2 is the vertical end of the line.
WiredHome 76:c981284eb513 128 /// @param[in] color defines the foreground color.
WiredHome 76:c981284eb513 129 /// @param[in] fillit is optional to NOFILL the rectangle. default is FILL.
WiredHome 32:0e4f2ae512e2 130 /// @returns success/failure code. @see RetCode_t.
WiredHome 32:0e4f2ae512e2 131 ///
WiredHome 37:f19b7e7449dc 132 virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
WiredHome 32:0e4f2ae512e2 133 color_t color, fill_t fillit = FILL) = 0;
WiredHome 32:0e4f2ae512e2 134
WiredHome 125:7a0b70f56550 135 /// a function to write the command and data to the RA8875 chip.
WiredHome 125:7a0b70f56550 136 ///
WiredHome 125:7a0b70f56550 137 /// @param command is the RA8875 instruction to perform
WiredHome 125:7a0b70f56550 138 /// @param data is the optional data to the instruction.
WiredHome 125:7a0b70f56550 139 /// @returns success/failure code. @see RetCode_t.
WiredHome 125:7a0b70f56550 140 ///
WiredHome 32:0e4f2ae512e2 141 virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF) = 0;
WiredHome 125:7a0b70f56550 142
WiredHome 125:7a0b70f56550 143
WiredHome 125:7a0b70f56550 144 /// a function to write the data to the RA8875 chip.
WiredHome 125:7a0b70f56550 145 ///
WiredHome 125:7a0b70f56550 146 /// This is typically used after a command has been initiated, and where
WiredHome 125:7a0b70f56550 147 /// there may be a data stream to follow.
WiredHome 125:7a0b70f56550 148 ///
WiredHome 125:7a0b70f56550 149 /// @param data is the optional data to the instruction.
WiredHome 125:7a0b70f56550 150 /// @returns success/failure code. @see RetCode_t.
WiredHome 125:7a0b70f56550 151 ///
WiredHome 32:0e4f2ae512e2 152 virtual RetCode_t WriteData(unsigned char data) = 0;
WiredHome 32:0e4f2ae512e2 153
WiredHome 32:0e4f2ae512e2 154 /// Set the window, which controls where items are written to the screen.
WiredHome 32:0e4f2ae512e2 155 ///
WiredHome 32:0e4f2ae512e2 156 /// When something hits the window width, it wraps back to the left side
WiredHome 126:c91bd2e500b9 157 /// and down a row.
WiredHome 126:c91bd2e500b9 158 ///
WiredHome 126:c91bd2e500b9 159 /// @note If the initial write is outside the window, it will
WiredHome 126:c91bd2e500b9 160 /// be captured into the window when it crosses a boundary. It may
WiredHome 126:c91bd2e500b9 161 /// be appropriate to SetGraphicsCursor() to a point in the window.
WiredHome 32:0e4f2ae512e2 162 ///
WiredHome 111:efe436c43aba 163 /// @param[in] r is the rect_t rect to define the window.
WiredHome 111:efe436c43aba 164 /// @returns success/failure code. @see RetCode_t.
WiredHome 111:efe436c43aba 165 ///
WiredHome 111:efe436c43aba 166 virtual RetCode_t window(rect_t r);
WiredHome 111:efe436c43aba 167
WiredHome 111:efe436c43aba 168 /// Set the window, which controls where items are written to the screen.
WiredHome 111:efe436c43aba 169 ///
WiredHome 111:efe436c43aba 170 /// When something hits the window width, it wraps back to the left side
WiredHome 126:c91bd2e500b9 171 /// and down a row.
WiredHome 126:c91bd2e500b9 172 ///
WiredHome 126:c91bd2e500b9 173 /// @note If the initial write is outside the window, it will
WiredHome 126:c91bd2e500b9 174 /// be captured into the window when it crosses a boundary. It may
WiredHome 126:c91bd2e500b9 175 /// be appropriate to SetGraphicsCursor() to a point in the window.
WiredHome 111:efe436c43aba 176 ///
WiredHome 114:dbfb996bfbf3 177 /// @note if no parameters are provided, it restores the window to full screen.
WiredHome 114:dbfb996bfbf3 178 ///
WiredHome 76:c981284eb513 179 /// @param[in] x is the left edge in pixels.
WiredHome 76:c981284eb513 180 /// @param[in] y is the top edge in pixels.
WiredHome 76:c981284eb513 181 /// @param[in] w is the window width in pixels.
WiredHome 76:c981284eb513 182 /// @param[in] h is the window height in pixels.
WiredHome 32:0e4f2ae512e2 183 /// @returns success/failure code. @see RetCode_t.
WiredHome 32:0e4f2ae512e2 184 ///
WiredHome 114:dbfb996bfbf3 185 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 32:0e4f2ae512e2 186
WiredHome 111:efe436c43aba 187 /// method to set the window region to the full screen.
WiredHome 111:efe436c43aba 188 ///
WiredHome 111:efe436c43aba 189 /// This restores the 'window' to the full screen, so that
WiredHome 111:efe436c43aba 190 /// other operations (@see cls) would clear the whole screen.
WiredHome 111:efe436c43aba 191 ///
WiredHome 111:efe436c43aba 192 /// @returns success/failure code. @see RetCode_t.
WiredHome 111:efe436c43aba 193 ///
WiredHome 111:efe436c43aba 194 virtual RetCode_t WindowMax(void);
WiredHome 111:efe436c43aba 195
WiredHome 32:0e4f2ae512e2 196 /// Clear the screen.
WiredHome 32:0e4f2ae512e2 197 ///
WiredHome 32:0e4f2ae512e2 198 /// The behavior is to clear the whole screen.
WiredHome 32:0e4f2ae512e2 199 ///
WiredHome 76:c981284eb513 200 /// @param[in] layers is ignored, but supports maintaining the same
WiredHome 61:8f3153bf0baa 201 /// API for the graphics layer.
WiredHome 32:0e4f2ae512e2 202 /// @returns success/failure code. @see RetCode_t.
WiredHome 32:0e4f2ae512e2 203 ///
WiredHome 61:8f3153bf0baa 204 virtual RetCode_t cls(uint16_t layers = 0);
WiredHome 32:0e4f2ae512e2 205
WiredHome 32:0e4f2ae512e2 206 /// method to put a single color pixel to the screen.
WiredHome 32:0e4f2ae512e2 207 ///
WiredHome 32:0e4f2ae512e2 208 /// This method may be called as many times as necessary after
WiredHome 32:0e4f2ae512e2 209 /// @see _StartGraphicsStream() is called, and it should be followed
WiredHome 32:0e4f2ae512e2 210 /// by _EndGraphicsStream.
WiredHome 32:0e4f2ae512e2 211 ///
WiredHome 76:c981284eb513 212 /// @param[in] pixel is a color value to be put on the screen.
WiredHome 79:544eb4964795 213 /// @returns success/failure code. @see RetCode_t.
WiredHome 32:0e4f2ae512e2 214 ///
WiredHome 55:dfbabef7003e 215 virtual RetCode_t _putp(color_t pixel);
WiredHome 32:0e4f2ae512e2 216
WiredHome 79:544eb4964795 217 /// method to fill a region.
WiredHome 79:544eb4964795 218 ///
WiredHome 125:7a0b70f56550 219 /// This method fills a region with the specified color. It essentially
WiredHome 125:7a0b70f56550 220 /// is an alias for fillrect, however this uses width and height rather
WiredHome 125:7a0b70f56550 221 /// than a second x,y pair.
WiredHome 79:544eb4964795 222 ///
WiredHome 79:544eb4964795 223 /// @param[in] x is the left-edge of the region.
WiredHome 79:544eb4964795 224 /// @param[in] y is the top-edge of the region.
WiredHome 79:544eb4964795 225 /// @param[in] w specifies the width of the region.
WiredHome 79:544eb4964795 226 /// @param[in] h specifies the height of the region.
WiredHome 125:7a0b70f56550 227 /// @param[in] color is the color value to use to fill the region
WiredHome 79:544eb4964795 228 /// @returns success/failure code. @see RetCode_t.
WiredHome 79:544eb4964795 229 ///
WiredHome 109:7b94f06f085b 230 virtual RetCode_t fill(loc_t x, loc_t y, dim_t w, dim_t h, color_t color);
WiredHome 76:c981284eb513 231
WiredHome 125:7a0b70f56550 232 /// method to stream bitmap data to the display
WiredHome 125:7a0b70f56550 233 ///
WiredHome 125:7a0b70f56550 234 /// This method fills a region from a stream of color data.
WiredHome 125:7a0b70f56550 235 ///
WiredHome 125:7a0b70f56550 236 /// @param[in] x is the left-edge of the region.
WiredHome 125:7a0b70f56550 237 /// @param[in] y is the top-edge of the region.
WiredHome 125:7a0b70f56550 238 /// @param[in] w specifies the width of the region.
WiredHome 125:7a0b70f56550 239 /// @param[in] h specifies the height of the region.
WiredHome 125:7a0b70f56550 240 /// @param[in] color is a pointer to a color stream with w x h values.
WiredHome 125:7a0b70f56550 241 /// @returns success/failure code. @see RetCode_t.
WiredHome 125:7a0b70f56550 242 ///
WiredHome 109:7b94f06f085b 243 virtual RetCode_t blit(loc_t x, loc_t y, dim_t w, dim_t h, const int * color);
WiredHome 29:422616aa04bd 244
WiredHome 101:e0aad446094a 245 /// This method returns the width in pixels of the chosen character
WiredHome 101:e0aad446094a 246 /// from the previously selected external font.
WiredHome 101:e0aad446094a 247 ///
WiredHome 101:e0aad446094a 248 /// @param[in] c is the character of interest.
WiredHome 106:c80828f5dea4 249 /// @param[in, out] width is a pointer to where the width will be stored.
WiredHome 101:e0aad446094a 250 /// This parameter is NULL tested and will only be written if not null
WiredHome 101:e0aad446094a 251 /// which is convenient if you only want the height.
WiredHome 106:c80828f5dea4 252 /// @param[in, out] height is a pointer to where the height will be stored.
WiredHome 101:e0aad446094a 253 /// This parameter is NULL tested and will only be written if not null
WiredHome 101:e0aad446094a 254 /// which is convenient if you only want the width.
WiredHome 101:e0aad446094a 255 /// @returns a pointer to the raw character data or NULL if not found.
WiredHome 101:e0aad446094a 256 ///
WiredHome 109:7b94f06f085b 257 virtual const uint8_t * getCharMetrics(const unsigned char c, dim_t * width, dim_t * height);
WiredHome 101:e0aad446094a 258
WiredHome 29:422616aa04bd 259 /// This method transfers one character from the external font data
WiredHome 29:422616aa04bd 260 /// to the screen.
WiredHome 29:422616aa04bd 261 ///
WiredHome 101:e0aad446094a 262 /// The font being used has already been set with the SelectUserFont
WiredHome 101:e0aad446094a 263 /// API.
WiredHome 101:e0aad446094a 264 ///
WiredHome 29:422616aa04bd 265 /// @note the font data is in a special format as generate by
WiredHome 95:ef538bd687c0 266 /// the mikroe font creator.
WiredHome 29:422616aa04bd 267 /// See http://www.mikroe.com/glcd-font-creator/
WiredHome 29:422616aa04bd 268 ///
WiredHome 76:c981284eb513 269 /// @param[in] x is the horizontal pixel coordinate
WiredHome 76:c981284eb513 270 /// @param[in] y is the vertical pixel coordinate
WiredHome 98:ecebed9b80b2 271 /// @param[in] c is the character to render
WiredHome 98:ecebed9b80b2 272 /// @returns how far the cursor should advance to the right in pixels.
WiredHome 98:ecebed9b80b2 273 /// @returns zero if the character could not be rendered.
WiredHome 29:422616aa04bd 274 ///
WiredHome 109:7b94f06f085b 275 virtual int fontblit(loc_t x, loc_t y, const unsigned char c);
WiredHome 29:422616aa04bd 276
WiredHome 32:0e4f2ae512e2 277 /// This method returns the color value from a palette.
WiredHome 32:0e4f2ae512e2 278 ///
WiredHome 32:0e4f2ae512e2 279 /// This method accepts a pointer to a Bitmap color palette, which
WiredHome 32:0e4f2ae512e2 280 /// is a table in memory composed of RGB Quad values (r, g, b, 0),
WiredHome 32:0e4f2ae512e2 281 /// and an index into that table. It then extracts the color information
WiredHome 32:0e4f2ae512e2 282 /// and downsamples it to a color_t value which it returns.
WiredHome 32:0e4f2ae512e2 283 ///
WiredHome 32:0e4f2ae512e2 284 /// @note This method probably has very little value outside of
WiredHome 32:0e4f2ae512e2 285 /// the internal methods for reading BMP files.
WiredHome 32:0e4f2ae512e2 286 ///
WiredHome 76:c981284eb513 287 /// @param[in] colorPaletteArray is the handle to the color palette array to use.
WiredHome 76:c981284eb513 288 /// @param[in] index is the index into the color palette.
WiredHome 32:0e4f2ae512e2 289 /// @returns the color in color_t format.
WiredHome 32:0e4f2ae512e2 290 ///
WiredHome 73:f22a18707b5e 291 color_t RGBQuadToRGB16(RGBQUAD * colorPaletteArray, uint16_t index);
WiredHome 32:0e4f2ae512e2 292
WiredHome 41:2956a0a221e5 293 /// This method converts a 16-bit color value into a 24-bit RGB Quad.
WiredHome 41:2956a0a221e5 294 ///
WiredHome 76:c981284eb513 295 /// @param[in] c is the 16-bit color. @see color_t.
WiredHome 41:2956a0a221e5 296 /// @returns an RGBQUAD value. @see RGBQUAD
WiredHome 41:2956a0a221e5 297 ///
WiredHome 41:2956a0a221e5 298 RGBQUAD RGB16ToRGBQuad(color_t c);
WiredHome 41:2956a0a221e5 299
WiredHome 42:7cbdfd2bbfc5 300 /// This method attempts to render a specified graphics image file at
WiredHome 42:7cbdfd2bbfc5 301 /// the specified screen location.
WiredHome 42:7cbdfd2bbfc5 302 ///
WiredHome 42:7cbdfd2bbfc5 303 /// This supports several variants of the following file types:
WiredHome 42:7cbdfd2bbfc5 304 /// \li Bitmap file format,
WiredHome 42:7cbdfd2bbfc5 305 /// \li Icon file format.
WiredHome 42:7cbdfd2bbfc5 306 ///
WiredHome 42:7cbdfd2bbfc5 307 /// @note The specified image width and height, when adjusted for the
WiredHome 42:7cbdfd2bbfc5 308 /// x and y origin, must fit on the screen, or the image will not
WiredHome 42:7cbdfd2bbfc5 309 /// be shown (it does not clip the image).
WiredHome 42:7cbdfd2bbfc5 310 ///
WiredHome 42:7cbdfd2bbfc5 311 /// @note The file extension is tested, and if it ends in a supported
WiredHome 42:7cbdfd2bbfc5 312 /// format, the appropriate handler is called to render that image.
WiredHome 42:7cbdfd2bbfc5 313 ///
WiredHome 76:c981284eb513 314 /// @param[in] x is the horizontal pixel coordinate
WiredHome 76:c981284eb513 315 /// @param[in] y is the vertical pixel coordinate
WiredHome 76:c981284eb513 316 /// @param[in] FileName refers to the fully qualified path and file on
WiredHome 42:7cbdfd2bbfc5 317 /// a mounted file system.
WiredHome 42:7cbdfd2bbfc5 318 /// @returns success or error code.
WiredHome 42:7cbdfd2bbfc5 319 ///
WiredHome 42:7cbdfd2bbfc5 320 RetCode_t RenderImageFile(loc_t x, loc_t y, const char *FileName);
WiredHome 42:7cbdfd2bbfc5 321
WiredHome 115:c9862fd0c689 322 /// This method reads a disk file that is in jpeg format and
WiredHome 115:c9862fd0c689 323 /// puts it on the screen.
WiredHome 115:c9862fd0c689 324 ///
WiredHome 115:c9862fd0c689 325 /// @param[in] x is the horizontal pixel coordinate
WiredHome 115:c9862fd0c689 326 /// @param[in] y is the vertical pixel coordinate
WiredHome 115:c9862fd0c689 327 /// @param[in] Name_JPG is the filename on the mounted file system.
WiredHome 115:c9862fd0c689 328 /// @returns success or error code.
WiredHome 115:c9862fd0c689 329 ///
WiredHome 115:c9862fd0c689 330 RetCode_t RenderJpegFile(loc_t x, loc_t y, const char *Name_JPG);
WiredHome 115:c9862fd0c689 331
WiredHome 31:c72e12cd5c67 332 /// This method reads a disk file that is in bitmap format and
WiredHome 31:c72e12cd5c67 333 /// puts it on the screen.
WiredHome 31:c72e12cd5c67 334 ///
WiredHome 36:300f6ee0b2cf 335 /// Supported formats:
WiredHome 112:325ca91bc03d 336 /// \li 1-bit color format (2 colors)
WiredHome 112:325ca91bc03d 337 /// \li 4-bit color format (16 colors)
WiredHome 112:325ca91bc03d 338 /// \li 8-bit color format (256 colors)
WiredHome 36:300f6ee0b2cf 339 /// \li 16-bit color format (65k colors)
WiredHome 112:325ca91bc03d 340 /// \li 24-bit color format (16M colors)
WiredHome 36:300f6ee0b2cf 341 /// \li compression: no.
WiredHome 36:300f6ee0b2cf 342 ///
WiredHome 36:300f6ee0b2cf 343 /// @note This is a slow operation, typically due to the use of
WiredHome 36:300f6ee0b2cf 344 /// the file system, and partially because bmp files
WiredHome 31:c72e12cd5c67 345 /// are stored from the bottom up, and the memory is written
WiredHome 32:0e4f2ae512e2 346 /// from the top down; as a result, it constantly 'seeks'
WiredHome 32:0e4f2ae512e2 347 /// on the file system for the next row of information.
WiredHome 31:c72e12cd5c67 348 ///
WiredHome 34:c99ec28fac66 349 /// As a performance test, a sample picture was timed. A family picture
WiredHome 34:c99ec28fac66 350 /// was converted to Bitmap format; shrunk to 352 x 272 pixels and save
WiredHome 34:c99ec28fac66 351 /// in 8-bit color format. The resulting file size was 94.5 KByte.
WiredHome 34:c99ec28fac66 352 /// The SPI port interface was set to 20 MHz.
WiredHome 34:c99ec28fac66 353 /// The original bitmap rendering software was purely in software,
WiredHome 34:c99ec28fac66 354 /// pushing 1 pixel at a time to the write function, which did use SPI
WiredHome 34:c99ec28fac66 355 /// hardware (not pin wiggling) to transfer commands and data to the
WiredHome 34:c99ec28fac66 356 /// display. Then, the driver was improved to leverage the capability
WiredHome 34:c99ec28fac66 357 /// of the derived display driver. As a final check, instead of the
WiredHome 34:c99ec28fac66 358 /// [known slow] local file system, a randomly chosen USB stick was
WiredHome 34:c99ec28fac66 359 /// used. The performance results are impressive (but depend on the
WiredHome 34:c99ec28fac66 360 /// listed factors).
WiredHome 34:c99ec28fac66 361 ///
WiredHome 35:7dcab9e3ab25 362 /// \li 34 seconds, LocalFileSystem, Software Rendering
WiredHome 35:7dcab9e3ab25 363 /// \li 9 seconds, LocalFileSystem, Hardware Rending for RA8875
WiredHome 35:7dcab9e3ab25 364 /// \li 3 seconds, MSCFileSystem, Hardware Rendering for RA8875
WiredHome 34:c99ec28fac66 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 76:c981284eb513 368 /// @param[in] Name_BMP is the filename on the mounted file system.
WiredHome 31:c72e12cd5c67 369 /// @returns success or error code.
WiredHome 31:c72e12cd5c67 370 ///
WiredHome 37:f19b7e7449dc 371 RetCode_t RenderBitmapFile(loc_t x, loc_t y, const char *Name_BMP);
WiredHome 31:c72e12cd5c67 372
WiredHome 42:7cbdfd2bbfc5 373
WiredHome 42:7cbdfd2bbfc5 374 /// This method reads a disk file that is in ico format and
WiredHome 42:7cbdfd2bbfc5 375 /// puts it on the screen.
WiredHome 42:7cbdfd2bbfc5 376 ///
WiredHome 42:7cbdfd2bbfc5 377 /// Reading the disk is slow, but a typical icon file is small
WiredHome 42:7cbdfd2bbfc5 378 /// so it should be ok.
WiredHome 42:7cbdfd2bbfc5 379 ///
WiredHome 42:7cbdfd2bbfc5 380 /// @note An Icon file can have more than one icon in it. This
WiredHome 42:7cbdfd2bbfc5 381 /// implementation only processes the first image in the file.
WiredHome 42:7cbdfd2bbfc5 382 ///
WiredHome 76:c981284eb513 383 /// @param[in] x is the horizontal pixel coordinate
WiredHome 76:c981284eb513 384 /// @param[in] y is the vertical pixel coordinate
WiredHome 76:c981284eb513 385 /// @param[in] Name_ICO is the filename on the mounted file system.
WiredHome 42:7cbdfd2bbfc5 386 /// @returns success or error code.
WiredHome 42:7cbdfd2bbfc5 387 ///
WiredHome 42:7cbdfd2bbfc5 388 RetCode_t RenderIconFile(loc_t x, loc_t y, const char *Name_ICO);
WiredHome 42:7cbdfd2bbfc5 389
WiredHome 42:7cbdfd2bbfc5 390
WiredHome 29:422616aa04bd 391 /// prints one character at the specified coordinates.
WiredHome 29:422616aa04bd 392 ///
WiredHome 29:422616aa04bd 393 /// This will print the character at the specified pixel coordinates.
WiredHome 29:422616aa04bd 394 ///
WiredHome 76:c981284eb513 395 /// @param[in] x is the horizontal offset in pixels.
WiredHome 76:c981284eb513 396 /// @param[in] y is the vertical offset in pixels.
WiredHome 76:c981284eb513 397 /// @param[in] value is the character to print.
WiredHome 29:422616aa04bd 398 /// @returns number of pixels to index to the right if a character was printed, 0 otherwise.
WiredHome 29:422616aa04bd 399 ///
WiredHome 29:422616aa04bd 400 virtual int character(int x, int y, int value);
WiredHome 29:422616aa04bd 401
WiredHome 32:0e4f2ae512e2 402 /// get the number of colums based on the currently active font
WiredHome 32:0e4f2ae512e2 403 ///
WiredHome 32:0e4f2ae512e2 404 /// @returns number of columns.
WiredHome 32:0e4f2ae512e2 405 ///
WiredHome 32:0e4f2ae512e2 406 virtual int columns(void);
WiredHome 32:0e4f2ae512e2 407
WiredHome 32:0e4f2ae512e2 408 /// get the number of rows based on the currently active font
WiredHome 32:0e4f2ae512e2 409 ///
WiredHome 32:0e4f2ae512e2 410 /// @returns number of rows.
WiredHome 32:0e4f2ae512e2 411 ///
WiredHome 32:0e4f2ae512e2 412 virtual int rows(void);
WiredHome 32:0e4f2ae512e2 413
WiredHome 98:ecebed9b80b2 414 /// Select a User Font for all subsequent text.
WiredHome 98:ecebed9b80b2 415 ///
WiredHome 98:ecebed9b80b2 416 /// @note Tool to create the fonts is accessible from its creator
WiredHome 98:ecebed9b80b2 417 /// available at http://www.mikroe.com.
WiredHome 98:ecebed9b80b2 418 /// For version 1.2.0.0, choose the "Export for TFT and new GLCD"
WiredHome 98:ecebed9b80b2 419 /// format.
WiredHome 98:ecebed9b80b2 420 ///
WiredHome 98:ecebed9b80b2 421 /// @param[in] font is a pointer to a specially formed font resource.
WiredHome 98:ecebed9b80b2 422 /// @returns error code.
WiredHome 98:ecebed9b80b2 423 ///
WiredHome 98:ecebed9b80b2 424 virtual RetCode_t SelectUserFont(const uint8_t * font = NULL);
WiredHome 98:ecebed9b80b2 425
WiredHome 32:0e4f2ae512e2 426
WiredHome 32:0e4f2ae512e2 427 protected:
WiredHome 32:0e4f2ae512e2 428
WiredHome 32:0e4f2ae512e2 429 /// Pure virtual method indicating the start of a graphics stream.
WiredHome 32:0e4f2ae512e2 430 ///
WiredHome 32:0e4f2ae512e2 431 /// This is called prior to a stream of pixel data being sent.
WiredHome 32:0e4f2ae512e2 432 /// This may cause register configuration changes in the derived
WiredHome 32:0e4f2ae512e2 433 /// class in order to prepare the hardware to accept the streaming
WiredHome 32:0e4f2ae512e2 434 /// data.
WiredHome 32:0e4f2ae512e2 435 ///
WiredHome 32:0e4f2ae512e2 436 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 437 ///
WiredHome 32:0e4f2ae512e2 438 /// @returns error code.
WiredHome 32:0e4f2ae512e2 439 ///
WiredHome 32:0e4f2ae512e2 440 virtual RetCode_t _StartGraphicsStream(void) = 0;
dreschpe 0:de9d1462a835 441
WiredHome 32:0e4f2ae512e2 442 /// Pure virtual method indicating the end of a graphics stream.
WiredHome 32:0e4f2ae512e2 443 ///
WiredHome 32:0e4f2ae512e2 444 /// This is called to conclude a stream of pixel data that was sent.
WiredHome 32:0e4f2ae512e2 445 /// This may cause register configuration changes in the derived
WiredHome 32:0e4f2ae512e2 446 /// class in order to stop the hardware from accept the streaming
WiredHome 32:0e4f2ae512e2 447 /// data.
WiredHome 32:0e4f2ae512e2 448 ///
WiredHome 32:0e4f2ae512e2 449 /// @note this method must be supported in the derived class.
WiredHome 32:0e4f2ae512e2 450 ///
WiredHome 32:0e4f2ae512e2 451 /// @returns error code.
WiredHome 32:0e4f2ae512e2 452 ///
WiredHome 32:0e4f2ae512e2 453 virtual RetCode_t _EndGraphicsStream(void) = 0;
WiredHome 32:0e4f2ae512e2 454
WiredHome 42:7cbdfd2bbfc5 455 /// Protected method to render an image given a file handle and
WiredHome 42:7cbdfd2bbfc5 456 /// coordinates.
WiredHome 42:7cbdfd2bbfc5 457 ///
WiredHome 76:c981284eb513 458 /// @param[in] x is the horizontal pixel coordinate
WiredHome 76:c981284eb513 459 /// @param[in] y is the vertical pixel coordinate
WiredHome 76:c981284eb513 460 /// @param[in] fileOffset is the offset into the file where the image data starts
WiredHome 76:c981284eb513 461 /// @param[in] Image is the filename stream already opened for the data.
WiredHome 42:7cbdfd2bbfc5 462 /// @returns success or error code.
WiredHome 42:7cbdfd2bbfc5 463 ///
WiredHome 42:7cbdfd2bbfc5 464 RetCode_t _RenderBitmap(loc_t x, loc_t y, uint32_t fileOffset, FILE * Image);
WiredHome 42:7cbdfd2bbfc5 465
WiredHome 115:c9862fd0c689 466 private:
WiredHome 122:79e431f98fa9 467
WiredHome 122:79e431f98fa9 468 /// Analyze the jpeg data in preparation for decompression.
WiredHome 122:79e431f98fa9 469 ///
WiredHome 115:c9862fd0c689 470 JRESULT jd_prepare(JDEC * jd, uint16_t(* infunc)(JDEC * jd, uint8_t * buffer, uint16_t bufsize), void * pool, uint16_t poolsize, void * filehandle);
WiredHome 115:c9862fd0c689 471
WiredHome 122:79e431f98fa9 472 /// Decompress the jpeg and render it.
WiredHome 122:79e431f98fa9 473 ///
WiredHome 115:c9862fd0c689 474 JRESULT jd_decomp(JDEC * jd, uint16_t(* outfunct)(JDEC * jd, void * stream, JRECT * rect), uint8_t scale);
WiredHome 115:c9862fd0c689 475
WiredHome 122:79e431f98fa9 476 /// helper function to read data from the file system
WiredHome 122:79e431f98fa9 477 ///
WiredHome 115:c9862fd0c689 478 uint16_t privInFunc(JDEC * jd, uint8_t * buff, uint16_t ndata);
WiredHome 115:c9862fd0c689 479
WiredHome 122:79e431f98fa9 480 /// helper function to read data from the file system
WiredHome 122:79e431f98fa9 481 ///
WiredHome 115:c9862fd0c689 482 uint16_t getJpegData(JDEC * jd, uint8_t *buff, uint16_t ndata);
WiredHome 115:c9862fd0c689 483
WiredHome 122:79e431f98fa9 484 /// helper function to write data to the display
WiredHome 122:79e431f98fa9 485 ///
WiredHome 115:c9862fd0c689 486 uint16_t privOutFunc(JDEC * jd, void * bitmap, JRECT * rect);
WiredHome 115:c9862fd0c689 487
WiredHome 115:c9862fd0c689 488 JRESULT mcu_output (
WiredHome 115:c9862fd0c689 489 JDEC * jd, /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 490 uint16_t (* outfunc)(JDEC * jd, void * stream, JRECT * rect), /* RGB output function */
WiredHome 115:c9862fd0c689 491 uint16_t x, /* MCU position in the image (left of the MCU) */
WiredHome 115:c9862fd0c689 492 uint16_t y /* MCU position in the image (top of the MCU) */
WiredHome 115:c9862fd0c689 493 );
WiredHome 115:c9862fd0c689 494
WiredHome 115:c9862fd0c689 495 int16_t bitext ( /* >=0: extracted data, <0: error code */
WiredHome 115:c9862fd0c689 496 JDEC * jd, /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 497 uint16_t nbit /* Number of bits to extract (1 to 11) */
WiredHome 115:c9862fd0c689 498 );
WiredHome 115:c9862fd0c689 499
WiredHome 115:c9862fd0c689 500 int16_t huffext ( /* >=0: decoded data, <0: error code */
WiredHome 115:c9862fd0c689 501 JDEC * jd, /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 502 const uint8_t * hbits, /* Pointer to the bit distribution table */
WiredHome 115:c9862fd0c689 503 const uint16_t * hcode, /* Pointer to the code word table */
WiredHome 115:c9862fd0c689 504 const uint8_t * hdata /* Pointer to the data table */
WiredHome 115:c9862fd0c689 505 );
WiredHome 115:c9862fd0c689 506
WiredHome 115:c9862fd0c689 507 JRESULT restart (
WiredHome 115:c9862fd0c689 508 JDEC * jd, /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 509 uint16_t rstn /* Expected restert sequense number */
WiredHome 115:c9862fd0c689 510 );
WiredHome 115:c9862fd0c689 511
WiredHome 115:c9862fd0c689 512 JRESULT mcu_load (
WiredHome 115:c9862fd0c689 513 JDEC * jd /* Pointer to the decompressor object */
WiredHome 115:c9862fd0c689 514 );
WiredHome 115:c9862fd0c689 515
WiredHome 122:79e431f98fa9 516
WiredHome 115:c9862fd0c689 517 protected:
WiredHome 109:7b94f06f085b 518 /// Pure virtual method to write a boolean stream to the display.
WiredHome 109:7b94f06f085b 519 ///
WiredHome 109:7b94f06f085b 520 /// This takes a bit stream in memory and using the current color settings
WiredHome 109:7b94f06f085b 521 /// it will stream it to the display. Along the way, each bit is translated
WiredHome 109:7b94f06f085b 522 /// to either the foreground or background color value and then that pixel
WiredHome 109:7b94f06f085b 523 /// is pushed onward.
WiredHome 109:7b94f06f085b 524 ///
WiredHome 109:7b94f06f085b 525 /// This is similar, but different, to the @ref pixelStream API, which is
WiredHome 109:7b94f06f085b 526 /// given a stream of color values.
WiredHome 109:7b94f06f085b 527 ///
WiredHome 109:7b94f06f085b 528 /// @param[in] x is the horizontal position on the display.
WiredHome 109:7b94f06f085b 529 /// @param[in] y is the vertical position on the display.
WiredHome 109:7b94f06f085b 530 /// @param[in] w is the width of the rectangular region to fill.
WiredHome 109:7b94f06f085b 531 /// @param[in] h is the height of the rectangular region to fill.
WiredHome 109:7b94f06f085b 532 /// @param[in] boolStream is the inline memory image from which to extract
WiredHome 109:7b94f06f085b 533 /// the bitstream.
WiredHome 109:7b94f06f085b 534 /// @returns success/failure code. See @ref RetCode_t.
WiredHome 109:7b94f06f085b 535 ///
WiredHome 109:7b94f06f085b 536 virtual RetCode_t booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) = 0;
WiredHome 109:7b94f06f085b 537
WiredHome 109:7b94f06f085b 538
WiredHome 29:422616aa04bd 539 const unsigned char * font; ///< reference to an external font somewhere in memory
WiredHome 29:422616aa04bd 540
dreschpe 0:de9d1462a835 541 // pixel location
WiredHome 125:7a0b70f56550 542 short _x; ///< keeps track of current X location
WiredHome 125:7a0b70f56550 543 short _y; ///< keeps track of current Y location
dreschpe 0:de9d1462a835 544
WiredHome 111:efe436c43aba 545 rect_t windowrect; ///< window commands are held here for speed of access
dreschpe 0:de9d1462a835 546 };
dreschpe 0:de9d1462a835 547
dreschpe 0:de9d1462a835 548 #endif
WiredHome 33:b6b710758ab3 549