Christian Weiß
/
TINF_Testvorbereitung_5B
TINF_Testvorbereitung_5B
C12832_copy/TextDisplay.h@0:799a62df672a, 2018-11-15 (annotated)
- Committer:
- Wizo
- Date:
- Thu Nov 15 18:14:50 2018 +0000
- Revision:
- 0:799a62df672a
TINF_Testvorbereitung_5B
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Wizo | 0:799a62df672a | 1 | /* mbed TextDisplay Library Base Class |
Wizo | 0:799a62df672a | 2 | * Copyright (c) 2007-2009 sford |
Wizo | 0:799a62df672a | 3 | * Released under the MIT License: http://mbed.org/license/mit |
Wizo | 0:799a62df672a | 4 | * |
Wizo | 0:799a62df672a | 5 | * A common base class for Text displays |
Wizo | 0:799a62df672a | 6 | * To port a new display, derive from this class and implement |
Wizo | 0:799a62df672a | 7 | * the constructor (setup the display), character (put a character |
Wizo | 0:799a62df672a | 8 | * at a location), rows and columns (number of rows/cols) functions. |
Wizo | 0:799a62df672a | 9 | * Everything else (locate, printf, putc, cls) will come for free |
Wizo | 0:799a62df672a | 10 | * |
Wizo | 0:799a62df672a | 11 | * The model is the display will wrap at the right and bottom, so you can |
Wizo | 0:799a62df672a | 12 | * keep writing and will always get valid characters. The location is |
Wizo | 0:799a62df672a | 13 | * maintained internally to the class to make this easy |
Wizo | 0:799a62df672a | 14 | */ |
Wizo | 0:799a62df672a | 15 | |
Wizo | 0:799a62df672a | 16 | #ifndef MBED_TEXTDISPLAY_H |
Wizo | 0:799a62df672a | 17 | #define MBED_TEXTDISPLAY_H |
Wizo | 0:799a62df672a | 18 | |
Wizo | 0:799a62df672a | 19 | #include "mbed.h" |
Wizo | 0:799a62df672a | 20 | |
Wizo | 0:799a62df672a | 21 | class TextDisplay : public Stream { |
Wizo | 0:799a62df672a | 22 | public: |
Wizo | 0:799a62df672a | 23 | |
Wizo | 0:799a62df672a | 24 | // functions needing implementation in derived implementation class |
Wizo | 0:799a62df672a | 25 | /** Create a TextDisplay interface |
Wizo | 0:799a62df672a | 26 | * |
Wizo | 0:799a62df672a | 27 | * @param name The name used in the path to access the strean through the filesystem |
Wizo | 0:799a62df672a | 28 | */ |
Wizo | 0:799a62df672a | 29 | TextDisplay(const char *name = NULL); |
Wizo | 0:799a62df672a | 30 | |
Wizo | 0:799a62df672a | 31 | /** output a character at the given position |
Wizo | 0:799a62df672a | 32 | * |
Wizo | 0:799a62df672a | 33 | * @param column column where charater must be written |
Wizo | 0:799a62df672a | 34 | * @param row where character must be written |
Wizo | 0:799a62df672a | 35 | * @param c the character to be written to the TextDisplay |
Wizo | 0:799a62df672a | 36 | */ |
Wizo | 0:799a62df672a | 37 | virtual void character(int column, int row, int c) = 0; |
Wizo | 0:799a62df672a | 38 | |
Wizo | 0:799a62df672a | 39 | /** return number if rows on TextDisplay |
Wizo | 0:799a62df672a | 40 | * @result number of rows |
Wizo | 0:799a62df672a | 41 | */ |
Wizo | 0:799a62df672a | 42 | virtual int rows() = 0; |
Wizo | 0:799a62df672a | 43 | |
Wizo | 0:799a62df672a | 44 | /** return number if columns on TextDisplay |
Wizo | 0:799a62df672a | 45 | * @result number of rows |
Wizo | 0:799a62df672a | 46 | */ |
Wizo | 0:799a62df672a | 47 | virtual int columns() = 0; |
Wizo | 0:799a62df672a | 48 | |
Wizo | 0:799a62df672a | 49 | // functions that come for free, but can be overwritten |
Wizo | 0:799a62df672a | 50 | |
Wizo | 0:799a62df672a | 51 | /** redirect output from a stream (stoud, sterr) to display |
Wizo | 0:799a62df672a | 52 | * @param stream stream that shall be redirected to the TextDisplay |
Wizo | 0:799a62df672a | 53 | */ |
Wizo | 0:799a62df672a | 54 | virtual bool claim (FILE *stream); |
Wizo | 0:799a62df672a | 55 | |
Wizo | 0:799a62df672a | 56 | /** clear screen |
Wizo | 0:799a62df672a | 57 | */ |
Wizo | 0:799a62df672a | 58 | virtual void cls(); |
Wizo | 0:799a62df672a | 59 | virtual void locate(int column, int row); |
Wizo | 0:799a62df672a | 60 | virtual void foreground(uint16_t colour); |
Wizo | 0:799a62df672a | 61 | virtual void background(uint16_t colour); |
Wizo | 0:799a62df672a | 62 | // putc (from Stream) |
Wizo | 0:799a62df672a | 63 | // printf (from Stream) |
Wizo | 0:799a62df672a | 64 | |
Wizo | 0:799a62df672a | 65 | protected: |
Wizo | 0:799a62df672a | 66 | |
Wizo | 0:799a62df672a | 67 | virtual int _putc(int value); |
Wizo | 0:799a62df672a | 68 | virtual int _getc(); |
Wizo | 0:799a62df672a | 69 | |
Wizo | 0:799a62df672a | 70 | // character location |
Wizo | 0:799a62df672a | 71 | uint16_t _column; |
Wizo | 0:799a62df672a | 72 | uint16_t _row; |
Wizo | 0:799a62df672a | 73 | |
Wizo | 0:799a62df672a | 74 | // colours |
Wizo | 0:799a62df672a | 75 | uint16_t _foreground; |
Wizo | 0:799a62df672a | 76 | uint16_t _background; |
Wizo | 0:799a62df672a | 77 | char *_path; |
Wizo | 0:799a62df672a | 78 | }; |
Wizo | 0:799a62df672a | 79 | |
Wizo | 0:799a62df672a | 80 | #endif |