Dependents:   tarea1

Fork of TextLCD by Simon Ford

Committer:
caaruizze
Date:
Mon Nov 18 01:41:20 2013 +0000
Revision:
8:32640818bc85
HOLA;

Who changed what in which revision?

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