Yet another I2C Text based LCD display program

Dependencies:   mbed

Committer:
pwheels
Date:
Sun Jan 19 14:23:58 2014 +0000
Revision:
2:91dec3d7903a
Parent:
1:d8767e2b8e7e
updated string to display command

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pwheels 0:551f3dbd553c 1 /*
pwheels 0:551f3dbd553c 2 * Copyright (c) 2011 Paul van der Wielen, Pro-Serv
pwheels 0:551f3dbd553c 3 *
pwheels 0:551f3dbd553c 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
pwheels 0:551f3dbd553c 5 * of this software and associated documentation files (the "Software"), to use
pwheels 0:551f3dbd553c 6 * and implement the software for none commercial reason and usage only and
pwheels 0:551f3dbd553c 7 * subject to the following conditions:
pwheels 0:551f3dbd553c 8 *
pwheels 0:551f3dbd553c 9 * The above copyright notice and this permission notice shall be included in
pwheels 0:551f3dbd553c 10 * all copies or substantial portions of the Software.
pwheels 0:551f3dbd553c 11 *
pwheels 0:551f3dbd553c 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
pwheels 0:551f3dbd553c 13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
pwheels 0:551f3dbd553c 14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
pwheels 0:551f3dbd553c 15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
pwheels 0:551f3dbd553c 16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
pwheels 0:551f3dbd553c 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
pwheels 0:551f3dbd553c 18 * THE SOFTWARE.
pwheels 0:551f3dbd553c 19 *
pwheels 0:551f3dbd553c 20 * Usage and assumptions:
pwheels 0:551f3dbd553c 21 * coding as to interface an I2C LC Display modle available from:
pwheels 0:551f3dbd553c 22 * Coptonix GmbH
pwheels 0:551f3dbd553c 23 * Berlin 24.06.2008by @ less than Euro 13.-
pwheels 0:551f3dbd553c 24 * which will interface to various HD44780 based units, 8Bit-Interface (16x2 or 20x4)
pwheels 0:551f3dbd553c 25 *
pwheels 0:551f3dbd553c 26 * Used device = LPC1768
pwheels 0:551f3dbd553c 27 */
pwheels 0:551f3dbd553c 28 #include "mbed.h"
pwheels 0:551f3dbd553c 29 #include "lc_display.h"
pwheels 0:551f3dbd553c 30
pwheels 0:551f3dbd553c 31 DigitalOut flash(LED1);
pwheels 0:551f3dbd553c 32
pwheels 0:551f3dbd553c 33 int main() {
pwheels 0:551f3dbd553c 34
pwheels 0:551f3dbd553c 35 // define some user characters for LCD display
pwheels 0:551f3dbd553c 36 char MySymbol[2][9]= {{0x01,0x04,0x0e,0x1f,0x04,0x04,0x04,0x00,0x00},
pwheels 0:551f3dbd553c 37 {0x02,0x00,0x00,0x04,0x04,0x04,0x1f,0x0e,0x04}};
pwheels 0:551f3dbd553c 38 //
pwheels 0:551f3dbd553c 39 _InitLCD();
pwheels 0:551f3dbd553c 40 _WriteLCD(LCDType,0x01);
pwheels 0:551f3dbd553c 41 _WriteLCD(WriteUserDefChar,MySymbol[0],9);
pwheels 0:551f3dbd553c 42 _WriteLCD(WriteUserDefChar,MySymbol[1],9);
pwheels 0:551f3dbd553c 43 while (1) {
pwheels 0:551f3dbd553c 44 _WriteLCD(ClrDisplay);
pwheels 0:551f3dbd553c 45 _WriteLCD(DisplayON_OFF, 1, 1, 0);
pwheels 0:551f3dbd553c 46 _WriteLCD(WriteString, "Hello tester !", 14);
pwheels 0:551f3dbd553c 47 _WriteLCD(SetCursor, 0x05);
pwheels 0:551f3dbd553c 48 _WriteLCD(Shift, 1, 1);
pwheels 0:551f3dbd553c 49 _WriteLCD(Delete, 1, 3, 4);
pwheels 0:551f3dbd553c 50 _WriteLCD(SetCursor, 0x45);
pwheels 0:551f3dbd553c 51 _WriteLCD(CharToLCD, 0x01);
pwheels 2:91dec3d7903a 52 _WriteLCD(SetCursor, 0x14);
pwheels 0:551f3dbd553c 53 _WriteLCD(CharToLCD, 0x02);
pwheels 2:91dec3d7903a 54 _WriteLCD(SetCursor, 0x54);
pwheels 2:91dec3d7903a 55 _WriteLCD(CharToLCD, 0x30);
pwheels 0:551f3dbd553c 56 _WriteLCD(Shift, 0, 0);
pwheels 0:551f3dbd553c 57 // log to usb serial port, visible by Tera Term
pwheels 0:551f3dbd553c 58 printf("Character ->%c<- at position %d, ram = %x\r\n", _ReadLCD(GetCharAtCur), _ReadLCD(GetCursorAdr), _ReadLCD(ReadRam));
pwheels 1:d8767e2b8e7e 59 wait(4);
pwheels 0:551f3dbd553c 60 _WriteLCD(ReturnHome);
pwheels 0:551f3dbd553c 61 _WriteLCD(DisplayON_OFF, 0, 1, 1);
pwheels 0:551f3dbd553c 62 wait(1);
pwheels 0:551f3dbd553c 63 flash = !flash;
pwheels 0:551f3dbd553c 64 }
pwheels 0:551f3dbd553c 65 }