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