Dependencies:   mbed

Committer:
simon
Date:
Mon Nov 30 09:32:28 2009 +0000
Revision:
0:42626fc1bbc5

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:42626fc1bbc5 1 /* mbed TextDisplay Library Base Class
simon 0:42626fc1bbc5 2 * Copyright (c) 2007-2009 sford
simon 0:42626fc1bbc5 3 * Released under the MIT License: http://mbed.org/license/mit
simon 0:42626fc1bbc5 4 *
simon 0:42626fc1bbc5 5 * A common base class for Text displays
simon 0:42626fc1bbc5 6 * To port a new display, derive from this class and implement
simon 0:42626fc1bbc5 7 * the constructor (setup the display), character (put a character
simon 0:42626fc1bbc5 8 * at a location), rows and columns (number of rows/cols) functions.
simon 0:42626fc1bbc5 9 * Everything else (locate, printf, putc, cls) will come for free
simon 0:42626fc1bbc5 10 *
simon 0:42626fc1bbc5 11 * The model is the display will wrap at the right and bottom, so you can
simon 0:42626fc1bbc5 12 * keep writing and will always get valid characters. The location is
simon 0:42626fc1bbc5 13 * maintained internally to the class to make this easy
simon 0:42626fc1bbc5 14 */
simon 0:42626fc1bbc5 15
simon 0:42626fc1bbc5 16 #ifndef MBED_TEXTDISPLAY_H
simon 0:42626fc1bbc5 17 #define MBED_TEXTDISPLAY_H
simon 0:42626fc1bbc5 18
simon 0:42626fc1bbc5 19 #include "mbed.h"
simon 0:42626fc1bbc5 20
simon 0:42626fc1bbc5 21 class TextDisplay : public Stream {
simon 0:42626fc1bbc5 22 public:
simon 0:42626fc1bbc5 23
simon 0:42626fc1bbc5 24 // functions needing implementation in derived implementation class
simon 0:42626fc1bbc5 25 TextDisplay(const char *name = NULL);
simon 0:42626fc1bbc5 26 virtual void character(int column, int row, int c) = 0;
simon 0:42626fc1bbc5 27 virtual int rows() = 0;
simon 0:42626fc1bbc5 28 virtual int columns() = 0;
simon 0:42626fc1bbc5 29
simon 0:42626fc1bbc5 30 // functions that come for free, but can be overwritten
simon 0:42626fc1bbc5 31 virtual void cls();
simon 0:42626fc1bbc5 32 virtual void locate(int column, int row);
simon 0:42626fc1bbc5 33 virtual void foreground(int colour);
simon 0:42626fc1bbc5 34 virtual void background(int colour);
simon 0:42626fc1bbc5 35 // putc (from Stream)
simon 0:42626fc1bbc5 36 // printf (from Stream)
simon 0:42626fc1bbc5 37
simon 0:42626fc1bbc5 38 protected:
simon 0:42626fc1bbc5 39
simon 0:42626fc1bbc5 40 virtual int _putc(int value);
simon 0:42626fc1bbc5 41 virtual int _getc();
simon 0:42626fc1bbc5 42
simon 0:42626fc1bbc5 43 // character location
simon 0:42626fc1bbc5 44 short _column;
simon 0:42626fc1bbc5 45 short _row;
simon 0:42626fc1bbc5 46
simon 0:42626fc1bbc5 47 // colours
simon 0:42626fc1bbc5 48 int _foreground;
simon 0:42626fc1bbc5 49 int _background;
simon 0:42626fc1bbc5 50 };
simon 0:42626fc1bbc5 51
simon 0:42626fc1bbc5 52 #endif