Robot Security System

Dependencies:   Motordriver SHTx mbed

Committer:
dmehta39
Date:
Fri Oct 12 05:21:40 2012 +0000
Revision:
0:b6d5c2bbe0a8
Robot Security System

Who changed what in which revision?

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