brw1

Dependencies:   mbed

Committer:
reiniermarcel
Date:
Mon Nov 30 11:13:18 2015 +0000
Revision:
0:a115ff47d1c1
ok

Who changed what in which revision?

UserRevisionLine numberNew contents of line
reiniermarcel 0:a115ff47d1c1 1 /* mbed GraphicsDisplay Display Library Base Class
reiniermarcel 0:a115ff47d1c1 2 * Copyright (c) 2007-2009 sford
reiniermarcel 0:a115ff47d1c1 3 * Released under the MIT License: http://mbed.org/license/mit
reiniermarcel 0:a115ff47d1c1 4 *
reiniermarcel 0:a115ff47d1c1 5 * A library for providing a common base class for Graphics displays
reiniermarcel 0:a115ff47d1c1 6 * To port a new display, derive from this class and implement
reiniermarcel 0:a115ff47d1c1 7 * the constructor (setup the display), pixel (put a pixel
reiniermarcel 0:a115ff47d1c1 8 * at a location), width and height functions. Everything else
reiniermarcel 0:a115ff47d1c1 9 * (locate, printf, putc, cls, window, putp, fill, blit, blitbit)
reiniermarcel 0:a115ff47d1c1 10 * will come for free. You can also provide a specialised implementation
reiniermarcel 0:a115ff47d1c1 11 * of window and putp to speed up the results
reiniermarcel 0:a115ff47d1c1 12 */
reiniermarcel 0:a115ff47d1c1 13
reiniermarcel 0:a115ff47d1c1 14 #ifndef MBED_GRAPHICSDISPLAY_H
reiniermarcel 0:a115ff47d1c1 15 #define MBED_GRAPHICSDISPLAY_H
reiniermarcel 0:a115ff47d1c1 16 #include "Bitmap.h"
reiniermarcel 0:a115ff47d1c1 17 #include "TextDisplay.h"
reiniermarcel 0:a115ff47d1c1 18
reiniermarcel 0:a115ff47d1c1 19 // GraphicsDisplay has one "soft font" which is in a different format
reiniermarcel 0:a115ff47d1c1 20 // then the primary font rendering api - see set_font(...). This is
reiniermarcel 0:a115ff47d1c1 21 // therefore deprecated, but preserved for a time for backward
reiniermarcel 0:a115ff47d1c1 22 // compatibility.
reiniermarcel 0:a115ff47d1c1 23 // #define LOCALFONT
reiniermarcel 0:a115ff47d1c1 24
reiniermarcel 0:a115ff47d1c1 25
reiniermarcel 0:a115ff47d1c1 26 /// The GraphicsDisplay class
reiniermarcel 0:a115ff47d1c1 27 ///
reiniermarcel 0:a115ff47d1c1 28 /// This graphics display class supports both graphics and text operations.
reiniermarcel 0:a115ff47d1c1 29 /// Typically, a subclass is derived from this which has localizations to
reiniermarcel 0:a115ff47d1c1 30 /// adapt to a specific hardware platform (e.g. a display controller chip),
reiniermarcel 0:a115ff47d1c1 31 /// that overrides methods in here to either add more capability or perhaps
reiniermarcel 0:a115ff47d1c1 32 /// to improve performance, by leveraging specific hardware capabilities.
reiniermarcel 0:a115ff47d1c1 33 ///
reiniermarcel 0:a115ff47d1c1 34 class GraphicsDisplay : public TextDisplay
reiniermarcel 0:a115ff47d1c1 35 {
reiniermarcel 0:a115ff47d1c1 36 public:
reiniermarcel 0:a115ff47d1c1 37 /// The constructor
reiniermarcel 0:a115ff47d1c1 38 GraphicsDisplay(const char* name);
reiniermarcel 0:a115ff47d1c1 39
reiniermarcel 0:a115ff47d1c1 40 /// Draw a pixel in the specified color.
reiniermarcel 0:a115ff47d1c1 41 ///
reiniermarcel 0:a115ff47d1c1 42 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 43 ///
reiniermarcel 0:a115ff47d1c1 44 /// @param[in] x is the horizontal offset to this pixel.
reiniermarcel 0:a115ff47d1c1 45 /// @param[in] y is the vertical offset to this pixel.
reiniermarcel 0:a115ff47d1c1 46 /// @param[in] color defines the color for the pixel.
reiniermarcel 0:a115ff47d1c1 47 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 48 ///
reiniermarcel 0:a115ff47d1c1 49 virtual RetCode_t pixel(loc_t x, loc_t y, color_t color) = 0;
reiniermarcel 0:a115ff47d1c1 50
reiniermarcel 0:a115ff47d1c1 51 /// Write a stream of pixels to the display.
reiniermarcel 0:a115ff47d1c1 52 ///
reiniermarcel 0:a115ff47d1c1 53 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 54 ///
reiniermarcel 0:a115ff47d1c1 55 /// @param[in] p is a pointer to a color_t array to write.
reiniermarcel 0:a115ff47d1c1 56 /// @param[in] count is the number of pixels to write.
reiniermarcel 0:a115ff47d1c1 57 /// @param[in] x is the horizontal position on the display.
reiniermarcel 0:a115ff47d1c1 58 /// @param[in] y is the vertical position on the display.
reiniermarcel 0:a115ff47d1c1 59 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 60 ///
reiniermarcel 0:a115ff47d1c1 61 virtual RetCode_t pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) = 0;
reiniermarcel 0:a115ff47d1c1 62
reiniermarcel 0:a115ff47d1c1 63 /// Get a pixel from the display.
reiniermarcel 0:a115ff47d1c1 64 ///
reiniermarcel 0:a115ff47d1c1 65 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 66 ///
reiniermarcel 0:a115ff47d1c1 67 /// @param[in] x is the horizontal offset to this pixel.
reiniermarcel 0:a115ff47d1c1 68 /// @param[in] y is the vertical offset to this pixel.
reiniermarcel 0:a115ff47d1c1 69 /// @returns the pixel. see @color_t
reiniermarcel 0:a115ff47d1c1 70 ///
reiniermarcel 0:a115ff47d1c1 71 virtual color_t getPixel(loc_t x, loc_t y) = 0;
reiniermarcel 0:a115ff47d1c1 72
reiniermarcel 0:a115ff47d1c1 73 /// Get a stream of pixels from the display.
reiniermarcel 0:a115ff47d1c1 74 ///
reiniermarcel 0:a115ff47d1c1 75 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 76 ///
reiniermarcel 0:a115ff47d1c1 77 /// @param[out] p is a pointer to a color_t array to accept the stream.
reiniermarcel 0:a115ff47d1c1 78 /// @param[in] count is the number of pixels to read.
reiniermarcel 0:a115ff47d1c1 79 /// @param[in] x is the horizontal offset to this pixel.
reiniermarcel 0:a115ff47d1c1 80 /// @param[in] y is the vertical offset to this pixel.
reiniermarcel 0:a115ff47d1c1 81 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 82 ///
reiniermarcel 0:a115ff47d1c1 83 virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y) = 0;
reiniermarcel 0:a115ff47d1c1 84
reiniermarcel 0:a115ff47d1c1 85 /// get the screen width in pixels
reiniermarcel 0:a115ff47d1c1 86 ///
reiniermarcel 0:a115ff47d1c1 87 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 88 ///
reiniermarcel 0:a115ff47d1c1 89 /// @returns screen width in pixels.
reiniermarcel 0:a115ff47d1c1 90 ///
reiniermarcel 0:a115ff47d1c1 91 virtual uint16_t width() = 0;
reiniermarcel 0:a115ff47d1c1 92
reiniermarcel 0:a115ff47d1c1 93 /// get the screen height in pixels
reiniermarcel 0:a115ff47d1c1 94 ///
reiniermarcel 0:a115ff47d1c1 95 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 96 ///
reiniermarcel 0:a115ff47d1c1 97 /// @returns screen height in pixels.
reiniermarcel 0:a115ff47d1c1 98 ///
reiniermarcel 0:a115ff47d1c1 99 virtual uint16_t height() = 0;
reiniermarcel 0:a115ff47d1c1 100
reiniermarcel 0:a115ff47d1c1 101 /// Prepare the controller to write binary data to the screen by positioning
reiniermarcel 0:a115ff47d1c1 102 /// the memory cursor.
reiniermarcel 0:a115ff47d1c1 103 ///
reiniermarcel 0:a115ff47d1c1 104 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 105 ///
reiniermarcel 0:a115ff47d1c1 106 /// @param[in] x is the horizontal position in pixels (from the left edge)
reiniermarcel 0:a115ff47d1c1 107 /// @param[in] y is the vertical position in pixels (from the top edge)
reiniermarcel 0:a115ff47d1c1 108 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 109 ///
reiniermarcel 0:a115ff47d1c1 110 virtual RetCode_t SetGraphicsCursor(loc_t x, loc_t y) = 0;
reiniermarcel 0:a115ff47d1c1 111
reiniermarcel 0:a115ff47d1c1 112 /// Prepare the controller to read binary data from the screen by positioning
reiniermarcel 0:a115ff47d1c1 113 /// the memory read cursor.
reiniermarcel 0:a115ff47d1c1 114 ///
reiniermarcel 0:a115ff47d1c1 115 /// @param[in] x is the horizontal position in pixels (from the left edge)
reiniermarcel 0:a115ff47d1c1 116 /// @param[in] y is the vertical position in pixels (from the top edge)
reiniermarcel 0:a115ff47d1c1 117 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 118 ///
reiniermarcel 0:a115ff47d1c1 119 virtual RetCode_t SetGraphicsCursorRead(loc_t x, loc_t y) = 0;
reiniermarcel 0:a115ff47d1c1 120
reiniermarcel 0:a115ff47d1c1 121 /// Draw a filled rectangle in the specified color
reiniermarcel 0:a115ff47d1c1 122 ///
reiniermarcel 0:a115ff47d1c1 123 /// @note As a side effect, this changes the current
reiniermarcel 0:a115ff47d1c1 124 /// foreground color for subsequent operations.
reiniermarcel 0:a115ff47d1c1 125 ///
reiniermarcel 0:a115ff47d1c1 126 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 127 ///
reiniermarcel 0:a115ff47d1c1 128 /// @param[in] x1 is the horizontal start of the line.
reiniermarcel 0:a115ff47d1c1 129 /// @param[in] y1 is the vertical start of the line.
reiniermarcel 0:a115ff47d1c1 130 /// @param[in] x2 is the horizontal end of the line.
reiniermarcel 0:a115ff47d1c1 131 /// @param[in] y2 is the vertical end of the line.
reiniermarcel 0:a115ff47d1c1 132 /// @param[in] color defines the foreground color.
reiniermarcel 0:a115ff47d1c1 133 /// @param[in] fillit is optional to NOFILL the rectangle. default is FILL.
reiniermarcel 0:a115ff47d1c1 134 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 135 ///
reiniermarcel 0:a115ff47d1c1 136 virtual RetCode_t fillrect(loc_t x1, loc_t y1, loc_t x2, loc_t y2,
reiniermarcel 0:a115ff47d1c1 137 color_t color, fill_t fillit = FILL) = 0;
reiniermarcel 0:a115ff47d1c1 138
reiniermarcel 0:a115ff47d1c1 139
reiniermarcel 0:a115ff47d1c1 140 virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF) = 0;
reiniermarcel 0:a115ff47d1c1 141 virtual RetCode_t WriteData(unsigned char data) = 0;
reiniermarcel 0:a115ff47d1c1 142
reiniermarcel 0:a115ff47d1c1 143 /// Set the window, which controls where items are written to the screen.
reiniermarcel 0:a115ff47d1c1 144 ///
reiniermarcel 0:a115ff47d1c1 145 /// When something hits the window width, it wraps back to the left side
reiniermarcel 0:a115ff47d1c1 146 /// and down a row. If the initial write is outside the window, it will
reiniermarcel 0:a115ff47d1c1 147 /// be captured into the window when it crosses a boundary.
reiniermarcel 0:a115ff47d1c1 148 ///
reiniermarcel 0:a115ff47d1c1 149 /// @param[in] x is the left edge in pixels.
reiniermarcel 0:a115ff47d1c1 150 /// @param[in] y is the top edge in pixels.
reiniermarcel 0:a115ff47d1c1 151 /// @param[in] w is the window width in pixels.
reiniermarcel 0:a115ff47d1c1 152 /// @param[in] h is the window height in pixels.
reiniermarcel 0:a115ff47d1c1 153 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 154 ///
reiniermarcel 0:a115ff47d1c1 155 virtual RetCode_t window(loc_t x, loc_t y, dim_t w, dim_t h);
reiniermarcel 0:a115ff47d1c1 156
reiniermarcel 0:a115ff47d1c1 157 /// Clear the screen.
reiniermarcel 0:a115ff47d1c1 158 ///
reiniermarcel 0:a115ff47d1c1 159 /// The behavior is to clear the whole screen.
reiniermarcel 0:a115ff47d1c1 160 ///
reiniermarcel 0:a115ff47d1c1 161 /// @param[in] layers is ignored, but supports maintaining the same
reiniermarcel 0:a115ff47d1c1 162 /// API for the graphics layer.
reiniermarcel 0:a115ff47d1c1 163 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 164 ///
reiniermarcel 0:a115ff47d1c1 165 virtual RetCode_t cls(uint16_t layers = 0);
reiniermarcel 0:a115ff47d1c1 166
reiniermarcel 0:a115ff47d1c1 167 /// method to set the window region to the full screen.
reiniermarcel 0:a115ff47d1c1 168 ///
reiniermarcel 0:a115ff47d1c1 169 /// This restores the 'window' to the full screen, so that
reiniermarcel 0:a115ff47d1c1 170 /// other operations (@see cls) would clear the whole screen.
reiniermarcel 0:a115ff47d1c1 171 ///
reiniermarcel 0:a115ff47d1c1 172 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 173 ///
reiniermarcel 0:a115ff47d1c1 174 virtual RetCode_t WindowMax(void);
reiniermarcel 0:a115ff47d1c1 175
reiniermarcel 0:a115ff47d1c1 176 /// method to put a single color pixel to the screen.
reiniermarcel 0:a115ff47d1c1 177 ///
reiniermarcel 0:a115ff47d1c1 178 /// This method may be called as many times as necessary after
reiniermarcel 0:a115ff47d1c1 179 /// @see _StartGraphicsStream() is called, and it should be followed
reiniermarcel 0:a115ff47d1c1 180 /// by _EndGraphicsStream.
reiniermarcel 0:a115ff47d1c1 181 ///
reiniermarcel 0:a115ff47d1c1 182 /// @param[in] pixel is a color value to be put on the screen.
reiniermarcel 0:a115ff47d1c1 183 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 184 ///
reiniermarcel 0:a115ff47d1c1 185 virtual RetCode_t _putp(color_t pixel);
reiniermarcel 0:a115ff47d1c1 186
reiniermarcel 0:a115ff47d1c1 187 /// method to fill a region.
reiniermarcel 0:a115ff47d1c1 188 ///
reiniermarcel 0:a115ff47d1c1 189 /// This method fills a region with the specified color.
reiniermarcel 0:a115ff47d1c1 190 ///
reiniermarcel 0:a115ff47d1c1 191 /// @param[in] x is the left-edge of the region.
reiniermarcel 0:a115ff47d1c1 192 /// @param[in] y is the top-edge of the region.
reiniermarcel 0:a115ff47d1c1 193 /// @param[in] w specifies the width of the region.
reiniermarcel 0:a115ff47d1c1 194 /// @param[in] h specifies the height of the region.
reiniermarcel 0:a115ff47d1c1 195 /// @returns success/failure code. @see RetCode_t.
reiniermarcel 0:a115ff47d1c1 196 ///
reiniermarcel 0:a115ff47d1c1 197 virtual RetCode_t fill(int x, int y, int w, int h, color_t color);
reiniermarcel 0:a115ff47d1c1 198
reiniermarcel 0:a115ff47d1c1 199
reiniermarcel 0:a115ff47d1c1 200 virtual RetCode_t blit(int x, int y, int w, int h, const int * color);
reiniermarcel 0:a115ff47d1c1 201
reiniermarcel 0:a115ff47d1c1 202 /// This method transfers one character from the external font data
reiniermarcel 0:a115ff47d1c1 203 /// to the screen.
reiniermarcel 0:a115ff47d1c1 204 ///
reiniermarcel 0:a115ff47d1c1 205 /// @note the font data is in a special format as generate by
reiniermarcel 0:a115ff47d1c1 206 /// the mikroe font creator. \\
reiniermarcel 0:a115ff47d1c1 207 /// See http://www.mikroe.com/glcd-font-creator/
reiniermarcel 0:a115ff47d1c1 208 ///
reiniermarcel 0:a115ff47d1c1 209 /// @param[in] x is the horizontal pixel coordinate
reiniermarcel 0:a115ff47d1c1 210 /// @param[in] y is the vertical pixel coordinate
reiniermarcel 0:a115ff47d1c1 211 /// @param[in] fontTable is the base of the table which has the metrics
reiniermarcel 0:a115ff47d1c1 212 /// @param[in] fontChar is the start of that record in the table for the char (e.g. 'A' - 'Z')
reiniermarcel 0:a115ff47d1c1 213 /// @returns how far the cursor should advance to the right in pixels
reiniermarcel 0:a115ff47d1c1 214 ///
reiniermarcel 0:a115ff47d1c1 215 virtual int fontblit(int x, int y, const unsigned char * fontTable, const unsigned char * fontChar);
reiniermarcel 0:a115ff47d1c1 216
reiniermarcel 0:a115ff47d1c1 217 /// This method returns the color value from a palette.
reiniermarcel 0:a115ff47d1c1 218 ///
reiniermarcel 0:a115ff47d1c1 219 /// This method accepts a pointer to a Bitmap color palette, which
reiniermarcel 0:a115ff47d1c1 220 /// is a table in memory composed of RGB Quad values (r, g, b, 0),
reiniermarcel 0:a115ff47d1c1 221 /// and an index into that table. It then extracts the color information
reiniermarcel 0:a115ff47d1c1 222 /// and downsamples it to a color_t value which it returns.
reiniermarcel 0:a115ff47d1c1 223 ///
reiniermarcel 0:a115ff47d1c1 224 /// @note This method probably has very little value outside of
reiniermarcel 0:a115ff47d1c1 225 /// the internal methods for reading BMP files.
reiniermarcel 0:a115ff47d1c1 226 ///
reiniermarcel 0:a115ff47d1c1 227 /// @param[in] colorPaletteArray is the handle to the color palette array to use.
reiniermarcel 0:a115ff47d1c1 228 /// @param[in] index is the index into the color palette.
reiniermarcel 0:a115ff47d1c1 229 /// @returns the color in color_t format.
reiniermarcel 0:a115ff47d1c1 230 ///
reiniermarcel 0:a115ff47d1c1 231 color_t RGBQuadToRGB16(RGBQUAD * colorPaletteArray, uint16_t index);
reiniermarcel 0:a115ff47d1c1 232
reiniermarcel 0:a115ff47d1c1 233 /// This method converts a 16-bit color value into a 24-bit RGB Quad.
reiniermarcel 0:a115ff47d1c1 234 ///
reiniermarcel 0:a115ff47d1c1 235 /// @param[in] c is the 16-bit color. @see color_t.
reiniermarcel 0:a115ff47d1c1 236 /// @returns an RGBQUAD value. @see RGBQUAD
reiniermarcel 0:a115ff47d1c1 237 ///
reiniermarcel 0:a115ff47d1c1 238 RGBQUAD RGB16ToRGBQuad(color_t c);
reiniermarcel 0:a115ff47d1c1 239
reiniermarcel 0:a115ff47d1c1 240 /// This method attempts to render a specified graphics image file at
reiniermarcel 0:a115ff47d1c1 241 /// the specified screen location.
reiniermarcel 0:a115ff47d1c1 242 ///
reiniermarcel 0:a115ff47d1c1 243 /// This supports several variants of the following file types:
reiniermarcel 0:a115ff47d1c1 244 /// \li Bitmap file format,
reiniermarcel 0:a115ff47d1c1 245 /// \li Icon file format.
reiniermarcel 0:a115ff47d1c1 246 ///
reiniermarcel 0:a115ff47d1c1 247 /// @note The specified image width and height, when adjusted for the
reiniermarcel 0:a115ff47d1c1 248 /// x and y origin, must fit on the screen, or the image will not
reiniermarcel 0:a115ff47d1c1 249 /// be shown (it does not clip the image).
reiniermarcel 0:a115ff47d1c1 250 ///
reiniermarcel 0:a115ff47d1c1 251 /// @note The file extension is tested, and if it ends in a supported
reiniermarcel 0:a115ff47d1c1 252 /// format, the appropriate handler is called to render that image.
reiniermarcel 0:a115ff47d1c1 253 ///
reiniermarcel 0:a115ff47d1c1 254 /// @param[in] x is the horizontal pixel coordinate
reiniermarcel 0:a115ff47d1c1 255 /// @param[in] y is the vertical pixel coordinate
reiniermarcel 0:a115ff47d1c1 256 /// @param[in] FileName refers to the fully qualified path and file on
reiniermarcel 0:a115ff47d1c1 257 /// a mounted file system.
reiniermarcel 0:a115ff47d1c1 258 /// @returns success or error code.
reiniermarcel 0:a115ff47d1c1 259 ///
reiniermarcel 0:a115ff47d1c1 260 RetCode_t RenderImageFile(loc_t x, loc_t y, const char *FileName);
reiniermarcel 0:a115ff47d1c1 261
reiniermarcel 0:a115ff47d1c1 262 /// This method reads a disk file that is in bitmap format and
reiniermarcel 0:a115ff47d1c1 263 /// puts it on the screen.
reiniermarcel 0:a115ff47d1c1 264 ///
reiniermarcel 0:a115ff47d1c1 265 /// Supported formats:
reiniermarcel 0:a115ff47d1c1 266 /// \li 4-bit color format (16 colors)
reiniermarcel 0:a115ff47d1c1 267 /// \li 8-bit color format (256 colors)
reiniermarcel 0:a115ff47d1c1 268 /// \li 16-bit color format (65k colors)
reiniermarcel 0:a115ff47d1c1 269 /// \li compression: no.
reiniermarcel 0:a115ff47d1c1 270 ///
reiniermarcel 0:a115ff47d1c1 271 /// @note This is a slow operation, typically due to the use of
reiniermarcel 0:a115ff47d1c1 272 /// the file system, and partially because bmp files
reiniermarcel 0:a115ff47d1c1 273 /// are stored from the bottom up, and the memory is written
reiniermarcel 0:a115ff47d1c1 274 /// from the top down; as a result, it constantly 'seeks'
reiniermarcel 0:a115ff47d1c1 275 /// on the file system for the next row of information.
reiniermarcel 0:a115ff47d1c1 276 ///
reiniermarcel 0:a115ff47d1c1 277 /// As a performance test, a sample picture was timed. A family picture
reiniermarcel 0:a115ff47d1c1 278 /// was converted to Bitmap format; shrunk to 352 x 272 pixels and save
reiniermarcel 0:a115ff47d1c1 279 /// in 8-bit color format. The resulting file size was 94.5 KByte.
reiniermarcel 0:a115ff47d1c1 280 /// The SPI port interface was set to 20 MHz.
reiniermarcel 0:a115ff47d1c1 281 /// The original bitmap rendering software was purely in software,
reiniermarcel 0:a115ff47d1c1 282 /// pushing 1 pixel at a time to the write function, which did use SPI
reiniermarcel 0:a115ff47d1c1 283 /// hardware (not pin wiggling) to transfer commands and data to the
reiniermarcel 0:a115ff47d1c1 284 /// display. Then, the driver was improved to leverage the capability
reiniermarcel 0:a115ff47d1c1 285 /// of the derived display driver. As a final check, instead of the
reiniermarcel 0:a115ff47d1c1 286 /// [known slow] local file system, a randomly chosen USB stick was
reiniermarcel 0:a115ff47d1c1 287 /// used. The performance results are impressive (but depend on the
reiniermarcel 0:a115ff47d1c1 288 /// listed factors).
reiniermarcel 0:a115ff47d1c1 289 ///
reiniermarcel 0:a115ff47d1c1 290 /// \li 34 seconds, LocalFileSystem, Software Rendering
reiniermarcel 0:a115ff47d1c1 291 /// \li 9 seconds, LocalFileSystem, Hardware Rending for RA8875
reiniermarcel 0:a115ff47d1c1 292 /// \li 3 seconds, MSCFileSystem, Hardware Rendering for RA8875
reiniermarcel 0:a115ff47d1c1 293 ///
reiniermarcel 0:a115ff47d1c1 294 /// @param[in] x is the horizontal pixel coordinate
reiniermarcel 0:a115ff47d1c1 295 /// @param[in] y is the vertical pixel coordinate
reiniermarcel 0:a115ff47d1c1 296 /// @param[in] Name_BMP is the filename on the mounted file system.
reiniermarcel 0:a115ff47d1c1 297 /// @returns success or error code.
reiniermarcel 0:a115ff47d1c1 298 ///
reiniermarcel 0:a115ff47d1c1 299 RetCode_t RenderBitmapFile(loc_t x, loc_t y, const char *Name_BMP);
reiniermarcel 0:a115ff47d1c1 300
reiniermarcel 0:a115ff47d1c1 301
reiniermarcel 0:a115ff47d1c1 302 /// This method reads a disk file that is in ico format and
reiniermarcel 0:a115ff47d1c1 303 /// puts it on the screen.
reiniermarcel 0:a115ff47d1c1 304 ///
reiniermarcel 0:a115ff47d1c1 305 /// Reading the disk is slow, but a typical icon file is small
reiniermarcel 0:a115ff47d1c1 306 /// so it should be ok.
reiniermarcel 0:a115ff47d1c1 307 ///
reiniermarcel 0:a115ff47d1c1 308 /// @note An Icon file can have more than one icon in it. This
reiniermarcel 0:a115ff47d1c1 309 /// implementation only processes the first image in the file.
reiniermarcel 0:a115ff47d1c1 310 ///
reiniermarcel 0:a115ff47d1c1 311 /// @param[in] x is the horizontal pixel coordinate
reiniermarcel 0:a115ff47d1c1 312 /// @param[in] y is the vertical pixel coordinate
reiniermarcel 0:a115ff47d1c1 313 /// @param[in] Name_ICO is the filename on the mounted file system.
reiniermarcel 0:a115ff47d1c1 314 /// @returns success or error code.
reiniermarcel 0:a115ff47d1c1 315 ///
reiniermarcel 0:a115ff47d1c1 316 RetCode_t RenderIconFile(loc_t x, loc_t y, const char *Name_ICO);
reiniermarcel 0:a115ff47d1c1 317
reiniermarcel 0:a115ff47d1c1 318
reiniermarcel 0:a115ff47d1c1 319 /// prints one character at the specified coordinates.
reiniermarcel 0:a115ff47d1c1 320 ///
reiniermarcel 0:a115ff47d1c1 321 /// This will print the character at the specified pixel coordinates.
reiniermarcel 0:a115ff47d1c1 322 ///
reiniermarcel 0:a115ff47d1c1 323 /// @param[in] x is the horizontal offset in pixels.
reiniermarcel 0:a115ff47d1c1 324 /// @param[in] y is the vertical offset in pixels.
reiniermarcel 0:a115ff47d1c1 325 /// @param[in] value is the character to print.
reiniermarcel 0:a115ff47d1c1 326 /// @returns number of pixels to index to the right if a character was printed, 0 otherwise.
reiniermarcel 0:a115ff47d1c1 327 ///
reiniermarcel 0:a115ff47d1c1 328 virtual int character(int x, int y, int value);
reiniermarcel 0:a115ff47d1c1 329
reiniermarcel 0:a115ff47d1c1 330 /// get the number of colums based on the currently active font
reiniermarcel 0:a115ff47d1c1 331 ///
reiniermarcel 0:a115ff47d1c1 332 /// @returns number of columns.
reiniermarcel 0:a115ff47d1c1 333 ///
reiniermarcel 0:a115ff47d1c1 334 virtual int columns(void);
reiniermarcel 0:a115ff47d1c1 335
reiniermarcel 0:a115ff47d1c1 336 /// get the number of rows based on the currently active font
reiniermarcel 0:a115ff47d1c1 337 ///
reiniermarcel 0:a115ff47d1c1 338 /// @returns number of rows.
reiniermarcel 0:a115ff47d1c1 339 ///
reiniermarcel 0:a115ff47d1c1 340 virtual int rows(void);
reiniermarcel 0:a115ff47d1c1 341
reiniermarcel 0:a115ff47d1c1 342 /// Select a bitmap font (provided by the user) for all subsequent text
reiniermarcel 0:a115ff47d1c1 343 /// rendering.
reiniermarcel 0:a115ff47d1c1 344 ///
reiniermarcel 0:a115ff47d1c1 345 /// This API permits selection of a special memory mapped font, which
reiniermarcel 0:a115ff47d1c1 346 /// enables the presentation of many font sizes and styles, including
reiniermarcel 0:a115ff47d1c1 347 /// proportional fonts.
reiniermarcel 0:a115ff47d1c1 348 ///
reiniermarcel 0:a115ff47d1c1 349 /// @note Tool to create the fonts is accessible from its creator
reiniermarcel 0:a115ff47d1c1 350 /// available at http://www.mikroe.com.
reiniermarcel 0:a115ff47d1c1 351 /// Hint: Change the data to an array of type char[].
reiniermarcel 0:a115ff47d1c1 352 ///
reiniermarcel 0:a115ff47d1c1 353 /// This special font array has a 4-byte header, followed by
reiniermarcel 0:a115ff47d1c1 354 /// the data:
reiniermarcel 0:a115ff47d1c1 355 /// \li the number of bytes per char
reiniermarcel 0:a115ff47d1c1 356 /// \li the vertical size in pixels for each character
reiniermarcel 0:a115ff47d1c1 357 /// \li the horizontal size in pixels for each character
reiniermarcel 0:a115ff47d1c1 358 /// \li the number of bytes per vertical line (width of the array)
reiniermarcel 0:a115ff47d1c1 359 /// \li the subsequent records are the font information.
reiniermarcel 0:a115ff47d1c1 360 ///
reiniermarcel 0:a115ff47d1c1 361 /// @param[in] font is a pointer to a specially formed font array.
reiniermarcel 0:a115ff47d1c1 362 /// NULL, or the omission of this parameter will restore the default
reiniermarcel 0:a115ff47d1c1 363 /// font capability, which may use the display controllers hardware
reiniermarcel 0:a115ff47d1c1 364 /// font (if available), or no font.
reiniermarcel 0:a115ff47d1c1 365 /// @returns error code.
reiniermarcel 0:a115ff47d1c1 366 ///
reiniermarcel 0:a115ff47d1c1 367 virtual RetCode_t set_font(const unsigned char * font = NULL);
reiniermarcel 0:a115ff47d1c1 368
reiniermarcel 0:a115ff47d1c1 369 protected:
reiniermarcel 0:a115ff47d1c1 370
reiniermarcel 0:a115ff47d1c1 371 /// Pure virtual method indicating the start of a graphics stream.
reiniermarcel 0:a115ff47d1c1 372 ///
reiniermarcel 0:a115ff47d1c1 373 /// This is called prior to a stream of pixel data being sent.
reiniermarcel 0:a115ff47d1c1 374 /// This may cause register configuration changes in the derived
reiniermarcel 0:a115ff47d1c1 375 /// class in order to prepare the hardware to accept the streaming
reiniermarcel 0:a115ff47d1c1 376 /// data.
reiniermarcel 0:a115ff47d1c1 377 ///
reiniermarcel 0:a115ff47d1c1 378 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 379 ///
reiniermarcel 0:a115ff47d1c1 380 /// @returns error code.
reiniermarcel 0:a115ff47d1c1 381 ///
reiniermarcel 0:a115ff47d1c1 382 virtual RetCode_t _StartGraphicsStream(void) = 0;
reiniermarcel 0:a115ff47d1c1 383
reiniermarcel 0:a115ff47d1c1 384 /// Pure virtual method indicating the end of a graphics stream.
reiniermarcel 0:a115ff47d1c1 385 ///
reiniermarcel 0:a115ff47d1c1 386 /// This is called to conclude a stream of pixel data that was sent.
reiniermarcel 0:a115ff47d1c1 387 /// This may cause register configuration changes in the derived
reiniermarcel 0:a115ff47d1c1 388 /// class in order to stop the hardware from accept the streaming
reiniermarcel 0:a115ff47d1c1 389 /// data.
reiniermarcel 0:a115ff47d1c1 390 ///
reiniermarcel 0:a115ff47d1c1 391 /// @note this method must be supported in the derived class.
reiniermarcel 0:a115ff47d1c1 392 ///
reiniermarcel 0:a115ff47d1c1 393 /// @returns error code.
reiniermarcel 0:a115ff47d1c1 394 ///
reiniermarcel 0:a115ff47d1c1 395 virtual RetCode_t _EndGraphicsStream(void) = 0;
reiniermarcel 0:a115ff47d1c1 396
reiniermarcel 0:a115ff47d1c1 397 /// Protected method to render an image given a file handle and
reiniermarcel 0:a115ff47d1c1 398 /// coordinates.
reiniermarcel 0:a115ff47d1c1 399 ///
reiniermarcel 0:a115ff47d1c1 400 /// @param[in] x is the horizontal pixel coordinate
reiniermarcel 0:a115ff47d1c1 401 /// @param[in] y is the vertical pixel coordinate
reiniermarcel 0:a115ff47d1c1 402 /// @param[in] w is the image width restriction, or zero to permit full image width.
reiniermarcel 0:a115ff47d1c1 403 /// @param[in] h is the image height restriction, or zero to permit full image height.
reiniermarcel 0:a115ff47d1c1 404 /// @param[in] fileOffset is the offset into the file where the image data starts
reiniermarcel 0:a115ff47d1c1 405 /// @param[in] Image is the filename stream already opened for the data.
reiniermarcel 0:a115ff47d1c1 406 /// @returns success or error code.
reiniermarcel 0:a115ff47d1c1 407 ///
reiniermarcel 0:a115ff47d1c1 408 RetCode_t _RenderBitmap(loc_t x, loc_t y, uint32_t fileOffset, FILE * Image);
reiniermarcel 0:a115ff47d1c1 409
reiniermarcel 0:a115ff47d1c1 410 #ifdef LOCALFONT
reiniermarcel 0:a115ff47d1c1 411 virtual int blitbit(int x, int y, int w, int h, const char * color);
reiniermarcel 0:a115ff47d1c1 412 #endif
reiniermarcel 0:a115ff47d1c1 413
reiniermarcel 0:a115ff47d1c1 414 const unsigned char * font; ///< reference to an external font somewhere in memory
reiniermarcel 0:a115ff47d1c1 415
reiniermarcel 0:a115ff47d1c1 416 // pixel location
reiniermarcel 0:a115ff47d1c1 417 short _x;
reiniermarcel 0:a115ff47d1c1 418 short _y;
reiniermarcel 0:a115ff47d1c1 419
reiniermarcel 0:a115ff47d1c1 420 // window location
reiniermarcel 0:a115ff47d1c1 421 short _x1;
reiniermarcel 0:a115ff47d1c1 422 short _x2;
reiniermarcel 0:a115ff47d1c1 423 short _y1;
reiniermarcel 0:a115ff47d1c1 424 short _y2;
reiniermarcel 0:a115ff47d1c1 425 };
reiniermarcel 0:a115ff47d1c1 426
reiniermarcel 0:a115ff47d1c1 427 #endif
reiniermarcel 0:a115ff47d1c1 428