Slight modifications to original for different LCD and mbed pin outs

Dependencies:   mbed

Fork of GT_Tuner by Andrew Durand

Committer:
mptapton
Date:
Fri Dec 16 10:15:01 2016 +0000
Revision:
2:0b7bf57470c4
Original code modified for a different LCD and mbed pin out. Additional output to LCD for real time input signal value

Who changed what in which revision?

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