TextLCD library for controlling various LCD panels based on the HD44780 4-bit interface

Dependents:   TextLCD_HelloWorld analog_test AVR_standalone_writer XBeeApi_RemoteCommand ... more

Committer:
simon
Date:
Sat May 22 18:18:19 2010 +0000
Revision:
0:edfb85c53631

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:edfb85c53631 1 /* mbed TextDisplay Library Base Class
simon 0:edfb85c53631 2 * Copyright (c) 2007-2010, sford
simon 0:edfb85c53631 3 *
simon 0:edfb85c53631 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
simon 0:edfb85c53631 5 * of this software and associated documentation files (the "Software"), to deal
simon 0:edfb85c53631 6 * in the Software without restriction, including without limitation the rights
simon 0:edfb85c53631 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
simon 0:edfb85c53631 8 * copies of the Software, and to permit persons to whom the Software is
simon 0:edfb85c53631 9 * furnished to do so, subject to the following conditions:
simon 0:edfb85c53631 10 *
simon 0:edfb85c53631 11 * The above copyright notice and this permission notice shall be included in
simon 0:edfb85c53631 12 * all copies or substantial portions of the Software.
simon 0:edfb85c53631 13 *
simon 0:edfb85c53631 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
simon 0:edfb85c53631 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
simon 0:edfb85c53631 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
simon 0:edfb85c53631 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
simon 0:edfb85c53631 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 0:edfb85c53631 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
simon 0:edfb85c53631 20 * THE SOFTWARE.
simon 0:edfb85c53631 21 *
simon 0:edfb85c53631 22 * A common base class for driving Text displays, providing useful functionality
simon 0:edfb85c53631 23 * that can be shared by all text lcds. To port a new display, derive from this
simon 0:edfb85c53631 24 * class and implement the constructor (setup the display), character (put a
simon 0:edfb85c53631 25 * character at a location), rows and columns (number of rows/cols) functions.
simon 0:edfb85c53631 26 * Everything else (locate, printf, putc, cls) will come for free
simon 0:edfb85c53631 27 *
simon 0:edfb85c53631 28 * The model is the display will wrap at the right and bottom, so you can
simon 0:edfb85c53631 29 * keep writing and will always get valid characters. The location is
simon 0:edfb85c53631 30 * maintained internally to the class to make this easier
simon 0:edfb85c53631 31 */
simon 0:edfb85c53631 32
simon 0:edfb85c53631 33 #ifndef MBED_TEXTDISPLAY_H
simon 0:edfb85c53631 34 #define MBED_TEXTDISPLAY_H
simon 0:edfb85c53631 35
simon 0:edfb85c53631 36 #include "mbed.h"
simon 0:edfb85c53631 37
simon 0:edfb85c53631 38 class TextDisplay : public Stream {
simon 0:edfb85c53631 39 public:
simon 0:edfb85c53631 40
simon 0:edfb85c53631 41 // functions to be implementated in the derived class
simon 0:edfb85c53631 42 TextDisplay();
simon 0:edfb85c53631 43 virtual void character(int column, int row, int c) = 0;
simon 0:edfb85c53631 44 virtual int rows() = 0;
simon 0:edfb85c53631 45 virtual int columns() = 0;
simon 0:edfb85c53631 46
simon 0:edfb85c53631 47 // functions that come for free, but can be overwritten
simon 0:edfb85c53631 48 virtual void cls();
simon 0:edfb85c53631 49 virtual void locate(int column, int row);
simon 0:edfb85c53631 50 virtual void foreground(int colour);
simon 0:edfb85c53631 51 virtual void background(int colour);
simon 0:edfb85c53631 52
simon 0:edfb85c53631 53 // other stdio-type functions
simon 0:edfb85c53631 54 // putc() inherited from Stream
simon 0:edfb85c53631 55 // printf() is inherited from Stream
simon 0:edfb85c53631 56
simon 0:edfb85c53631 57 protected:
simon 0:edfb85c53631 58
simon 0:edfb85c53631 59 virtual int _putc(int value);
simon 0:edfb85c53631 60 virtual int _getc();
simon 0:edfb85c53631 61
simon 0:edfb85c53631 62 // character location
simon 0:edfb85c53631 63 short _column;
simon 0:edfb85c53631 64 short _row;
simon 0:edfb85c53631 65
simon 0:edfb85c53631 66 // colours
simon 0:edfb85c53631 67 int _foreground;
simon 0:edfb85c53631 68 int _background;
simon 0:edfb85c53631 69 };
simon 0:edfb85c53631 70
simon 0:edfb85c53631 71 #endif