Library release of Simon Ford's GraphicsDisplay Display Library Base Class.
Dependents: ese_project_copy ese_project_share Test_ColorMemLCD rIoTwear_LCD ... more
GraphicsDisplay.h@1:1cb0fcbce1bf, 2015-01-23 (annotated)
- Committer:
- frankvnk
- Date:
- Fri Jan 23 20:21:32 2015 +0000
- Revision:
- 1:1cb0fcbce1bf
- Parent:
- 0:282710e02ef4
Added documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frankvnk | 0:282710e02ef4 | 1 | /* mbed GraphicsDisplay Display Library Base Class |
frankvnk | 0:282710e02ef4 | 2 | * Copyright (c) 2007-2009 sford |
frankvnk | 0:282710e02ef4 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
frankvnk | 0:282710e02ef4 | 4 | * |
frankvnk | 0:282710e02ef4 | 5 | * A library for providing a common base class for Graphics displays |
frankvnk | 0:282710e02ef4 | 6 | * To port a new display, derive from this class and implement |
frankvnk | 0:282710e02ef4 | 7 | * the constructor (setup the display), pixel (put a pixel |
frankvnk | 0:282710e02ef4 | 8 | * at a location), width and height functions. Everything else |
frankvnk | 0:282710e02ef4 | 9 | * (locate, printf, putc, cls, window, putp, fill, blit, blitbit) |
frankvnk | 0:282710e02ef4 | 10 | * will come for free. You can also provide a specialised implementation |
frankvnk | 0:282710e02ef4 | 11 | * of window and putp to speed up the results |
frankvnk | 0:282710e02ef4 | 12 | */ |
frankvnk | 0:282710e02ef4 | 13 | |
frankvnk | 0:282710e02ef4 | 14 | #ifndef MBED_GRAPHICSDISPLAY_H |
frankvnk | 0:282710e02ef4 | 15 | #define MBED_GRAPHICSDISPLAY_H |
frankvnk | 0:282710e02ef4 | 16 | |
frankvnk | 0:282710e02ef4 | 17 | #include "TextDisplay.h" |
frankvnk | 0:282710e02ef4 | 18 | |
frankvnk | 1:1cb0fcbce1bf | 19 | /** A common base class for Graphics displays |
frankvnk | 1:1cb0fcbce1bf | 20 | */ |
frankvnk | 0:282710e02ef4 | 21 | class GraphicsDisplay : public TextDisplay { |
frankvnk | 0:282710e02ef4 | 22 | |
frankvnk | 0:282710e02ef4 | 23 | public: |
frankvnk | 0:282710e02ef4 | 24 | |
frankvnk | 1:1cb0fcbce1bf | 25 | /** Create a GraphicsDisplay interface |
frankvnk | 1:1cb0fcbce1bf | 26 | * @param name The name used by the parent class to access the interface |
frankvnk | 1:1cb0fcbce1bf | 27 | */ |
frankvnk | 0:282710e02ef4 | 28 | GraphicsDisplay(const char* name); |
frankvnk | 0:282710e02ef4 | 29 | |
frankvnk | 1:1cb0fcbce1bf | 30 | // functions needing implementation in derived implementation class |
frankvnk | 1:1cb0fcbce1bf | 31 | // ---------------------------------------------------------------- |
frankvnk | 1:1cb0fcbce1bf | 32 | /** Draw a pixel in the specified color. |
frankvnk | 1:1cb0fcbce1bf | 33 | * @note this method must be supported in the derived class. |
frankvnk | 1:1cb0fcbce1bf | 34 | * @param x is the horizontal offset to this pixel. |
frankvnk | 1:1cb0fcbce1bf | 35 | * @param y is the vertical offset to this pixel. |
frankvnk | 1:1cb0fcbce1bf | 36 | * @param colour defines the color for the pixel. |
frankvnk | 1:1cb0fcbce1bf | 37 | */ |
frankvnk | 0:282710e02ef4 | 38 | virtual void pixel(int x, int y, int colour) = 0; |
frankvnk | 1:1cb0fcbce1bf | 39 | |
frankvnk | 1:1cb0fcbce1bf | 40 | /** get the screen width in pixels |
frankvnk | 1:1cb0fcbce1bf | 41 | * @note this method must be supported in the derived class. |
frankvnk | 1:1cb0fcbce1bf | 42 | * @returns screen width in pixels. |
frankvnk | 1:1cb0fcbce1bf | 43 | */ |
frankvnk | 0:282710e02ef4 | 44 | virtual int width() = 0; |
frankvnk | 1:1cb0fcbce1bf | 45 | |
frankvnk | 1:1cb0fcbce1bf | 46 | /** get the screen height in pixels |
frankvnk | 1:1cb0fcbce1bf | 47 | * @note this method must be supported in the derived class. |
frankvnk | 1:1cb0fcbce1bf | 48 | * @returns screen height in pixels. |
frankvnk | 1:1cb0fcbce1bf | 49 | */ |
frankvnk | 0:282710e02ef4 | 50 | virtual int height() = 0; |
frankvnk | 0:282710e02ef4 | 51 | |
frankvnk | 1:1cb0fcbce1bf | 52 | // functions that come for free, but can be overwritten |
frankvnk | 1:1cb0fcbce1bf | 53 | // ---------------------------------------------------- |
frankvnk | 1:1cb0fcbce1bf | 54 | /** Set the window, which controls where items are written to the screen. |
frankvnk | 1:1cb0fcbce1bf | 55 | * When something hits the window width, it wraps back to the left side |
frankvnk | 1:1cb0fcbce1bf | 56 | * and down a row. If the initial write is outside the window, it will |
frankvnk | 1:1cb0fcbce1bf | 57 | * be captured into the window when it crosses a boundary. |
frankvnk | 1:1cb0fcbce1bf | 58 | * @param x is the left edge in pixels. |
frankvnk | 1:1cb0fcbce1bf | 59 | * @param y is the top edge in pixels. |
frankvnk | 1:1cb0fcbce1bf | 60 | * @param w is the window width in pixels. |
frankvnk | 1:1cb0fcbce1bf | 61 | * @param h is the window height in pixels. |
frankvnk | 1:1cb0fcbce1bf | 62 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 63 | */ |
frankvnk | 0:282710e02ef4 | 64 | virtual void window(int x, int y, int w, int h); |
frankvnk | 1:1cb0fcbce1bf | 65 | |
frankvnk | 1:1cb0fcbce1bf | 66 | /** Put a single pixel at the current pixel location |
frankvnk | 1:1cb0fcbce1bf | 67 | * and update the pixel location based on window settings. |
frankvnk | 1:1cb0fcbce1bf | 68 | * @param colour is the pixel colour. |
frankvnk | 1:1cb0fcbce1bf | 69 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 70 | */ |
frankvnk | 0:282710e02ef4 | 71 | virtual void putp(int colour); |
frankvnk | 0:282710e02ef4 | 72 | |
frankvnk | 1:1cb0fcbce1bf | 73 | /** clear the entire screen |
frankvnk | 1:1cb0fcbce1bf | 74 | */ |
frankvnk | 0:282710e02ef4 | 75 | virtual void cls(); |
frankvnk | 1:1cb0fcbce1bf | 76 | |
frankvnk | 1:1cb0fcbce1bf | 77 | /** Fill a region using a single colour. |
frankvnk | 1:1cb0fcbce1bf | 78 | * @param x is the left-edge of the region. |
frankvnk | 1:1cb0fcbce1bf | 79 | * @param y is the top-edge of the region. |
frankvnk | 1:1cb0fcbce1bf | 80 | * @param w specifies the width of the region. |
frankvnk | 1:1cb0fcbce1bf | 81 | * @param h specifies the height of the region. |
frankvnk | 1:1cb0fcbce1bf | 82 | * @param colour is the fill colour. |
frankvnk | 1:1cb0fcbce1bf | 83 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 84 | */ |
frankvnk | 0:282710e02ef4 | 85 | virtual void fill(int x, int y, int w, int h, int colour); |
frankvnk | 1:1cb0fcbce1bf | 86 | |
frankvnk | 1:1cb0fcbce1bf | 87 | /** Fill a region using an array. |
frankvnk | 1:1cb0fcbce1bf | 88 | * @param x is the left-edge of the region. |
frankvnk | 1:1cb0fcbce1bf | 89 | * @param y is the top-edge of the region. |
frankvnk | 1:1cb0fcbce1bf | 90 | * @param w specifies the width of the region. |
frankvnk | 1:1cb0fcbce1bf | 91 | * @param h specifies the height of the region. |
frankvnk | 1:1cb0fcbce1bf | 92 | * @param colour is a pointer to the array with size = w * h. |
frankvnk | 1:1cb0fcbce1bf | 93 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 94 | */ |
frankvnk | 0:282710e02ef4 | 95 | virtual void blit(int x, int y, int w, int h, const int *colour); |
frankvnk | 1:1cb0fcbce1bf | 96 | |
frankvnk | 1:1cb0fcbce1bf | 97 | /** Fill a region using a font array. |
frankvnk | 1:1cb0fcbce1bf | 98 | * @param x is the left-edge of the region. |
frankvnk | 1:1cb0fcbce1bf | 99 | * @param y is the top-edge of the region. |
frankvnk | 1:1cb0fcbce1bf | 100 | * @param w specifies the width of the region. |
frankvnk | 1:1cb0fcbce1bf | 101 | * @param h specifies the height of the region. |
frankvnk | 1:1cb0fcbce1bf | 102 | * @param colour is a pointer to the font array. |
frankvnk | 1:1cb0fcbce1bf | 103 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 104 | */ |
frankvnk | 0:282710e02ef4 | 105 | virtual void blitbit(int x, int y, int w, int h, const char* colour); |
frankvnk | 0:282710e02ef4 | 106 | |
frankvnk | 1:1cb0fcbce1bf | 107 | /** Print one character at the specified row, column. |
frankvnk | 1:1cb0fcbce1bf | 108 | * @param column is the horizontal character position. |
frankvnk | 1:1cb0fcbce1bf | 109 | * @param row is the vertical character position. |
frankvnk | 1:1cb0fcbce1bf | 110 | * @param value is the character to print. |
frankvnk | 1:1cb0fcbce1bf | 111 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 112 | */ |
frankvnk | 0:282710e02ef4 | 113 | virtual void character(int column, int row, int value); |
frankvnk | 1:1cb0fcbce1bf | 114 | |
frankvnk | 1:1cb0fcbce1bf | 115 | /** Get the number of columns based on the currently active font. |
frankvnk | 1:1cb0fcbce1bf | 116 | * @returns number of columns. |
frankvnk | 1:1cb0fcbce1bf | 117 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 118 | */ |
frankvnk | 0:282710e02ef4 | 119 | virtual int columns(); |
frankvnk | 1:1cb0fcbce1bf | 120 | |
frankvnk | 1:1cb0fcbce1bf | 121 | /** Get the number of rows based on the currently active font. |
frankvnk | 1:1cb0fcbce1bf | 122 | * @returns number of rows. |
frankvnk | 1:1cb0fcbce1bf | 123 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 124 | */ |
frankvnk | 0:282710e02ef4 | 125 | virtual int rows(); |
frankvnk | 0:282710e02ef4 | 126 | |
frankvnk | 0:282710e02ef4 | 127 | protected: |
frankvnk | 0:282710e02ef4 | 128 | |
frankvnk | 0:282710e02ef4 | 129 | // pixel location |
frankvnk | 0:282710e02ef4 | 130 | short _x; |
frankvnk | 0:282710e02ef4 | 131 | short _y; |
frankvnk | 0:282710e02ef4 | 132 | |
frankvnk | 0:282710e02ef4 | 133 | // window location |
frankvnk | 0:282710e02ef4 | 134 | short _x1; |
frankvnk | 0:282710e02ef4 | 135 | short _x2; |
frankvnk | 0:282710e02ef4 | 136 | short _y1; |
frankvnk | 0:282710e02ef4 | 137 | short _y2; |
frankvnk | 0:282710e02ef4 | 138 | |
frankvnk | 0:282710e02ef4 | 139 | }; |
frankvnk | 0:282710e02ef4 | 140 | |
frankvnk | 0:282710e02ef4 | 141 | #endif |