for personal use

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TextLCD.h Source File

TextLCD.h

00001 /* mbed TextLCD Library
00002  * Copyright (c) 2007-2009 sford
00003  * Released under the MIT License: http://mbed.org/license/mit
00004  */
00005  
00006 #ifndef MBED_TEXTLCD_H
00007 #define MBED_TEXTLCD_H
00008 
00009 #include "Stream.h"
00010 #include "DigitalOut.h"
00011 #include "BusOut.h"
00012 
00013 namespace mbed {
00014 
00015 /* Class: TextLCD
00016  * A 16x2 Text LCD controller
00017  *
00018  * If you are connecting multiple displays, you can connect them all in
00019  * parallel except for the enable (e) pin, which must be unique for each
00020  * display.
00021  *
00022  * Example:
00023  * > #include "mbed.h"
00024  * > #include "TextLCD.h"
00025  * >
00026  * > TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3
00027  * >
00028  * > int main() {
00029  * >     lcd.printf("Hello World!");
00030  * > }
00031  */
00032 class TextLCD : public Stream {
00033 
00034 public:
00035     /* Constructor: TextLCD
00036      * Create a TextLCD object, connected to the specified pins
00037      *
00038      * All signals must be connected to DigitalIn compatible pins. 
00039      * Variables:
00040      *  rs -  Used to specify data or command
00041      *  rw - Used to determine read or write
00042      *  e - enable
00043      *  d0..d3 - The data lines
00044      */
00045     TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1, 
00046         PinName d2, PinName d3, int columns = 16, int rows = 2);
00047 
00048 #if 0 // Inhereted from Stream, for documentation only
00049     /* Function: putc
00050      *  Write a character
00051      *
00052      * Variables:
00053      *  c - The character to write to the serial port
00054      */
00055     int putc(int c);
00056 
00057     /* Function: printf
00058      *  Write a formated string
00059      *
00060      * Variables:
00061      *  format - A printf-style format string, followed by the
00062      *      variables to use in formating the string.
00063      */
00064     int printf(const char* format, ...);
00065 #endif
00066         
00067     /* Function: locate
00068      * Locate to a certian position
00069      *
00070      * Variables:
00071      *  column - the column to locate to, from 0..15
00072      *  row - the row to locate to, from 0..1
00073      */
00074     virtual void locate(int column, int row);
00075     
00076     /* Function: cls
00077      * Clear the screen, and locate to 0,0
00078      */
00079     virtual void cls(); 
00080     
00081     virtual void reset();
00082         
00083 protected:
00084 
00085     void clock();
00086     void writeData(int data);
00087     void writeCommand(int command);
00088     void writeByte(int value);
00089     void writeNibble(int value);
00090     virtual int _putc(int c);       
00091     virtual int _getc();
00092     virtual void newline();             
00093             
00094     int _row;
00095     int _column;    
00096     DigitalOut _rw, _rs, _e;
00097     BusOut _d;
00098     int _columns;
00099     int _rows;
00100 
00101 };
00102 
00103 }
00104 
00105 #endif