naze-shippai-suru-noka

Dependencies:   TextLCD mbed pop3

Committer:
kogure7
Date:
Tue Nov 01 11:58:29 2011 +0000
Revision:
1:c5b02f551a38
Parent:
0:85a5c0651795

        

Who changed what in which revision?

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