Forked para SNOCC
Fork of RA8875 by
TextDisplay.h@33:b6b710758ab3, 2014-01-22 (annotated)
- Committer:
- WiredHome
- Date:
- Wed Jan 22 03:50:55 2014 +0000
- Revision:
- 33:b6b710758ab3
- Parent:
- 31:c72e12cd5c67
- Child:
- 37:f19b7e7449dc
Documentation fixes after running doxygen externally.
; And migrated colour to color.
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 | 19:3f82c1161fd2 | 23 | class TextDisplay : public Stream |
WiredHome | 19:3f82c1161fd2 | 24 | { |
dreschpe | 0:de9d1462a835 | 25 | public: |
dreschpe | 0:de9d1462a835 | 26 | |
WiredHome | 19:3f82c1161fd2 | 27 | // functions needing implementation in derived implementation class |
WiredHome | 19:3f82c1161fd2 | 28 | /** Create a TextDisplay interface |
WiredHome | 19:3f82c1161fd2 | 29 | * |
WiredHome | 19:3f82c1161fd2 | 30 | * @param name The name used in the path to access the strean through the filesystem |
WiredHome | 19:3f82c1161fd2 | 31 | */ |
dreschpe | 0:de9d1462a835 | 32 | TextDisplay(const char *name = NULL); |
dreschpe | 0:de9d1462a835 | 33 | |
dreschpe | 0:de9d1462a835 | 34 | /** output a character at the given position |
dreschpe | 0:de9d1462a835 | 35 | * |
WiredHome | 29:422616aa04bd | 36 | * @param x position in pixels |
WiredHome | 29:422616aa04bd | 37 | * @param y position in pixels |
dreschpe | 0:de9d1462a835 | 38 | * @param c the character to be written to the TextDisplay |
WiredHome | 29:422616aa04bd | 39 | * @returns number of pixels to advance the cursor. |
dreschpe | 0:de9d1462a835 | 40 | */ |
WiredHome | 29:422616aa04bd | 41 | virtual int character(int x, int y, int c) = 0; |
dreschpe | 0:de9d1462a835 | 42 | |
dreschpe | 0:de9d1462a835 | 43 | /** return number if rows on TextDisplay |
dreschpe | 0:de9d1462a835 | 44 | * @result number of rows |
dreschpe | 0:de9d1462a835 | 45 | */ |
dreschpe | 0:de9d1462a835 | 46 | virtual int rows() = 0; |
dreschpe | 0:de9d1462a835 | 47 | |
dreschpe | 0:de9d1462a835 | 48 | /** return number if columns on TextDisplay |
dreschpe | 0:de9d1462a835 | 49 | * @result number of rows |
dreschpe | 0:de9d1462a835 | 50 | */ |
dreschpe | 0:de9d1462a835 | 51 | virtual int columns() = 0; |
WiredHome | 19:3f82c1161fd2 | 52 | |
dreschpe | 0:de9d1462a835 | 53 | // functions that come for free, but can be overwritten |
dreschpe | 0:de9d1462a835 | 54 | |
dreschpe | 0:de9d1462a835 | 55 | /** redirect output from a stream (stoud, sterr) to display |
dreschpe | 0:de9d1462a835 | 56 | * @param stream stream that shall be redirected to the TextDisplay |
dreschpe | 0:de9d1462a835 | 57 | */ |
dreschpe | 0:de9d1462a835 | 58 | virtual bool claim (FILE *stream); |
dreschpe | 0:de9d1462a835 | 59 | |
dreschpe | 0:de9d1462a835 | 60 | /** clear screen |
dreschpe | 0:de9d1462a835 | 61 | */ |
WiredHome | 29:422616aa04bd | 62 | virtual RetCode_t cls() = 0; |
WiredHome | 19:3f82c1161fd2 | 63 | virtual RetCode_t locate(unsigned int column, unsigned int row) = 0; |
WiredHome | 33:b6b710758ab3 | 64 | virtual RetCode_t foreground(uint16_t color) = 0; |
WiredHome | 33:b6b710758ab3 | 65 | virtual RetCode_t background(uint16_t color) = 0; |
dreschpe | 0:de9d1462a835 | 66 | // putc (from Stream) |
dreschpe | 0:de9d1462a835 | 67 | // printf (from Stream) |
dreschpe | 0:de9d1462a835 | 68 | |
WiredHome | 19:3f82c1161fd2 | 69 | protected: |
dreschpe | 0:de9d1462a835 | 70 | virtual int _putc(int value); |
dreschpe | 0:de9d1462a835 | 71 | virtual int _getc(); |
dreschpe | 0:de9d1462a835 | 72 | |
dreschpe | 0:de9d1462a835 | 73 | // character location |
dreschpe | 0:de9d1462a835 | 74 | uint16_t _column; |
dreschpe | 0:de9d1462a835 | 75 | uint16_t _row; |
dreschpe | 0:de9d1462a835 | 76 | |
WiredHome | 33:b6b710758ab3 | 77 | // colors |
dreschpe | 0:de9d1462a835 | 78 | uint16_t _foreground; |
dreschpe | 0:de9d1462a835 | 79 | uint16_t _background; |
dreschpe | 0:de9d1462a835 | 80 | char *_path; |
dreschpe | 0:de9d1462a835 | 81 | }; |
dreschpe | 0:de9d1462a835 | 82 | |
dreschpe | 0:de9d1462a835 | 83 | #endif |