Forked para SNOCC
Fork of RA8875 by
TextDisplay.h@103:7e0464ca6c5c, 2016-02-07 (annotated)
- Committer:
- WiredHome
- Date:
- Sun Feb 07 23:18:01 2016 +0000
- Revision:
- 103:7e0464ca6c5c
- Parent:
- 76:c981284eb513
- Child:
- 104:8d1d3832a215
Added missing APIs for Get/SetTextCursor using point_t.; Fixed a defect in touch; if no point was requested, just polling for touch-state, it would return the no calibration value during a touch.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dreschpe | 0:de9d1462a835 | 1 | /* mbed TextDisplay 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 common base class for Text 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), character (put a character |
dreschpe | 0:de9d1462a835 | 8 | * at a location), rows and columns (number of rows/cols) functions. |
dreschpe | 0:de9d1462a835 | 9 | * Everything else (locate, printf, putc, cls) will come for free |
dreschpe | 0:de9d1462a835 | 10 | * |
dreschpe | 0:de9d1462a835 | 11 | * The model is the display will wrap at the right and bottom, so you can |
WiredHome | 19:3f82c1161fd2 | 12 | * keep writing and will always get valid characters. The location is |
dreschpe | 0:de9d1462a835 | 13 | * maintained internally to the class to make this easy |
dreschpe | 0:de9d1462a835 | 14 | */ |
dreschpe | 0:de9d1462a835 | 15 | |
dreschpe | 0:de9d1462a835 | 16 | #ifndef MBED_TEXTDISPLAY_H |
dreschpe | 0:de9d1462a835 | 17 | #define MBED_TEXTDISPLAY_H |
dreschpe | 0:de9d1462a835 | 18 | |
dreschpe | 0:de9d1462a835 | 19 | #include "mbed.h" |
dreschpe | 0:de9d1462a835 | 20 | |
WiredHome | 31:c72e12cd5c67 | 21 | #include "DisplayDefs.h" |
WiredHome | 19:3f82c1161fd2 | 22 | |
WiredHome | 37:f19b7e7449dc | 23 | /// A text display class that supports character based |
WiredHome | 37:f19b7e7449dc | 24 | /// presentation. |
WiredHome | 37:f19b7e7449dc | 25 | /// |
WiredHome | 19:3f82c1161fd2 | 26 | class TextDisplay : public Stream |
WiredHome | 19:3f82c1161fd2 | 27 | { |
dreschpe | 0:de9d1462a835 | 28 | public: |
dreschpe | 0:de9d1462a835 | 29 | |
WiredHome | 19:3f82c1161fd2 | 30 | // functions needing implementation in derived implementation class |
WiredHome | 37:f19b7e7449dc | 31 | /// Create a TextDisplay interface |
WiredHome | 37:f19b7e7449dc | 32 | /// |
WiredHome | 37:f19b7e7449dc | 33 | /// @param name The name used in the path to access the display through |
WiredHome | 37:f19b7e7449dc | 34 | /// the stdio stream. |
WiredHome | 37:f19b7e7449dc | 35 | /// |
dreschpe | 0:de9d1462a835 | 36 | TextDisplay(const char *name = NULL); |
dreschpe | 0:de9d1462a835 | 37 | |
WiredHome | 103:7e0464ca6c5c | 38 | /// destructor to clean up |
WiredHome | 103:7e0464ca6c5c | 39 | /// |
WiredHome | 103:7e0464ca6c5c | 40 | ~TextDisplay(); |
WiredHome | 103:7e0464ca6c5c | 41 | |
WiredHome | 37:f19b7e7449dc | 42 | /// output a character at the given position |
WiredHome | 37:f19b7e7449dc | 43 | /// |
WiredHome | 37:f19b7e7449dc | 44 | /// @note this method may be overridden in a derived class. |
WiredHome | 37:f19b7e7449dc | 45 | /// |
WiredHome | 76:c981284eb513 | 46 | /// @param[in] x position in pixels |
WiredHome | 76:c981284eb513 | 47 | /// @param[in] y position in pixels |
WiredHome | 76:c981284eb513 | 48 | /// @param[in] c the character to be written to the TextDisplay |
WiredHome | 37:f19b7e7449dc | 49 | /// @returns number of pixels to advance the cursor which could be the cell width |
WiredHome | 37:f19b7e7449dc | 50 | /// for non-proportional characters, or the actual character width for |
WiredHome | 37:f19b7e7449dc | 51 | /// proportional characters. |
WiredHome | 37:f19b7e7449dc | 52 | /// |
WiredHome | 29:422616aa04bd | 53 | virtual int character(int x, int y, int c) = 0; |
dreschpe | 0:de9d1462a835 | 54 | |
WiredHome | 37:f19b7e7449dc | 55 | /// return number of rows on TextDisplay |
WiredHome | 37:f19b7e7449dc | 56 | /// |
WiredHome | 37:f19b7e7449dc | 57 | /// @note this method may be overridden in a derived class. |
WiredHome | 37:f19b7e7449dc | 58 | /// |
WiredHome | 37:f19b7e7449dc | 59 | /// @returns number of text rows for the display for the currently |
WiredHome | 37:f19b7e7449dc | 60 | /// active font. |
WiredHome | 37:f19b7e7449dc | 61 | /// |
dreschpe | 0:de9d1462a835 | 62 | virtual int rows() = 0; |
dreschpe | 0:de9d1462a835 | 63 | |
WiredHome | 37:f19b7e7449dc | 64 | /// return number if columns on TextDisplay |
WiredHome | 37:f19b7e7449dc | 65 | /// |
WiredHome | 37:f19b7e7449dc | 66 | /// @note this method may be overridden in a derived class. |
WiredHome | 37:f19b7e7449dc | 67 | /// |
WiredHome | 37:f19b7e7449dc | 68 | /// @returns number of text rows for the display for the currently |
WiredHome | 37:f19b7e7449dc | 69 | /// active font. |
WiredHome | 37:f19b7e7449dc | 70 | /// |
dreschpe | 0:de9d1462a835 | 71 | virtual int columns() = 0; |
WiredHome | 19:3f82c1161fd2 | 72 | |
dreschpe | 0:de9d1462a835 | 73 | // functions that come for free, but can be overwritten |
dreschpe | 0:de9d1462a835 | 74 | |
WiredHome | 37:f19b7e7449dc | 75 | /// redirect output from a stream (stoud, sterr) to display |
WiredHome | 37:f19b7e7449dc | 76 | /// |
WiredHome | 37:f19b7e7449dc | 77 | /// @note this method may be overridden in a derived class. |
WiredHome | 37:f19b7e7449dc | 78 | /// |
WiredHome | 76:c981284eb513 | 79 | /// @param[in] stream that shall be redirected to the TextDisplay |
WiredHome | 37:f19b7e7449dc | 80 | /// @returns true if the claim succeeded. |
WiredHome | 37:f19b7e7449dc | 81 | /// |
dreschpe | 0:de9d1462a835 | 82 | virtual bool claim (FILE *stream); |
dreschpe | 0:de9d1462a835 | 83 | |
WiredHome | 37:f19b7e7449dc | 84 | /// clear screen |
WiredHome | 37:f19b7e7449dc | 85 | /// |
WiredHome | 37:f19b7e7449dc | 86 | /// @note this method may be overridden in a derived class. |
WiredHome | 76:c981284eb513 | 87 | /// |
WiredHome | 76:c981284eb513 | 88 | /// @param[in] layers is ignored, but supports maintaining the same |
WiredHome | 61:8f3153bf0baa | 89 | /// API for the graphics layer. |
WiredHome | 37:f19b7e7449dc | 90 | /// @returns error code. |
WiredHome | 37:f19b7e7449dc | 91 | /// |
WiredHome | 61:8f3153bf0baa | 92 | virtual RetCode_t cls(uint16_t layers = 0) = 0; |
WiredHome | 37:f19b7e7449dc | 93 | |
WiredHome | 37:f19b7e7449dc | 94 | /// locate the cursor at a character position. |
WiredHome | 37:f19b7e7449dc | 95 | /// |
WiredHome | 37:f19b7e7449dc | 96 | /// Based on the currently active font, locate the cursor on screen. |
WiredHome | 37:f19b7e7449dc | 97 | /// |
WiredHome | 37:f19b7e7449dc | 98 | /// @note this method may be overridden in a derived class. |
WiredHome | 37:f19b7e7449dc | 99 | /// |
WiredHome | 76:c981284eb513 | 100 | /// @param[in] column is the horizontal offset from the left side. |
WiredHome | 76:c981284eb513 | 101 | /// @param[in] row is the vertical offset from the top. |
WiredHome | 37:f19b7e7449dc | 102 | /// @returns error code. |
WiredHome | 37:f19b7e7449dc | 103 | /// |
WiredHome | 37:f19b7e7449dc | 104 | virtual RetCode_t locate(textloc_t column, textloc_t row) = 0; |
WiredHome | 37:f19b7e7449dc | 105 | |
WiredHome | 37:f19b7e7449dc | 106 | /// set the foreground color |
WiredHome | 37:f19b7e7449dc | 107 | /// |
WiredHome | 37:f19b7e7449dc | 108 | /// @note this method may be overridden in a derived class. |
WiredHome | 37:f19b7e7449dc | 109 | /// |
WiredHome | 76:c981284eb513 | 110 | /// @param[in] color is color to use for foreground drawing. |
WiredHome | 37:f19b7e7449dc | 111 | /// @returns error code. |
WiredHome | 37:f19b7e7449dc | 112 | /// |
WiredHome | 37:f19b7e7449dc | 113 | virtual RetCode_t foreground(color_t color) = 0; |
WiredHome | 37:f19b7e7449dc | 114 | |
WiredHome | 37:f19b7e7449dc | 115 | /// set the background color |
WiredHome | 37:f19b7e7449dc | 116 | /// |
WiredHome | 37:f19b7e7449dc | 117 | /// @note this method may be overridden in a derived class. |
WiredHome | 37:f19b7e7449dc | 118 | /// |
WiredHome | 76:c981284eb513 | 119 | /// @param[in] color is color to use for background drawing. |
WiredHome | 37:f19b7e7449dc | 120 | /// @returns error code. |
WiredHome | 37:f19b7e7449dc | 121 | /// |
WiredHome | 37:f19b7e7449dc | 122 | virtual RetCode_t background(color_t color) = 0; |
dreschpe | 0:de9d1462a835 | 123 | // putc (from Stream) |
dreschpe | 0:de9d1462a835 | 124 | // printf (from Stream) |
dreschpe | 0:de9d1462a835 | 125 | |
WiredHome | 19:3f82c1161fd2 | 126 | protected: |
dreschpe | 0:de9d1462a835 | 127 | virtual int _putc(int value); |
dreschpe | 0:de9d1462a835 | 128 | virtual int _getc(); |
dreschpe | 0:de9d1462a835 | 129 | |
dreschpe | 0:de9d1462a835 | 130 | // character location |
dreschpe | 0:de9d1462a835 | 131 | uint16_t _column; |
dreschpe | 0:de9d1462a835 | 132 | uint16_t _row; |
dreschpe | 0:de9d1462a835 | 133 | |
WiredHome | 33:b6b710758ab3 | 134 | // colors |
WiredHome | 37:f19b7e7449dc | 135 | color_t _foreground; |
WiredHome | 37:f19b7e7449dc | 136 | color_t _background; |
dreschpe | 0:de9d1462a835 | 137 | char *_path; |
dreschpe | 0:de9d1462a835 | 138 | }; |
dreschpe | 0:de9d1462a835 | 139 | |
dreschpe | 0:de9d1462a835 | 140 | #endif |