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