TextLCD

Dependents:   Tarea1_con_incremental

Fork of TextLCD by Pallavi Prasad

Committer:
lcorralesc1
Date:
Sun Oct 20 07:08:20 2013 +0000
Revision:
1:d7956bcc25ff
Parent:
0:de90b67b2bca
El comando lcd.write(C1) se hizo public para poder usarlo en el codigo trabajado

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
lcorralesc1 1:d7956bcc25ff 2 * Copyright (c) 2007-2010, sford, http://mbed.org
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 *
lcorralesc1 1:d7956bcc25ff 36 * TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d4-d7
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:
lcorralesc1 1:d7956bcc25ff 45 void writeCommand(int command); //quedo publica ya la podemos usar en el codigo C
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)
lcorralesc1 1:d7956bcc25ff 58 * @param d4-d7 Data lines for using as a 4-bit interface
pprasad7 0:de90b67b2bca 59 * @param type Sets the panel size/addressing mode (default = LCD16x2)
pprasad7 0:de90b67b2bca 60 */
lcorralesc1 1:d7956bcc25ff 61 TextLCD(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, 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();
lcorralesc1 1:d7956bcc25ff 90
lcorralesc1 1:d7956bcc25ff 91
pprasad7 0:de90b67b2bca 92 protected:
pprasad7 0:de90b67b2bca 93
pprasad7 0:de90b67b2bca 94 // Stream implementation functions
pprasad7 0:de90b67b2bca 95 virtual int _putc(int value);
pprasad7 0:de90b67b2bca 96 virtual int _getc();
pprasad7 0:de90b67b2bca 97
pprasad7 0:de90b67b2bca 98 int address(int column, int row);
pprasad7 0:de90b67b2bca 99 void character(int column, int row, int c);
pprasad7 0:de90b67b2bca 100 void writeByte(int value);
lcorralesc1 1:d7956bcc25ff 101 //void writeCommand(int command); esta se documenta para poder poner comandos quedo publica
pprasad7 0:de90b67b2bca 102 void writeData(int data);
pprasad7 0:de90b67b2bca 103
pprasad7 0:de90b67b2bca 104 DigitalOut _rs, _e;
pprasad7 0:de90b67b2bca 105 BusOut _d;
pprasad7 0:de90b67b2bca 106 LCDType _type;
pprasad7 0:de90b67b2bca 107
pprasad7 0:de90b67b2bca 108 int _column;
pprasad7 0:de90b67b2bca 109 int _row;
pprasad7 0:de90b67b2bca 110 };
pprasad7 0:de90b67b2bca 111
lcorralesc1 1:d7956bcc25ff 112 #endif