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