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