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