Test LCD

Dependencies:   mbed

Fork of TextLCDTest by Simon Ford

Committer:
simon
Date:
Tue Nov 17 10:16:30 2009 +0000
Revision:
0:b77078f30b97

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:b77078f30b97 1 /* mbed TextLCD Library
simon 0:b77078f30b97 2 * Copyright (c) 2007-2009 sford
simon 0:b77078f30b97 3 * Released under the MIT License: http://mbed.org/license/mit
simon 0:b77078f30b97 4 *
simon 0:b77078f30b97 5 * TODO: Needs serious rework/neatening up!
simon 0:b77078f30b97 6 */
simon 0:b77078f30b97 7
simon 0:b77078f30b97 8 #ifndef MBED_TEXTLCD_H
simon 0:b77078f30b97 9 #define MBED_TEXTLCD_H
simon 0:b77078f30b97 10
simon 0:b77078f30b97 11 #include "Stream.h"
simon 0:b77078f30b97 12 #include "DigitalOut.h"
simon 0:b77078f30b97 13 #include "BusOut.h"
simon 0:b77078f30b97 14
simon 0:b77078f30b97 15 namespace mbed {
simon 0:b77078f30b97 16
simon 0:b77078f30b97 17 /* Class: TextLCD
simon 0:b77078f30b97 18 * A 16x2 Text LCD controller
simon 0:b77078f30b97 19 *
simon 0:b77078f30b97 20 * Allows you to print to a Text LCD screen, and locate/cls. Could be
simon 0:b77078f30b97 21 * turned in to a more generic libray.
simon 0:b77078f30b97 22 *
simon 0:b77078f30b97 23 * If you are connecting multiple displays, you can connect them all in
simon 0:b77078f30b97 24 * parallel except for the enable (e) pin, which must be unique for each
simon 0:b77078f30b97 25 * display.
simon 0:b77078f30b97 26 *
simon 0:b77078f30b97 27 * Example:
simon 0:b77078f30b97 28 * > #include "mbed.h"
simon 0:b77078f30b97 29 * > #include "TextLCD.h"
simon 0:b77078f30b97 30 * >
simon 0:b77078f30b97 31 * > TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3
simon 0:b77078f30b97 32 * >
simon 0:b77078f30b97 33 * > int main() {
simon 0:b77078f30b97 34 * > lcd.printf("Hello World!");
simon 0:b77078f30b97 35 * > }
simon 0:b77078f30b97 36 */
simon 0:b77078f30b97 37 class TextLCD : public Stream {
simon 0:b77078f30b97 38
simon 0:b77078f30b97 39 public:
simon 0:b77078f30b97 40 /* Constructor: TextLCD
simon 0:b77078f30b97 41 * Create a TextLCD object, connected to the specified pins
simon 0:b77078f30b97 42 *
simon 0:b77078f30b97 43 * All signals must be connected to DigitalIn compatible pins.
simon 0:b77078f30b97 44 *
simon 0:b77078f30b97 45 * Variables:
simon 0:b77078f30b97 46 * rs - Used to specify data or command
simon 0:b77078f30b97 47 * rw - Used to determine read or write
simon 0:b77078f30b97 48 * e - enable
simon 0:b77078f30b97 49 * d0..d3 - The data lines
simon 0:b77078f30b97 50 */
simon 0:b77078f30b97 51 TextLCD(PinName rs, PinName rw, PinName e, PinName d0, PinName d1,
simon 0:b77078f30b97 52 PinName d2, PinName d3, int columns = 16, int rows = 2);
simon 0:b77078f30b97 53
simon 0:b77078f30b97 54 #if 0 // Inhereted from Stream, for documentation only
simon 0:b77078f30b97 55 /* Function: putc
simon 0:b77078f30b97 56 * Write a character
simon 0:b77078f30b97 57 *
simon 0:b77078f30b97 58 * Variables:
simon 0:b77078f30b97 59 * c - The character to write to the serial port
simon 0:b77078f30b97 60 */
simon 0:b77078f30b97 61 int putc(int c);
simon 0:b77078f30b97 62
simon 0:b77078f30b97 63 /* Function: printf
simon 0:b77078f30b97 64 * Write a formated string
simon 0:b77078f30b97 65 *
simon 0:b77078f30b97 66 * Variables:
simon 0:b77078f30b97 67 * format - A printf-style format string, followed by the
simon 0:b77078f30b97 68 * variables to use in formating the string.
simon 0:b77078f30b97 69 */
simon 0:b77078f30b97 70 int printf(const char* format, ...);
simon 0:b77078f30b97 71 #endif
simon 0:b77078f30b97 72
simon 0:b77078f30b97 73 /* Function: locate
simon 0:b77078f30b97 74 * Locate to a certian position
simon 0:b77078f30b97 75 *
simon 0:b77078f30b97 76 * Variables:
simon 0:b77078f30b97 77 * column - the column to locate to, from 0..15
simon 0:b77078f30b97 78 * row - the row to locate to, from 0..1
simon 0:b77078f30b97 79 */
simon 0:b77078f30b97 80 virtual void locate(int column, int row);
simon 0:b77078f30b97 81
simon 0:b77078f30b97 82 /* Function: cls
simon 0:b77078f30b97 83 * Clear the screen, and locate to 0,0
simon 0:b77078f30b97 84 */
simon 0:b77078f30b97 85 virtual void cls();
simon 0:b77078f30b97 86
simon 0:b77078f30b97 87 virtual void reset();
simon 0:b77078f30b97 88
simon 0:b77078f30b97 89 //protected:
simon 0:b77078f30b97 90
simon 0:b77078f30b97 91 void clock();
simon 0:b77078f30b97 92 void writeData(int data);
simon 0:b77078f30b97 93 void writeCommand(int command);
simon 0:b77078f30b97 94 void writeByte(int value);
simon 0:b77078f30b97 95 void writeNibble(int value);
simon 0:b77078f30b97 96 virtual int _putc(int c);
simon 0:b77078f30b97 97 virtual int _getc();
simon 0:b77078f30b97 98 virtual void newline();
simon 0:b77078f30b97 99
simon 0:b77078f30b97 100 int _row;
simon 0:b77078f30b97 101 int _column;
simon 0:b77078f30b97 102 DigitalOut _rw, _rs, _e;
simon 0:b77078f30b97 103 BusOut _d;
simon 0:b77078f30b97 104 int _columns;
simon 0:b77078f30b97 105 int _rows;
simon 0:b77078f30b97 106
simon 0:b77078f30b97 107 };
simon 0:b77078f30b97 108
simon 0:b77078f30b97 109 }
simon 0:b77078f30b97 110
simon 0:b77078f30b97 111 #endif