Library release of Simon Ford's GraphicsDisplay Display Library Base Class.

Dependents:   ese_project_copy ese_project_share Test_ColorMemLCD rIoTwear_LCD ... more

Committer:
frankvnk
Date:
Wed Jan 21 19:40:58 2015 +0000
Revision:
0:282710e02ef4
Child:
1:1cb0fcbce1bf
Initial release

Who changed what in which revision?

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