Lib for the new LCD Display with ILI9341 controller
TextDisplay.h@14:2724838d11ed, 2021-12-01 (annotated)
- Committer:
- smejky
- Date:
- Wed Dec 01 15:30:52 2021 +0000
- Revision:
- 14:2724838d11ed
- Parent:
- 0:da1bf437cbc1
My display
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 | |
dreschpe | 0:da1bf437cbc1 | 21 | class TextDisplay : public Stream { |
dreschpe | 0:da1bf437cbc1 | 22 | public: |
dreschpe | 0:da1bf437cbc1 | 23 | |
dreschpe | 0:da1bf437cbc1 | 24 | // functions needing implementation in derived implementation class |
dreschpe | 0:da1bf437cbc1 | 25 | /** Create a TextDisplay interface |
dreschpe | 0:da1bf437cbc1 | 26 | * |
dreschpe | 0:da1bf437cbc1 | 27 | * @param name The name used in the path to access the strean through the filesystem |
dreschpe | 0:da1bf437cbc1 | 28 | */ |
dreschpe | 0:da1bf437cbc1 | 29 | TextDisplay(const char *name = NULL); |
dreschpe | 0:da1bf437cbc1 | 30 | |
dreschpe | 0:da1bf437cbc1 | 31 | /** output a character at the given position |
dreschpe | 0:da1bf437cbc1 | 32 | * |
dreschpe | 0:da1bf437cbc1 | 33 | * @param column column where charater must be written |
dreschpe | 0:da1bf437cbc1 | 34 | * @param row where character must be written |
dreschpe | 0:da1bf437cbc1 | 35 | * @param c the character to be written to the TextDisplay |
dreschpe | 0:da1bf437cbc1 | 36 | */ |
dreschpe | 0:da1bf437cbc1 | 37 | virtual void character(int column, int row, int c) = 0; |
dreschpe | 0:da1bf437cbc1 | 38 | |
dreschpe | 0:da1bf437cbc1 | 39 | /** return number if rows on TextDisplay |
dreschpe | 0:da1bf437cbc1 | 40 | * @result number of rows |
dreschpe | 0:da1bf437cbc1 | 41 | */ |
dreschpe | 0:da1bf437cbc1 | 42 | virtual int rows() = 0; |
dreschpe | 0:da1bf437cbc1 | 43 | |
dreschpe | 0:da1bf437cbc1 | 44 | /** return number if columns on TextDisplay |
dreschpe | 0:da1bf437cbc1 | 45 | * @result number of rows |
dreschpe | 0:da1bf437cbc1 | 46 | */ |
dreschpe | 0:da1bf437cbc1 | 47 | virtual int columns() = 0; |
dreschpe | 0:da1bf437cbc1 | 48 | |
dreschpe | 0:da1bf437cbc1 | 49 | // functions that come for free, but can be overwritten |
dreschpe | 0:da1bf437cbc1 | 50 | |
dreschpe | 0:da1bf437cbc1 | 51 | /** redirect output from a stream (stoud, sterr) to display |
dreschpe | 0:da1bf437cbc1 | 52 | * @param stream stream that shall be redirected to the TextDisplay |
dreschpe | 0:da1bf437cbc1 | 53 | */ |
dreschpe | 0:da1bf437cbc1 | 54 | virtual bool claim (FILE *stream); |
dreschpe | 0:da1bf437cbc1 | 55 | |
dreschpe | 0:da1bf437cbc1 | 56 | /** clear screen |
dreschpe | 0:da1bf437cbc1 | 57 | */ |
dreschpe | 0:da1bf437cbc1 | 58 | virtual void cls(); |
dreschpe | 0:da1bf437cbc1 | 59 | virtual void locate(int column, int row); |
dreschpe | 0:da1bf437cbc1 | 60 | virtual void foreground(uint16_t colour); |
dreschpe | 0:da1bf437cbc1 | 61 | virtual void background(uint16_t colour); |
dreschpe | 0:da1bf437cbc1 | 62 | // putc (from Stream) |
dreschpe | 0:da1bf437cbc1 | 63 | // printf (from Stream) |
dreschpe | 0:da1bf437cbc1 | 64 | |
dreschpe | 0:da1bf437cbc1 | 65 | protected: |
dreschpe | 0:da1bf437cbc1 | 66 | |
dreschpe | 0:da1bf437cbc1 | 67 | virtual int _putc(int value); |
dreschpe | 0:da1bf437cbc1 | 68 | virtual int _getc(); |
dreschpe | 0:da1bf437cbc1 | 69 | |
dreschpe | 0:da1bf437cbc1 | 70 | // character location |
dreschpe | 0:da1bf437cbc1 | 71 | uint16_t _column; |
dreschpe | 0:da1bf437cbc1 | 72 | uint16_t _row; |
dreschpe | 0:da1bf437cbc1 | 73 | |
dreschpe | 0:da1bf437cbc1 | 74 | // colours |
dreschpe | 0:da1bf437cbc1 | 75 | uint16_t _foreground; |
dreschpe | 0:da1bf437cbc1 | 76 | uint16_t _background; |
dreschpe | 0:da1bf437cbc1 | 77 | char *_path; |
dreschpe | 0:da1bf437cbc1 | 78 | }; |
dreschpe | 0:da1bf437cbc1 | 79 | |
dreschpe | 0:da1bf437cbc1 | 80 | #endif |