test

Dependencies:   mbed

Committer:
chris77774
Date:
Sat Apr 30 17:57:29 2016 +0000
Revision:
0:32a06703946f
test

Who changed what in which revision?

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