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

Dependencies:   mbed

Committer:
Lerche
Date:
Sun Oct 03 08:36:08 2010 +0000
Revision:
0:69334bd84891

        

Who changed what in which revision?

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