Driver for a Text LCD using a PCF8574 over I2C It works with standard I2C Module with different pinout

Dependencies:   mbed

Fork of I2CTextLCD by Romilly Cocking

Revision:
1:3561ca8c9754
Parent:
0:6beb6f498640
--- a/TextLCD.cpp	Mon Aug 09 14:17:02 2010 +0000
+++ b/TextLCD.cpp	Fri Apr 06 09:33:48 2018 +0000
@@ -54,19 +54,22 @@
 TextLCD::TextLCD(PinName sda, PinName scl, int i2cAddress, LCDType type) : _i2c(sda, scl),
         _type(type) {
     _i2cAddress = i2cAddress;
-    wait(0.015);        // Wait 15ms to ensure powered up
+    wait(0.020);        // Wait 15ms to ensure powered up
 
     // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
     for (int i=0; i<3; i++) {
-        writeByte(0x3, false);
-        wait(0.00164);  // this command takes 1.64ms, so wait for it
+        writeByte(0x03, false);
+        wait(0.005);  // this command takes 1.64ms, so wait for it
     }
     writeByte(0x2, false);     // 4-bit mode
-    wait(0.000040f);    // most instructions take 40us
+    wait(0.000080f);    // most instructions take 40us
 
     writeCommand(0x28); // Function set 001 BW N F - -
+    wait(0.000080f);
     writeCommand(0x0C);
+    wait(0.000080f);
     writeCommand(0x6);  // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes
+    wait(0.000080f);
     cls();
 }
 
@@ -120,15 +123,17 @@
 }
 
 void TextLCD::writeNibble(int data, bool rs) {
+    data=data<<4;
+    data=data | 0x08; //backlight on
     if (rs) {
         data = data | RS_ON; // set rs bit
     }
     data |= E_ON; // E on
     writeI2CByte(data);
     data ^= E_ON; // E off
-    wait_us(1);
+    wait_us(100);
     writeI2CByte(data);
-    wait_us(1000);
+    wait_us(100);
 }
 
 void TextLCD::writeByte(int data, bool rs) {