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.
Dependents: demoUI whrmDemoUI Host_Software_MAX32664GWEB_HR_EXTENDED Host_Software_MAX32664GWEC_SpO2_HR-_EXTE ... more
TextDisplay.h@0:a0faa86660d4, 2015-03-18 (annotated)
- Committer:
 - Steven Cooreman 
 - Date:
 - Wed Mar 18 10:57:16 2015 -0500
 - Revision:
 - 0:a0faa86660d4
 - Child:
 - 4:b02dfd360729
 
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Steven Cooreman  | 
0:a0faa86660d4 | 1 | /* mbed TextDisplay Library Base Class | 
| Steven Cooreman  | 
0:a0faa86660d4 | 2 | * Copyright (c) 2007-2009 sford | 
| Steven Cooreman  | 
0:a0faa86660d4 | 3 | * Released under the MIT License: http://mbed.org/license/mit | 
| Steven Cooreman  | 
0:a0faa86660d4 | 4 | * | 
| Steven Cooreman  | 
0:a0faa86660d4 | 5 | * A common base class for Text displays | 
| Steven Cooreman  | 
0:a0faa86660d4 | 6 | * To port a new display, derive from this class and implement | 
| Steven Cooreman  | 
0:a0faa86660d4 | 7 | * the constructor (setup the display), character (put a character | 
| Steven Cooreman  | 
0:a0faa86660d4 | 8 | * at a location), rows and columns (number of rows/cols) functions. | 
| Steven Cooreman  | 
0:a0faa86660d4 | 9 | * Everything else (locate, printf, putc, cls) will come for free | 
| Steven Cooreman  | 
0:a0faa86660d4 | 10 | * | 
| Steven Cooreman  | 
0:a0faa86660d4 | 11 | * The model is the display will wrap at the right and bottom, so you can | 
| Steven Cooreman  | 
0:a0faa86660d4 | 12 | * keep writing and will always get valid characters. The location is | 
| Steven Cooreman  | 
0:a0faa86660d4 | 13 | * maintained internally to the class to make this easy | 
| Steven Cooreman  | 
0:a0faa86660d4 | 14 | */ | 
| Steven Cooreman  | 
0:a0faa86660d4 | 15 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 16 | #ifndef MBED_TEXTDISPLAY_H | 
| Steven Cooreman  | 
0:a0faa86660d4 | 17 | #define MBED_TEXTDISPLAY_H | 
| Steven Cooreman  | 
0:a0faa86660d4 | 18 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 19 | #include "mbed.h" | 
| Steven Cooreman  | 
0:a0faa86660d4 | 20 | #include "LCDSettings.h" | 
| Steven Cooreman  | 
0:a0faa86660d4 | 21 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 22 | class TextDisplay { | 
| Steven Cooreman  | 
0:a0faa86660d4 | 23 | public: | 
| Steven Cooreman  | 
0:a0faa86660d4 | 24 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 25 | // functions needing implementation in derived implementation class | 
| Steven Cooreman  | 
0:a0faa86660d4 | 26 | /** Create a TextDisplay interface | 
| Steven Cooreman  | 
0:a0faa86660d4 | 27 | * | 
| Steven Cooreman  | 
0:a0faa86660d4 | 28 | * @param name The name used in the path to access the strean through the filesystem | 
| Steven Cooreman  | 
0:a0faa86660d4 | 29 | */ | 
| Steven Cooreman  | 
0:a0faa86660d4 | 30 | TextDisplay(const char *name = NULL); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 31 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 32 | /** output a character at the given position | 
| Steven Cooreman  | 
0:a0faa86660d4 | 33 | * | 
| Steven Cooreman  | 
0:a0faa86660d4 | 34 | * @param column column where charater must be written | 
| Steven Cooreman  | 
0:a0faa86660d4 | 35 | * @param row where character must be written | 
| Steven Cooreman  | 
0:a0faa86660d4 | 36 | * @param c the character to be written to the TextDisplay | 
| Steven Cooreman  | 
0:a0faa86660d4 | 37 | */ | 
| Steven Cooreman  | 
0:a0faa86660d4 | 38 | virtual void character(int column, int row, int c) = 0; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 39 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 40 | /** return number if rows on TextDisplay | 
| Steven Cooreman  | 
0:a0faa86660d4 | 41 | * @result number of rows | 
| Steven Cooreman  | 
0:a0faa86660d4 | 42 | */ | 
| Steven Cooreman  | 
0:a0faa86660d4 | 43 | virtual int rows() = 0; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 44 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 45 | /** return number if columns on TextDisplay | 
| Steven Cooreman  | 
0:a0faa86660d4 | 46 | * @result number of rows | 
| Steven Cooreman  | 
0:a0faa86660d4 | 47 | */ | 
| Steven Cooreman  | 
0:a0faa86660d4 | 48 | virtual int columns() = 0; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 49 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 50 | // functions that come for free, but can be overwritten | 
| Steven Cooreman  | 
0:a0faa86660d4 | 51 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 52 | /** redirect output from a stream (stoud, sterr) to display | 
| Steven Cooreman  | 
0:a0faa86660d4 | 53 | * @param stream stream that shall be redirected to the TextDisplay | 
| Steven Cooreman  | 
0:a0faa86660d4 | 54 | */ | 
| Steven Cooreman  | 
0:a0faa86660d4 | 55 | virtual bool claim (FILE *stream); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 56 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 57 | /** clear screen | 
| Steven Cooreman  | 
0:a0faa86660d4 | 58 | */ | 
| Steven Cooreman  | 
0:a0faa86660d4 | 59 | virtual void cls(); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 60 | virtual void locate(int column, int row); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 61 | virtual void foreground(uint16_t colour); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 62 | virtual void background(uint16_t colour); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 63 | // putc (from Stream) | 
| Steven Cooreman  | 
0:a0faa86660d4 | 64 | // printf (from Stream) | 
| Steven Cooreman  | 
0:a0faa86660d4 | 65 | virtual void printf(const char* format, ...); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 66 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 67 | protected: | 
| Steven Cooreman  | 
0:a0faa86660d4 | 68 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 69 | virtual int _putc(int value); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 70 | virtual int _getc(); | 
| Steven Cooreman  | 
0:a0faa86660d4 | 71 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 72 | // character location | 
| Steven Cooreman  | 
0:a0faa86660d4 | 73 | uint16_t _column; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 74 | uint16_t _row; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 75 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 76 | // colours | 
| Steven Cooreman  | 
0:a0faa86660d4 | 77 | uint16_t _foreground; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 78 | uint16_t _background; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 79 | char *_path; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 80 | }; | 
| Steven Cooreman  | 
0:a0faa86660d4 | 81 | |
| Steven Cooreman  | 
0:a0faa86660d4 | 82 | #endif |