EA OLED (Orig. by SFord, retouched by Lerche)

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TextDisplay.h Source File

TextDisplay.h

00001 /* mbed TextDisplay Library Base Class
00002  * Copyright (c) 2007-2009 sford
00003  * Released under the MIT License: http://mbed.org/license/mit
00004  *
00005  * A common base class for Text displays
00006  * To port a new display, derive from this class and implement
00007  * the constructor (setup the display), character (put a character
00008  * at a location), rows and columns (number of rows/cols) functions.
00009  * Everything else (locate, printf, putc, cls) will come for free
00010  *
00011  * The model is the display will wrap at the right and bottom, so you can
00012  * keep writing and will always get valid characters. The location is 
00013  * maintained internally to the class to make this easy
00014  */
00015 
00016 #ifndef MBED_TEXTDISPLAY_H
00017 #define MBED_TEXTDISPLAY_H
00018 
00019 #include "mbed.h"
00020 
00021 class TextDisplay : public Stream {
00022 public:
00023 
00024     // functions needing implementation in derived implementation class
00025     TextDisplay();
00026     virtual void character(int column, int row, int c) = 0;
00027     virtual int rows() = 0;
00028     virtual int columns() = 0;
00029     
00030     // functions that come for free, but can be overwritten
00031     virtual void cls();
00032     virtual void locate(int column, int row);
00033     virtual void foreground(int colour);
00034     virtual void background(int colour);
00035     // putc (from Stream)
00036     // printf (from Stream)
00037     
00038 protected:
00039 
00040     virtual int _putc(int value);
00041     virtual int _getc();
00042 
00043     // character location
00044     short _column;
00045     short _row;
00046 
00047     // colours
00048     int _foreground;
00049     int _background;
00050 };
00051 
00052 #endif