Jozsef Benecs / Mbed 2 deprecated Measure_system

Dependencies:   EthernetNetIf mbed RF12B

Committer:
benecsj
Date:
Thu Mar 03 08:45:49 2011 +0000
Revision:
0:8d62137f7ff4
For FRIENDs.

Who changed what in which revision?

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