Petar Jandrlic
/
OLED_PERIPH_XPR_BB
hadrovic oled
EAOLED/TextDisplay.h@0:b13343630d26, 2014-04-09 (annotated)
- Committer:
- perodot
- Date:
- Wed Apr 09 13:32:39 2014 +0000
- Revision:
- 0:b13343630d26
Hardovic Oled
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
perodot | 0:b13343630d26 | 1 | /* mbed TextDisplay Library Base Class |
perodot | 0:b13343630d26 | 2 | * Copyright (c) 2007-2009 sford |
perodot | 0:b13343630d26 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
perodot | 0:b13343630d26 | 4 | * |
perodot | 0:b13343630d26 | 5 | * A common base class for Text displays |
perodot | 0:b13343630d26 | 6 | * To port a new display, derive from this class and implement |
perodot | 0:b13343630d26 | 7 | * the constructor (setup the display), character (put a character |
perodot | 0:b13343630d26 | 8 | * at a location), rows and columns (number of rows/cols) functions. |
perodot | 0:b13343630d26 | 9 | * Everything else (locate, printf, putc, cls) will come for free |
perodot | 0:b13343630d26 | 10 | * |
perodot | 0:b13343630d26 | 11 | * The model is the display will wrap at the right and bottom, so you can |
perodot | 0:b13343630d26 | 12 | * keep writing and will always get valid characters. The location is |
perodot | 0:b13343630d26 | 13 | * maintained internally to the class to make this easy |
perodot | 0:b13343630d26 | 14 | */ |
perodot | 0:b13343630d26 | 15 | |
perodot | 0:b13343630d26 | 16 | #ifndef MBED_TEXTDISPLAY_H |
perodot | 0:b13343630d26 | 17 | #define MBED_TEXTDISPLAY_H |
perodot | 0:b13343630d26 | 18 | |
perodot | 0:b13343630d26 | 19 | #include "mbed.h" |
perodot | 0:b13343630d26 | 20 | |
perodot | 0:b13343630d26 | 21 | class TextDisplay : public Stream { |
perodot | 0:b13343630d26 | 22 | public: |
perodot | 0:b13343630d26 | 23 | |
perodot | 0:b13343630d26 | 24 | // functions needing implementation in derived implementation class |
perodot | 0:b13343630d26 | 25 | TextDisplay(); |
perodot | 0:b13343630d26 | 26 | virtual void character(int column, int row, int c) = 0; |
perodot | 0:b13343630d26 | 27 | virtual int rows() = 0; |
perodot | 0:b13343630d26 | 28 | virtual int columns() = 0; |
perodot | 0:b13343630d26 | 29 | |
perodot | 0:b13343630d26 | 30 | // functions that come for free, but can be overwritten |
perodot | 0:b13343630d26 | 31 | virtual void cls(); |
perodot | 0:b13343630d26 | 32 | virtual void locate(int column, int row); |
perodot | 0:b13343630d26 | 33 | virtual void foreground(int colour); |
perodot | 0:b13343630d26 | 34 | virtual void background(int colour); |
perodot | 0:b13343630d26 | 35 | // putc (from Stream) |
perodot | 0:b13343630d26 | 36 | // printf (from Stream) |
perodot | 0:b13343630d26 | 37 | |
perodot | 0:b13343630d26 | 38 | protected: |
perodot | 0:b13343630d26 | 39 | |
perodot | 0:b13343630d26 | 40 | virtual int _putc(int value); |
perodot | 0:b13343630d26 | 41 | virtual int _getc(); |
perodot | 0:b13343630d26 | 42 | |
perodot | 0:b13343630d26 | 43 | // character location |
perodot | 0:b13343630d26 | 44 | short _column; |
perodot | 0:b13343630d26 | 45 | short _row; |
perodot | 0:b13343630d26 | 46 | |
perodot | 0:b13343630d26 | 47 | // colours |
perodot | 0:b13343630d26 | 48 | int _foreground; |
perodot | 0:b13343630d26 | 49 | int _background; |
perodot | 0:b13343630d26 | 50 | }; |
perodot | 0:b13343630d26 | 51 | |
perodot | 0:b13343630d26 | 52 | #endif |