Control a robot over the internet using UDP and a Wifly module (WiFi).

Dependencies:   Motor TextLCD WiflyInterface mbed-rtos mbed

Committer:
apatel336
Date:
Thu Oct 17 13:27:56 2013 +0000
Revision:
0:c0dc3a76f3d4
Initial Release

Who changed what in which revision?

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