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