Modified TextLCD library to support DOG series displays with ST7036 controller.

Committer:
leliep
Date:
Mon Oct 25 08:04:30 2010 +0000
Revision:
0:c07e086b8996
Child:
1:42fadf37be5b
Maybe somebody could merge this into the original Version. The only changes have been in the display initialization part, nothing highly sophisticated.

Who changed what in which revision?

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