mbed-os

Fork of mbed-os by erkin yucel

Committer:
xuaner
Date:
Thu Jul 20 14:26:57 2017 +0000
Revision:
1:3deb71413561
Parent:
0:f269e3021894
mbed_os

Who changed what in which revision?

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