A test example using the OLED display on the Embedded Artists Xpresso baseboard

Dependencies:   mbed

Committer:
simon
Date:
Sun Feb 28 16:04:59 2010 +0000
Revision:
0:f42b25503fd1

        

Who changed what in which revision?

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