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