Library release of Simon Ford's GraphicsDisplay Display Library Base Class.
Dependents: ese_project_copy ese_project_share Test_ColorMemLCD rIoTwear_LCD ... more
TextDisplay.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 TextDisplay 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 common base class for Text 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), character (put a character |
frankvnk | 0:282710e02ef4 | 8 | * at a location), rows and columns (number of rows/cols) functions. |
frankvnk | 0:282710e02ef4 | 9 | * Everything else (locate, printf, putc, cls) will come for free |
frankvnk | 0:282710e02ef4 | 10 | * |
frankvnk | 0:282710e02ef4 | 11 | * The model is the display will wrap at the right and bottom, so you can |
frankvnk | 0:282710e02ef4 | 12 | * keep writing and will always get valid characters. The location is |
frankvnk | 0:282710e02ef4 | 13 | * maintained internally to the class to make this easy |
frankvnk | 0:282710e02ef4 | 14 | */ |
frankvnk | 0:282710e02ef4 | 15 | |
frankvnk | 0:282710e02ef4 | 16 | #ifndef MBED_TEXTDISPLAY_H |
frankvnk | 0:282710e02ef4 | 17 | #define MBED_TEXTDISPLAY_H |
frankvnk | 0:282710e02ef4 | 18 | |
frankvnk | 0:282710e02ef4 | 19 | #include "mbed.h" |
frankvnk | 0:282710e02ef4 | 20 | |
frankvnk | 1:1cb0fcbce1bf | 21 | /** A common base class for Text displays |
frankvnk | 1:1cb0fcbce1bf | 22 | */ |
frankvnk | 0:282710e02ef4 | 23 | class TextDisplay : public Stream { |
frankvnk | 0:282710e02ef4 | 24 | public: |
frankvnk | 0:282710e02ef4 | 25 | |
frankvnk | 1:1cb0fcbce1bf | 26 | // functions needing implementation in derived implementation class |
frankvnk | 1:1cb0fcbce1bf | 27 | // ---------------------------------------------------------------- |
frankvnk | 1:1cb0fcbce1bf | 28 | /** Create a TextDisplay interface |
frankvnk | 1:1cb0fcbce1bf | 29 | * @param name The name used in the path to access the strean through the filesystem |
frankvnk | 1:1cb0fcbce1bf | 30 | */ |
frankvnk | 0:282710e02ef4 | 31 | TextDisplay(const char *name = NULL); |
frankvnk | 0:282710e02ef4 | 32 | |
frankvnk | 0:282710e02ef4 | 33 | /** output a character at the given position |
frankvnk | 1:1cb0fcbce1bf | 34 | * |
frankvnk | 1:1cb0fcbce1bf | 35 | * @param column column where charater must be written |
frankvnk | 1:1cb0fcbce1bf | 36 | * @param row where character must be written |
frankvnk | 1:1cb0fcbce1bf | 37 | * @param c the character to be written to the TextDisplay |
frankvnk | 1:1cb0fcbce1bf | 38 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 39 | */ |
frankvnk | 0:282710e02ef4 | 40 | virtual void character(int column, int row, int c) = 0; |
frankvnk | 0:282710e02ef4 | 41 | |
frankvnk | 1:1cb0fcbce1bf | 42 | /** return number of rows on TextDisplay |
frankvnk | 1:1cb0fcbce1bf | 43 | * @result number of rows |
frankvnk | 1:1cb0fcbce1bf | 44 | * @note this method must be supported in the derived class. |
frankvnk | 1:1cb0fcbce1bf | 45 | */ |
frankvnk | 0:282710e02ef4 | 46 | virtual int rows() = 0; |
frankvnk | 0:282710e02ef4 | 47 | |
frankvnk | 1:1cb0fcbce1bf | 48 | /** return number of columns on TextDisplay |
frankvnk | 1:1cb0fcbce1bf | 49 | * @result number of columns |
frankvnk | 1:1cb0fcbce1bf | 50 | * @note this method must be supported in the derived class. |
frankvnk | 0:282710e02ef4 | 51 | */ |
frankvnk | 0:282710e02ef4 | 52 | virtual int columns() = 0; |
frankvnk | 0:282710e02ef4 | 53 | |
frankvnk | 0:282710e02ef4 | 54 | // functions that come for free, but can be overwritten |
frankvnk | 1:1cb0fcbce1bf | 55 | // ---------------------------------------------------- |
frankvnk | 0:282710e02ef4 | 56 | /** redirect output from a stream (stoud, sterr) to display |
frankvnk | 0:282710e02ef4 | 57 | * @param stream stream that shall be redirected to the TextDisplay |
frankvnk | 1:1cb0fcbce1bf | 58 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 59 | * @returns true if the claim succeeded. |
frankvnk | 0:282710e02ef4 | 60 | */ |
frankvnk | 0:282710e02ef4 | 61 | virtual bool claim (FILE *stream); |
frankvnk | 0:282710e02ef4 | 62 | |
frankvnk | 1:1cb0fcbce1bf | 63 | /** clear the entire screen |
frankvnk | 1:1cb0fcbce1bf | 64 | * @note this method may be overridden in a derived class. |
frankvnk | 0:282710e02ef4 | 65 | */ |
frankvnk | 0:282710e02ef4 | 66 | virtual void cls(); |
frankvnk | 1:1cb0fcbce1bf | 67 | |
frankvnk | 1:1cb0fcbce1bf | 68 | /** locate the cursor at a character position. |
frankvnk | 1:1cb0fcbce1bf | 69 | * Based on the currently active font, locate the cursor on screen. |
frankvnk | 1:1cb0fcbce1bf | 70 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 71 | * @param column is the horizontal offset from the left side. |
frankvnk | 1:1cb0fcbce1bf | 72 | * @param row is the vertical offset from the top. |
frankvnk | 1:1cb0fcbce1bf | 73 | */ |
frankvnk | 0:282710e02ef4 | 74 | virtual void locate(int column, int row); |
frankvnk | 1:1cb0fcbce1bf | 75 | |
frankvnk | 1:1cb0fcbce1bf | 76 | /** set the foreground color |
frankvnk | 1:1cb0fcbce1bf | 77 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 78 | * @param color is color to use for foreground drawing. |
frankvnk | 1:1cb0fcbce1bf | 79 | */ |
frankvnk | 0:282710e02ef4 | 80 | virtual void foreground(uint16_t colour); |
frankvnk | 1:1cb0fcbce1bf | 81 | |
frankvnk | 1:1cb0fcbce1bf | 82 | /** set the background color |
frankvnk | 1:1cb0fcbce1bf | 83 | * @note this method may be overridden in a derived class. |
frankvnk | 1:1cb0fcbce1bf | 84 | * @param color is color to use for background drawing. |
frankvnk | 1:1cb0fcbce1bf | 85 | */ |
frankvnk | 0:282710e02ef4 | 86 | virtual void background(uint16_t colour); |
frankvnk | 1:1cb0fcbce1bf | 87 | |
frankvnk | 0:282710e02ef4 | 88 | // putc (from Stream) |
frankvnk | 0:282710e02ef4 | 89 | // printf (from Stream) |
frankvnk | 0:282710e02ef4 | 90 | |
frankvnk | 0:282710e02ef4 | 91 | protected: |
frankvnk | 0:282710e02ef4 | 92 | |
frankvnk | 0:282710e02ef4 | 93 | virtual int _putc(int value); |
frankvnk | 0:282710e02ef4 | 94 | virtual int _getc(); |
frankvnk | 0:282710e02ef4 | 95 | |
frankvnk | 0:282710e02ef4 | 96 | // character location |
frankvnk | 0:282710e02ef4 | 97 | uint16_t _column; |
frankvnk | 0:282710e02ef4 | 98 | uint16_t _row; |
frankvnk | 0:282710e02ef4 | 99 | |
frankvnk | 0:282710e02ef4 | 100 | // colours |
frankvnk | 0:282710e02ef4 | 101 | uint16_t _foreground; |
frankvnk | 0:282710e02ef4 | 102 | uint16_t _background; |
frankvnk | 0:282710e02ef4 | 103 | char *_path; |
frankvnk | 0:282710e02ef4 | 104 | }; |
frankvnk | 0:282710e02ef4 | 105 | |
frankvnk | 0:282710e02ef4 | 106 | #endif |