for personal use

Committer:
freezeburger
Date:
Fri Jun 19 15:11:14 2020 +0000
Revision:
0:eebebe91fd28
[mbed] converted /TextLCD/TextLCD

Who changed what in which revision?

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