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