This program is for SG12864A(128 x 64 mono-LCD display) with Starboard Orange. Many of source code is referred from below website(in Japanese). (http://www.picfun.com/PIC24H/app24H01.html) Connection between SG12864A and mbed: (these connection are defined in SG12864A.h) pin1(VSS) pin2(VDD) : 5V pin3(V0) : pin4(DI) : p23 pin5(RW): p22 pin6(E): p21 pin7(DB0):p20 pin8(DB1):p19 pin9(DB2):p14 pin10(DB3):p13 pin11(DB4):p12 pin12(DB5):p11 pin13(DB6):p10 pin14(DB7):p9 pin15(CS1):p17 pin16(CS2):p16 pin17(RST):p15 pin18:VOUT pin19:LED Anode pin20:LED Cathode Note: lcd_Line function is not correct(maybe)... Other function is correctly working.

Dependencies:   mbed

Committer:
y_notsu
Date:
Sun Jan 09 11:44:15 2011 +0000
Revision:
0:d0cd5139479f
0.1(first release)

Who changed what in which revision?

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