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