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