Functions test with Optrex LCD 20x4

Dependencies:   mbed

Dependents:   DatatypesLength AsciiCode IntegerFormatSpecifiers FloatFormatSpecifier

Committer:
Eduard
Date:
Mon Nov 29 22:27:13 2010 +0000
Revision:
3:52fb10c44695

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Eduard 3:52fb10c44695 1 /*******************************************************************************************
Eduard 3:52fb10c44695 2 * Program to test OptrexLCD library witch is a clone of TextLCD only with a different timing.
Eduard 3:52fb10c44695 3 * Normaly it takes a 40us enable puls to execute an instruction, but with the optrex 20x4 LCD
Eduard 3:52fb10c44695 4 * it takes 75us. Also the cls command takes 3ms instead of the 1.64ms which is normal.
Eduard 3:52fb10c44695 5 * Because the timing is the only difference, all functionality is equal to TextLCD.
Eduard 3:52fb10c44695 6 * Probally the OptrexLCD library works with other LCD as well, if not the origenal TextLCD library
Eduard 3:52fb10c44695 7 * can included instead.
Eduard 3:52fb10c44695 8 * The program write the text: "Start" and after half a second: "Hello rownr:0" next to it on the first row.
Eduard 3:52fb10c44695 9 * After another half a second it writes: "Second row? rownr:1" on the next row, then it
Eduard 3:52fb10c44695 10 * will write: "Third row? rownr:2" on the next and: "Fourth row? rownr:3" on the last.
Eduard 3:52fb10c44695 11 * After 1 second the screen got cleared and ASCII character nr.65 ("A") is put to the LCD at column "0"
Eduard 3:52fb10c44695 12 * and row "0". Then character nr.66 ("B") is written to column "1" and row "1". Next nr67 ("C") is written
Eduard 3:52fb10c44695 13 * to column "2", row "2" and nr68 ("D") on "3,3". Row "3" is the last row. When trying to select row "4" the
Eduard 3:52fb10c44695 14 * LCD goes in "Two Rows" mode instead of "Four Rows" mode. The characters "E" to "H" are written
Eduard 3:52fb10c44695 15 * in upwards direction.
Eduard 3:52fb10c44695 16 **********************************************************************************************/
Eduard 3:52fb10c44695 17 #include "mbed.h"
Eduard 3:52fb10c44695 18 #include "OptrexLCD.h"
Eduard 3:52fb10c44695 19
Eduard 3:52fb10c44695 20 DigitalOut BlinkLed(LED4); // when the led is blinking the program runs well
Eduard 3:52fb10c44695 21
Eduard 3:52fb10c44695 22 TextLCD lcd(p10, p12, p15, p16, p17, p18, TextLCD::LCD20x4 ); // rs, e, d0-d3
Eduard 3:52fb10c44695 23
Eduard 3:52fb10c44695 24 int main()
Eduard 3:52fb10c44695 25 {
Eduard 3:52fb10c44695 26 while(1)
Eduard 3:52fb10c44695 27 {
Eduard 3:52fb10c44695 28 BlinkLed = !BlinkLed; //indicates the programm is running
Eduard 3:52fb10c44695 29
Eduard 3:52fb10c44695 30 lcd.printf("Start "); // the printf instruction writes a text string to the LCD
Eduard 3:52fb10c44695 31 wait(0.5);
Eduard 3:52fb10c44695 32 lcd.printf("Hello rownr:0\n"); // the "\n" directive tells the program to go to the next row.
Eduard 3:52fb10c44695 33 wait(0.5);
Eduard 3:52fb10c44695 34 lcd.printf("Second row? rownr:1\n");
Eduard 3:52fb10c44695 35 wait(0.5);
Eduard 3:52fb10c44695 36 lcd.printf("Third row? rownr:2\n");
Eduard 3:52fb10c44695 37 wait(0.5);
Eduard 3:52fb10c44695 38 lcd.printf("Fourth row? rownr:3\n");
Eduard 3:52fb10c44695 39 wait(0.5);
Eduard 3:52fb10c44695 40 lcd.printf("Fifth row? rownr:4\n"); // there are only four rows, the fifth wil be at the first row, rownr:0.
Eduard 3:52fb10c44695 41 wait(0.5);
Eduard 3:52fb10c44695 42 lcd.printf("Sixth row? rownr:5\n"); // this wil be written on the second row
Eduard 3:52fb10c44695 43 wait(2);
Eduard 3:52fb10c44695 44
Eduard 3:52fb10c44695 45 lcd.cls(); // clear the LCD and go to column "0" and row "0"
Eduard 3:52fb10c44695 46 wait(0.5);
Eduard 3:52fb10c44695 47
Eduard 3:52fb10c44695 48 lcd.putc(65); // put character 65 (A) at column "0" and row "0"
Eduard 3:52fb10c44695 49 wait(0.5);
Eduard 3:52fb10c44695 50 lcd.locate(1,1); // go to column "1" and row "1"
Eduard 3:52fb10c44695 51 lcd.putc(66); // put a "B" in (1,1)
Eduard 3:52fb10c44695 52 wait(0.5);
Eduard 3:52fb10c44695 53 lcd.locate(2,2);
Eduard 3:52fb10c44695 54 lcd.putc(67); // put a "C" in (2,2)
Eduard 3:52fb10c44695 55 wait(0.5);
Eduard 3:52fb10c44695 56 lcd.locate(3,3);
Eduard 3:52fb10c44695 57 lcd.putc(68);
Eduard 3:52fb10c44695 58 wait(0.5);
Eduard 3:52fb10c44695 59
Eduard 3:52fb10c44695 60 lcd.locate(4,3);
Eduard 3:52fb10c44695 61 lcd.putc(69);
Eduard 3:52fb10c44695 62 wait(0.5);
Eduard 3:52fb10c44695 63 lcd.locate(5,2);
Eduard 3:52fb10c44695 64 lcd.putc(70);
Eduard 3:52fb10c44695 65 wait(0.5);
Eduard 3:52fb10c44695 66 lcd.locate(6,1);
Eduard 3:52fb10c44695 67 lcd.putc(71);
Eduard 3:52fb10c44695 68 wait(0.5);
Eduard 3:52fb10c44695 69 lcd.locate(7,0);
Eduard 3:52fb10c44695 70 lcd.putc(72);
Eduard 3:52fb10c44695 71 wait(0.5);
Eduard 3:52fb10c44695 72
Eduard 3:52fb10c44695 73 lcd.cls();
Eduard 3:52fb10c44695 74 wait(0.5);
Eduard 3:52fb10c44695 75 }
Eduard 3:52fb10c44695 76 }