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.
Dependencies: C12832 MQTT LM75B MMA7660
Dependents: MFT_IoT_demo_USB400 IBM_RFID
C12832/TextDisplay.h@8:80d49dd91542, 2014-10-01 (annotated)
- Committer:
- icraggs
- Date:
- Wed Oct 01 13:27:35 2014 +0000
- Revision:
- 8:80d49dd91542
- Parent:
- 6:37b6d0d56190
Remove conditional compilation for IBM IoT settings
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| samdanbury | 6:37b6d0d56190 | 1 | /* mbed TextDisplay Library Base Class |
| samdanbury | 6:37b6d0d56190 | 2 | * Copyright (c) 2007-2009 sford |
| samdanbury | 6:37b6d0d56190 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
| samdanbury | 6:37b6d0d56190 | 4 | * |
| samdanbury | 6:37b6d0d56190 | 5 | * A common base class for Text displays |
| samdanbury | 6:37b6d0d56190 | 6 | * To port a new display, derive from this class and implement |
| samdanbury | 6:37b6d0d56190 | 7 | * the constructor (setup the display), character (put a character |
| samdanbury | 6:37b6d0d56190 | 8 | * at a location), rows and columns (number of rows/cols) functions. |
| samdanbury | 6:37b6d0d56190 | 9 | * Everything else (locate, printf, putc, cls) will come for free |
| samdanbury | 6:37b6d0d56190 | 10 | * |
| samdanbury | 6:37b6d0d56190 | 11 | * The model is the display will wrap at the right and bottom, so you can |
| samdanbury | 6:37b6d0d56190 | 12 | * keep writing and will always get valid characters. The location is |
| samdanbury | 6:37b6d0d56190 | 13 | * maintained internally to the class to make this easy |
| samdanbury | 6:37b6d0d56190 | 14 | */ |
| samdanbury | 6:37b6d0d56190 | 15 | |
| samdanbury | 6:37b6d0d56190 | 16 | #ifndef MBED_TEXTDISPLAY_H |
| samdanbury | 6:37b6d0d56190 | 17 | #define MBED_TEXTDISPLAY_H |
| samdanbury | 6:37b6d0d56190 | 18 | |
| samdanbury | 6:37b6d0d56190 | 19 | #include "mbed.h" |
| samdanbury | 6:37b6d0d56190 | 20 | |
| samdanbury | 6:37b6d0d56190 | 21 | /** |
| samdanbury | 6:37b6d0d56190 | 22 | * TextDisplay interface |
| samdanbury | 6:37b6d0d56190 | 23 | */ |
| samdanbury | 6:37b6d0d56190 | 24 | class TextDisplay : public Stream { |
| samdanbury | 6:37b6d0d56190 | 25 | public: |
| samdanbury | 6:37b6d0d56190 | 26 | |
| samdanbury | 6:37b6d0d56190 | 27 | /** |
| samdanbury | 6:37b6d0d56190 | 28 | * Create a TextDisplay interface |
| samdanbury | 6:37b6d0d56190 | 29 | * |
| samdanbury | 6:37b6d0d56190 | 30 | * @param name The name used in the path to access the strean through the filesystem |
| samdanbury | 6:37b6d0d56190 | 31 | */ |
| samdanbury | 6:37b6d0d56190 | 32 | TextDisplay(const char *name = NULL); |
| samdanbury | 6:37b6d0d56190 | 33 | |
| samdanbury | 6:37b6d0d56190 | 34 | /** |
| samdanbury | 6:37b6d0d56190 | 35 | * Output a character at the given position |
| samdanbury | 6:37b6d0d56190 | 36 | * |
| samdanbury | 6:37b6d0d56190 | 37 | * @param column column where charater must be written |
| samdanbury | 6:37b6d0d56190 | 38 | * @param row where character must be written |
| samdanbury | 6:37b6d0d56190 | 39 | * @param c the character to be written to the TextDisplay |
| samdanbury | 6:37b6d0d56190 | 40 | */ |
| samdanbury | 6:37b6d0d56190 | 41 | virtual void character(int column, int row, int c) = 0; |
| samdanbury | 6:37b6d0d56190 | 42 | |
| samdanbury | 6:37b6d0d56190 | 43 | /** |
| samdanbury | 6:37b6d0d56190 | 44 | * Return number of rows on TextDisplay |
| samdanbury | 6:37b6d0d56190 | 45 | * |
| samdanbury | 6:37b6d0d56190 | 46 | * @results number of rows |
| samdanbury | 6:37b6d0d56190 | 47 | */ |
| samdanbury | 6:37b6d0d56190 | 48 | virtual int rows() = 0; |
| samdanbury | 6:37b6d0d56190 | 49 | |
| samdanbury | 6:37b6d0d56190 | 50 | /** |
| samdanbury | 6:37b6d0d56190 | 51 | * Return number if columns on TextDisplay\ |
| samdanbury | 6:37b6d0d56190 | 52 | * |
| samdanbury | 6:37b6d0d56190 | 53 | * @results number of rows |
| samdanbury | 6:37b6d0d56190 | 54 | */ |
| samdanbury | 6:37b6d0d56190 | 55 | virtual int columns() = 0; |
| samdanbury | 6:37b6d0d56190 | 56 | |
| samdanbury | 6:37b6d0d56190 | 57 | // functions that come for free, but can be overwritten |
| samdanbury | 6:37b6d0d56190 | 58 | |
| samdanbury | 6:37b6d0d56190 | 59 | /** |
| samdanbury | 6:37b6d0d56190 | 60 | * Redirect output from a stream (stoud, sterr) to display |
| samdanbury | 6:37b6d0d56190 | 61 | * |
| samdanbury | 6:37b6d0d56190 | 62 | * @param stream stream that shall be redirected to the TextDisplay |
| samdanbury | 6:37b6d0d56190 | 63 | */ |
| samdanbury | 6:37b6d0d56190 | 64 | virtual bool claim (FILE *stream); |
| samdanbury | 6:37b6d0d56190 | 65 | |
| samdanbury | 6:37b6d0d56190 | 66 | /** |
| samdanbury | 6:37b6d0d56190 | 67 | * Clear screen |
| samdanbury | 6:37b6d0d56190 | 68 | */ |
| samdanbury | 6:37b6d0d56190 | 69 | virtual void cls(); |
| samdanbury | 6:37b6d0d56190 | 70 | |
| samdanbury | 6:37b6d0d56190 | 71 | /** |
| samdanbury | 6:37b6d0d56190 | 72 | * Change the cursor position to column, row (in pixels) |
| samdanbury | 6:37b6d0d56190 | 73 | */ |
| samdanbury | 6:37b6d0d56190 | 74 | virtual void locate(int column, int row); |
| samdanbury | 6:37b6d0d56190 | 75 | |
| samdanbury | 6:37b6d0d56190 | 76 | virtual void foreground(uint16_t colour); |
| samdanbury | 6:37b6d0d56190 | 77 | virtual void background(uint16_t colour); |
| samdanbury | 6:37b6d0d56190 | 78 | // putc (from Stream) |
| samdanbury | 6:37b6d0d56190 | 79 | // printf (from Stream) |
| samdanbury | 6:37b6d0d56190 | 80 | |
| samdanbury | 6:37b6d0d56190 | 81 | protected: |
| samdanbury | 6:37b6d0d56190 | 82 | |
| samdanbury | 6:37b6d0d56190 | 83 | virtual int _putc(int value); |
| samdanbury | 6:37b6d0d56190 | 84 | virtual int _getc(); |
| samdanbury | 6:37b6d0d56190 | 85 | |
| samdanbury | 6:37b6d0d56190 | 86 | // character location |
| samdanbury | 6:37b6d0d56190 | 87 | uint16_t _column; |
| samdanbury | 6:37b6d0d56190 | 88 | uint16_t _row; |
| samdanbury | 6:37b6d0d56190 | 89 | |
| samdanbury | 6:37b6d0d56190 | 90 | // colours |
| samdanbury | 6:37b6d0d56190 | 91 | uint16_t _foreground; |
| samdanbury | 6:37b6d0d56190 | 92 | uint16_t _background; |
| samdanbury | 6:37b6d0d56190 | 93 | char *_path; |
| samdanbury | 6:37b6d0d56190 | 94 | }; |
| samdanbury | 6:37b6d0d56190 | 95 | |
| samdanbury | 6:37b6d0d56190 | 96 | #endif |

