Noriaki Mitsunaga / Mbed 2 deprecated DigiCam

Dependencies:   TextLCD mbed SDFileSystem

Committer:
non
Date:
Thu Oct 06 00:54:08 2011 +0000
Revision:
0:07d02a20d1cc

        

Who changed what in which revision?

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