Lab Checkoff

Dependencies:   SDFileSystem TextLCD mbed-rtos mbed wave_player FATFileSystem

Committer:
doubster
Date:
Wed Nov 13 20:00:28 2013 +0000
Revision:
0:67dbd54e60d4
Lab Checkoff

Who changed what in which revision?

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