jkxvjdjg

Fork of TextLCD by Pallavi Prasad

Committer:
javiernegrette
Date:
Fri Nov 08 17:01:15 2013 +0000
Revision:
1:bb9be1ccca1e
Parent:
0:de90b67b2bca
kjbfgjfdbgjf

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pprasad7 0:de90b67b2bca 1 /* mbed TextLCD Library, for a 4-bit LCD based on HD44780
pprasad7 0:de90b67b2bca 2 * Copyright (c) 2007-2010, sford
pprasad7 0:de90b67b2bca 3 *
pprasad7 0:de90b67b2bca 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
pprasad7 0:de90b67b2bca 5 * of this software and associated documentation files (the "Software"), to deal
pprasad7 0:de90b67b2bca 6 * in the Software without restriction, including without limitation the rights
pprasad7 0:de90b67b2bca 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
pprasad7 0:de90b67b2bca 8 * copies of the Software, and to permit persons to whom the Software is
pprasad7 0:de90b67b2bca 9 * furnished to do so, subject to the following conditions:
pprasad7 0:de90b67b2bca 10 *
pprasad7 0:de90b67b2bca 11 * The above copyright notice and this permission notice shall be included in
pprasad7 0:de90b67b2bca 12 * all copies or substantial portions of the Software.
pprasad7 0:de90b67b2bca 13 *
pprasad7 0:de90b67b2bca 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
pprasad7 0:de90b67b2bca 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
pprasad7 0:de90b67b2bca 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
pprasad7 0:de90b67b2bca 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
pprasad7 0:de90b67b2bca 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
pprasad7 0:de90b67b2bca 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
pprasad7 0:de90b67b2bca 20 * THE SOFTWARE.
pprasad7 0:de90b67b2bca 21 */
pprasad7 0:de90b67b2bca 22
pprasad7 0:de90b67b2bca 23 #ifndef MBED_TEXTLCD_H
pprasad7 0:de90b67b2bca 24 #define MBED_TEXTLCD_H
pprasad7 0:de90b67b2bca 25
pprasad7 0:de90b67b2bca 26 #include "mbed.h"
pprasad7 0:de90b67b2bca 27
pprasad7 0:de90b67b2bca 28 /** A TextLCD interface for driving 4-bit HD44780-based LCDs
pprasad7 0:de90b67b2bca 29 *
pprasad7 0:de90b67b2bca 30 * Currently supports 16x2, 20x2 and 20x4 panels
pprasad7 0:de90b67b2bca 31 *
pprasad7 0:de90b67b2bca 32 * @code
pprasad7 0:de90b67b2bca 33 * #include "mbed.h"
pprasad7 0:de90b67b2bca 34 * #include "TextLCD.h"
pprasad7 0:de90b67b2bca 35 *
pprasad7 0:de90b67b2bca 36 * TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d0-d3
pprasad7 0:de90b67b2bca 37 *
pprasad7 0:de90b67b2bca 38 * int main() {
pprasad7 0:de90b67b2bca 39 * lcd.printf("Hello World!\n");
pprasad7 0:de90b67b2bca 40 * }
pprasad7 0:de90b67b2bca 41 * @endcode
pprasad7 0:de90b67b2bca 42 */
pprasad7 0:de90b67b2bca 43 class TextLCD : public Stream {
pprasad7 0:de90b67b2bca 44 public:
javiernegrette 1:bb9be1ccca1e 45 void writeCommand(int command);
pprasad7 0:de90b67b2bca 46 /** LCD panel format */
pprasad7 0:de90b67b2bca 47 enum LCDType {
pprasad7 0:de90b67b2bca 48 LCD16x2 /**< 16x2 LCD panel (default) */
pprasad7 0:de90b67b2bca 49 , LCD16x2B /**< 16x2 LCD panel alternate addressing */
pprasad7 0:de90b67b2bca 50 , LCD20x2 /**< 20x2 LCD panel */
pprasad7 0:de90b67b2bca 51 , LCD20x4 /**< 20x4 LCD panel */
pprasad7 0:de90b67b2bca 52 };
pprasad7 0:de90b67b2bca 53
pprasad7 0:de90b67b2bca 54 /** Create a TextLCD interface
pprasad7 0:de90b67b2bca 55 *
pprasad7 0:de90b67b2bca 56 * @param rs Instruction/data control line
pprasad7 0:de90b67b2bca 57 * @param e Enable line (clock)
pprasad7 0:de90b67b2bca 58 * @param d0-d3 Data lines
pprasad7 0:de90b67b2bca 59 * @param type Sets the panel size/addressing mode (default = LCD16x2)
pprasad7 0:de90b67b2bca 60 */
pprasad7 0:de90b67b2bca 61 TextLCD(PinName rs, PinName e, PinName d0, PinName d1, PinName d2, PinName d3, LCDType type = LCD16x2);
pprasad7 0:de90b67b2bca 62
pprasad7 0:de90b67b2bca 63 #if DOXYGEN_ONLY
pprasad7 0:de90b67b2bca 64 /** Write a character to the LCD
pprasad7 0:de90b67b2bca 65 *
pprasad7 0:de90b67b2bca 66 * @param c The character to write to the display
pprasad7 0:de90b67b2bca 67 */
pprasad7 0:de90b67b2bca 68 int putc(int c);
pprasad7 0:de90b67b2bca 69
pprasad7 0:de90b67b2bca 70 /** Write a formated string to the LCD
pprasad7 0:de90b67b2bca 71 *
pprasad7 0:de90b67b2bca 72 * @param format A printf-style format string, followed by the
pprasad7 0:de90b67b2bca 73 * variables to use in formating the string.
pprasad7 0:de90b67b2bca 74 */
pprasad7 0:de90b67b2bca 75 int printf(const char* format, ...);
pprasad7 0:de90b67b2bca 76 #endif
pprasad7 0:de90b67b2bca 77
pprasad7 0:de90b67b2bca 78 /** Locate to a screen column and row
pprasad7 0:de90b67b2bca 79 *
pprasad7 0:de90b67b2bca 80 * @param column The horizontal position from the left, indexed from 0
pprasad7 0:de90b67b2bca 81 * @param row The vertical position from the top, indexed from 0
pprasad7 0:de90b67b2bca 82 */
pprasad7 0:de90b67b2bca 83 void locate(int column, int row);
pprasad7 0:de90b67b2bca 84
pprasad7 0:de90b67b2bca 85 /** Clear the screen and locate to 0,0 */
pprasad7 0:de90b67b2bca 86 void cls();
pprasad7 0:de90b67b2bca 87
pprasad7 0:de90b67b2bca 88 int rows();
pprasad7 0:de90b67b2bca 89 int columns();
pprasad7 0:de90b67b2bca 90
pprasad7 0:de90b67b2bca 91 protected:
pprasad7 0:de90b67b2bca 92
pprasad7 0:de90b67b2bca 93 // Stream implementation functions
pprasad7 0:de90b67b2bca 94 virtual int _putc(int value);
pprasad7 0:de90b67b2bca 95 virtual int _getc();
pprasad7 0:de90b67b2bca 96
pprasad7 0:de90b67b2bca 97 int address(int column, int row);
pprasad7 0:de90b67b2bca 98 void character(int column, int row, int c);
pprasad7 0:de90b67b2bca 99 void writeByte(int value);
javiernegrette 1:bb9be1ccca1e 100 //void writeCommand(int command);
pprasad7 0:de90b67b2bca 101 void writeData(int data);
pprasad7 0:de90b67b2bca 102
pprasad7 0:de90b67b2bca 103 DigitalOut _rs, _e;
pprasad7 0:de90b67b2bca 104 BusOut _d;
pprasad7 0:de90b67b2bca 105 LCDType _type;
pprasad7 0:de90b67b2bca 106
pprasad7 0:de90b67b2bca 107 int _column;
pprasad7 0:de90b67b2bca 108 int _row;
pprasad7 0:de90b67b2bca 109 };
pprasad7 0:de90b67b2bca 110
pprasad7 0:de90b67b2bca 111 #endif