Control a robot over the internet using UDP and a Ethernet interface.

Dependencies:   EthernetInterface Motor TextLCD mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
apatel336
Date:
Thu Oct 17 13:26:38 2013 +0000
Revision:
0:1496281373a5
Initial Release

Who changed what in which revision?

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