LCD display

Dependents:   LAB05_Oppgave4

Fork of LCDLib by Rune Langoy

Revision:
4:264d9b06bf60
Parent:
3:d2f70de20dbe
Child:
5:d9eb6ed84a06
--- a/TextLCD.cpp	Sun Sep 20 11:06:45 2015 +0000
+++ b/TextLCD.cpp	Sun Sep 20 11:54:39 2015 +0000
@@ -17,50 +17,36 @@
 #define CLEAR_RW() (LCD_RW=0)
 
 
-//Enables the LCD Module for use 2-Lines...
-/*TextLCD::TextLCD()
+TextLCD::TextLCD(PinName rs,PinName rw, PinName e, PinName d4, PinName d5,
+                 PinName d6, PinName d7) : LCD_RS(rs),LCD_RW(rw),
+    LCD_EN(e), LCD_D4(d4), LCD_D5(d5), LCD_D6(d6), LCD_D7(d7)
 {
+
+    CLEAR_RW();
+    wait_ms(50);  // Wait for disp to turn on
+
     CLEAR_EN(); //EN =0
-    wait_ms(500);
+    CLEAR_RS();
 
-    init_4BitMode2LinesDisplayOn();  //enabler 4 bit mode
+    init_4BitMode2LinesDisplayOn();    //enabler 4 bit mode
+    wait_ms(1);
+
+    lcdComand(0x00);
     wait_us(100);
 
-    lcdComand(0x28);//(0b0010 1000);	// 4- bit mode   LCD 2 line 5x7 Matrix
+    lcdComand(0x28);//(0b0010 1000);   // 4- bit mode   LCD 2 line 16x2 Matrix
     wait_us(100);
-    lcdComand(0xE);//(0b0000 1110);  //Hva gjør vi her ?
+
+    lcdComand(0xE);//(0b0000 1110);    // Hva gjør vi her ?
     wait_us(100);
     lcdComand(0x01); //(0b00000001); //Hva gjør vi her ?
     wait_us(100);
     lcdComand(0x06);//(0b00000110);  //Hva gjør vi her ?
     wait_us(100);
-}*/
 
-TextLCD::TextLCD(PinName rs,PinName rw, PinName e, PinName d4, PinName d5,
-                 PinName d6, PinName d7) : LCD_RS(rs),LCD_RW(rw),
-        LCD_EN(e), LCD_D4(d4), LCD_D5(d5), LCD_D6(d6), LCD_D7(d7)
-{
-    CLEAR_EN(); //EN =0
-    wait_ms(500);
-
-    init_4BitMode2LinesDisplayOn();  //enabler 4 bit mode
-    wait_us(100);
-
-    lcdComand(0x28);//(0b0010 1000);	// 4- bit mode   LCD 2 line 5x7 Matrix
-    wait_us(100);
-    lcdComand(0xE);//(0b0000 1110);  //Hva gjør vi her ?
-    wait_us(100);
-    lcdComand(0x01); //(0b00000001); //Hva gjør vi her ?
-    wait_us(100);
-    lcdComand(0x06);//(0b00000110);  //Hva gjør vi her ?
-    wait_us(100);
 }
 
 
-
-
-
-
 // Causes the LCD-module to read the data on the data input pins
 void TextLCD::pulseEn()
 {
@@ -89,6 +75,17 @@
     CLEAR_RS();
     CLEAR_RW();
 
+    // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
+    writeLcdBitD4toD7(0x3);
+    pulseEn();
+    wait_ms(2);
+    writeLcdBitD4toD7(0x3);
+    pulseEn();
+    wait_ms(2);
+    writeLcdBitD4toD7(0x3);
+    pulseEn();
+    wait_ms(2);
+
     //Enable 4 bit mode  From KS0066U Documentation
     writeLcdBitD4toD7(0x2);//(0b0010);   // Select 4- bit start
     pulseEn();	//LCD exec function
@@ -136,8 +133,6 @@
     wait_us(100); //wait
 }
 
-
-
 //Moves cursor to the X,Y position
 void TextLCD::gotoxy(int x, int y)
 {
@@ -153,16 +148,7 @@
     return value;
 }
 
-int TextLCD::_getc() {
-    return -1;
-}
-
-//Writes a string to the LCD Display
-void TextLCD::lcd_print(char *str)
+int TextLCD::_getc()
 {
-    unsigned char i =0;
-    while(str[i] !=0) {
-        lcdData(str[i]);
-        i++;
-    }
+    return -1;
 }
\ No newline at end of file